Package org.apache.hadoop.hdfs.server.namenode

Examples of org.apache.hadoop.hdfs.server.namenode.NameNode


      // write 1/2 block & close
      stm = fs1.create(file1, true, (int)BLOCK_SIZE*2, rep, BLOCK_SIZE);
      AppendTestUtil.write(stm, 0, halfBlock);
      stm.close();

      NameNode nn = cluster.getNameNode();
      LOG.info("======== Appending");
      stm = fs1.append(file1);
      LOG.info("======== Writing");
      AppendTestUtil.write(stm, 0, halfBlock/2);
      LOG.info("======== Checking progress");
View Full Code Here


      // write 1/2 block & close
      stm = fs1.create(file1, true, (int)BLOCK_SIZE*2, rep, BLOCK_SIZE);
      AppendTestUtil.write(stm, 0, halfBlock);
      stm.close();

      NameNode nn = cluster.getNameNode();
      LOG.info("======== Appending");
      stm = fs1.append(file1);
      LOG.info("======== Writing");
      AppendTestUtil.write(stm, 0, halfBlock/4);

View Full Code Here

   * with no .append() called.
   */
  public void testNotPrematurelyCompleteWithFailureNotReopened() throws Exception {
    LOG.info("START");
    cluster = new MiniDFSCluster(conf, 3, true, null);
    NameNode nn = cluster.getNameNode();
    FileSystem fs1 = cluster.getFileSystem();
    try {
      short rep = 3; // replication

      file1 = new Path("/delayedReceiveBlock");
View Full Code Here

      loseLeases(fs1);

      // Make the first nextGenerationStamp call get delayed
      DelayAnswer delayer = new DelayAnswer(false);

      NameNode nn = cluster.getNameNode();
      nn.namesystem = spy(nn.namesystem);
      NameNodeAdapter.callNextGenerationStampForBlock(
        doAnswer(delayer).when(nn.namesystem),
        (Block)anyObject());
View Full Code Here

    // make sure JT starts
    jConf = mrCluster.createJobConf();
   
    // provide namenodes names for the job to get the delegation tokens for
    //String nnUri = dfsCluster.getNameNode().getUri(namenode).toString();
    NameNode nn = dfsCluster.getNameNode();
    URI nnUri = NameNode.getUri(nn.getNameNodeAddress());
    jConf.set(JobContext.JOB_NAMENODES, nnUri + "," + nnUri.toString());
    // job tracker principle id..
    jConf.set(JobTracker.JT_USER_NAME, "jt_id");

    // using argument to pass the file name
View Full Code Here

    // Start a second DN for this test -- we're checking
    // what happens when one of the DNs is slowed for some reason.
    REPL_FACTOR = 2;
    startDNandWait(null, false);

    NameNode nn = cluster.getNameNode();

    FSDataOutputStream out = fs.create(filePath, REPL_FACTOR);
    try {
      AppendTestUtil.write(out, 0, 10);
      out.hflush();

      // Set up a spy so that we can delay the block report coming
      // from this node.
      DataNode dn = cluster.getDataNodes().get(0);
      DatanodeProtocolClientSideTranslatorPB spy =
        DataNodeTestUtils.spyOnBposToNN(dn, nn);

      Mockito.doAnswer(delayer)
        .when(spy).blockReport(
          Mockito.<DatanodeRegistration>anyObject(),
          Mockito.anyString(),
          Mockito.<StorageBlockReport[]>anyObject());

      // Force a block report to be generated. The block report will have
      // an RBW replica in it. Wait for the RPC to be sent, but block
      // it before it gets to the NN.
      dn.scheduleAllBlockReport(0);
      delayer.waitForCall();

    } finally {
      IOUtils.closeStream(out);
    }

    // Now that the stream is closed, the NN will have the block in COMPLETE
    // state.
    delayer.proceed();
    brFinished.await();

    // Verify that no replicas are marked corrupt, and that the
    // file is still readable.
    BlockManagerTestUtil.updateState(nn.getNamesystem().getBlockManager());
    assertEquals(0, nn.getNamesystem().getCorruptReplicaBlocks());
    DFSTestUtil.readFile(fs, filePath);

    // Ensure that the file is readable even from the DN that we futzed with.
    cluster.stopDataNode(1);
    DFSTestUtil.readFile(fs, filePath);
View Full Code Here

    assertEquals(0, runTool("-getServiceState", "nn1"));
  }
   
  @Test
  public void testStateTransition() throws Exception {
    NameNode nnode1 = cluster.getNameNode(0);
    assertTrue(nnode1.isStandbyState());
    assertEquals(0, runTool("-transitionToActive", "nn1"));
    assertFalse(nnode1.isStandbyState());      
    assertEquals(0, runTool("-transitionToStandby", "nn1"));
    assertTrue(nnode1.isStandbyState());
   
    NameNode nnode2 = cluster.getNameNode(1);
    assertTrue(nnode2.isStandbyState());
    assertEquals(0, runTool("-transitionToActive", "nn2"));
    assertFalse(nnode2.isStandbyState());
    assertEquals(0, runTool("-transitionToStandby", "nn2"));
    assertTrue(nnode2.isStandbyState());
  }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testTransitionToActiveWhenOtherNamenodeisActive()
      throws Exception {
    NameNode nn1 = cluster.getNameNode(0);
    NameNode nn2 = cluster.getNameNode(1);
    if(nn1.getState() != null && !nn1.getState().
        equals(HAServiceState.STANDBY.name()) ) {
      cluster.transitionToStandby(0);
    }
    if(nn2.getState() != null && !nn2.getState().
        equals(HAServiceState.STANDBY.name()) ) {
      cluster.transitionToStandby(1);
    }
    //Making sure both the namenode are in standby state
    assertTrue(nn1.isStandbyState());
    assertTrue(nn2.isStandbyState());
    // Triggering the transition for both namenode to Active
    runTool("-transitionToActive", "nn1");
    runTool("-transitionToActive", "nn2");

    assertFalse("Both namenodes cannot be active", nn1.isActiveState()
        && nn2.isActiveState());
  
    /*  This test case doesn't allow nn2 to transition to Active even with
        forceActive switch since nn1 is already active  */
    if(nn1.getState() != null && !nn1.getState().
        equals(HAServiceState.STANDBY.name()) ) {
      cluster.transitionToStandby(0);
    }
    if(nn2.getState() != null && !nn2.getState().
        equals(HAServiceState.STANDBY.name()) ) {
      cluster.transitionToStandby(1);
    }
    //Making sure both the namenode are in standby state
    assertTrue(nn1.isStandbyState());
    assertTrue(nn2.isStandbyState());
   
    runTool("-transitionToActive", "nn1");
    runTool("-transitionToActive", "nn2","--forceactive");
   
    assertFalse("Both namenodes cannot be active even though with forceActive",
        nn1.isActiveState() && nn2.isActiveState());

    /*  In this test case, we have deliberately shut down nn1 and this will
        cause HAAAdmin#isOtherTargetNodeActive to throw an Exception
        and transitionToActive for nn2 with  forceActive switch will succeed
        even with Exception  */
    cluster.shutdownNameNode(0);
    if(nn2.getState() != null && !nn2.getState().
        equals(HAServiceState.STANDBY.name()) ) {
      cluster.transitionToStandby(1);
    }
    //Making sure both the namenode (nn2) is in standby state
    assertTrue(nn2.isStandbyState());
    assertFalse(cluster.isNameNodeUp(0));
   
    runTool("-transitionToActive", "nn2", "--forceactive");
    assertTrue("Namenode nn2 should be active", nn2.isActiveState());
  }
View Full Code Here

    try {
      cluster = new MiniDFSCluster.Builder(conf).numDataNodes(numDataNodes).build();
      cluster.waitActive();
      assertEquals(numDataNodes, cluster.getDataNodes().size());

      final NameNode nn = cluster.getNameNode();
      final BlockManager bm = nn.getNamesystem().getBlockManager();
      final BlockTokenSecretManager sm = bm.getBlockTokenSecretManager();

      // set a short token lifetime (1 second)
      SecurityTestUtil.setBlockTokenLifetime(sm, 1000L);
      Path fileToAppend = new Path(FILE_TO_APPEND);
View Full Code Here

    try {
      cluster = new MiniDFSCluster.Builder(conf).numDataNodes(numDataNodes).build();
      cluster.waitActive();
      assertEquals(numDataNodes, cluster.getDataNodes().size());

      final NameNode nn = cluster.getNameNode();
      final BlockManager bm = nn.getNamesystem().getBlockManager();
      final BlockTokenSecretManager sm = bm.getBlockTokenSecretManager();

      // set a short token lifetime (1 second)
      SecurityTestUtil.setBlockTokenLifetime(sm, 1000L);
      Path fileToWrite = new Path(FILE_TO_WRITE);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.server.namenode.NameNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.