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

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


    // Not available in 0.20 hdfs.  Use reflection to make it happen.

    // private NameNode nameNode;
    Field field = this.dfsCluster.getClass().getDeclaredField("nameNode");
    field.setAccessible(true);
    NameNode nn = (NameNode)field.get(this.dfsCluster);
    nn.namesystem.leaseManager.setLeasePeriod(100, 50000);
  }
View Full Code Here


    // Not available in 0.20 hdfs.  Use reflection to make it happen.

    // private NameNode nameNode;
    Field field = this.dfsCluster.getClass().getDeclaredField("nameNode");
    field.setAccessible(true);
    NameNode nn = (NameNode)field.get(this.dfsCluster);
    nn.namesystem.leaseManager.setLeasePeriod(100, 50000);
  }
View Full Code Here

    assertTrue(maxBlockAcquires > 0);

    try {
      cluster.waitActive();
      FileSystem fs = cluster.getFileSystem();
      NameNode preSpyNN = cluster.getNameNode();
      NameNode spyNN = spy(preSpyNN);
      DFSClient client = new DFSClient(null, spyNN, conf, null);

      DFSTestUtil.createFile(fs, file, fileSize, (short)1, 12345L /*seed*/);

      // If the client will retry maxBlockAcquires times, then if we fail
View Full Code Here

    assertTrue(maxBlockAcquires > 0);

    try {
      cluster.waitActive();
      FileSystem fs = cluster.getFileSystem();
      NameNode preSpyNN = cluster.getNameNode();
      NameNode spyNN = spy(preSpyNN);
      DFSClient client = new DFSClient(null, spyNN, conf, null);

      DFSTestUtil.createFile(fs, file, fileSize, (short)1, 12345L /*seed*/);

      // If the client will retry maxBlockAcquires times, then if we fail
View Full Code Here

      cluster = new MiniDFSCluster(conf, 0, false, null);
      cluster.waitActive();
     
      LOG.info("Restarted cluster with just the NameNode");
     
      NameNode namenode = cluster.getNameNode();
     
      assertTrue("No datanode is started. Should be in SafeMode",
                 namenode.isInSafeMode());
     
      // manually set safemode.
      namenode.setSafeMode(SafeModeAction.SAFEMODE_ENTER);
     
      // now bring up the datanode and wait for it to be active.
      cluster.startDataNodes(conf, 1, true, null, null);
      cluster.waitActive();
     
      LOG.info("Datanode is started.");
     
      try {
        Thread.sleep(2000);
      } catch (InterruptedException ignored) {}
     
      assertTrue("should still be in SafeMode", namenode.isInSafeMode());
     
      namenode.setSafeMode(SafeModeAction.SAFEMODE_LEAVE);
      assertFalse("should not be in SafeMode", namenode.isInSafeMode());
    } finally {
      if(fs != null) fs.close();
      if(cluster!= null) cluster.shutdown();
    }
  }
View Full Code Here

      // create two files with one block each.
      DFSTestUtil.createFile(fs, file1, 1000, (short) 1, 0);
      DFSTestUtil.createFile(fs, file2, 2000, (short) 1, 0);
      checkGetBlockLocationsWorks(fs, file1);

      NameNode namenode = cluster.getNameNode();
      namenode.setSafeMode(SafeModeAction.SAFEMODE_ENTER);
      Assert.assertTrue("should still be in SafeMode", namenode.isInSafeMode());
      // getBlock locations should still work since block locations exists
      checkGetBlockLocationsWorks(fs, file1);
      namenode.setSafeMode(SafeModeAction.SAFEMODE_LEAVE);
      assertFalse("should not be in SafeMode", namenode.isInSafeMode());
      Assert.assertFalse("should not be in SafeMode", namenode.isInSafeMode());

      // Now 2nd part of the tests where there aren't block locations
      cluster.shutdownDataNodes();
      cluster.shutdownNameNode();

      // now bring up just the NameNode.
      cluster.restartNameNode();
      cluster.waitActive();

      LOG.info("Restarted cluster with just the NameNode");

      namenode = cluster.getNameNode();

      Assert.assertTrue("No datanode is started. Should be in SafeMode",
          namenode.isInSafeMode());
      FileStatus stat = fs.getFileStatus(file1);
      try {
        fs.getFileBlockLocations(stat, 0, 1000);
        Assert.assertTrue("Should have got safemode exception", false);
      } catch (SafeModeException e) {
        // as expected
      } catch (RemoteException re) {
        if (!re.getClassName().equals(SafeModeException.class.getName()))
          Assert.assertTrue("Should have got safemode exception", false);
      }

      namenode.setSafeMode(SafeModeAction.SAFEMODE_LEAVE);
      Assert.assertFalse("Should not be in safemode", namenode.isInSafeMode());
      checkGetBlockLocationsWorks(fs, file1);

    } finally {
      if (fs != null)
        fs.close();
View Full Code Here

  public void testRecoverFinalizedBlock() throws Throwable {
    cluster = new MiniDFSCluster(conf, 3, true, null);

    try {
      cluster.waitActive();
      NameNode preSpyNN = cluster.getNameNode();
      NameNode spyNN = spy(preSpyNN);

      // Delay completeFile
      DelayAnswer delayer = new DelayAnswer();
      doAnswer(delayer).when(spyNN).complete(anyString(), anyString());
View Full Code Here

  public void testCompleteOtherLeaseHoldersFile() throws Throwable {
    cluster = new MiniDFSCluster(conf, 3, true, null);

    try {
      cluster.waitActive();
      NameNode preSpyNN = cluster.getNameNode();
      NameNode spyNN = spy(preSpyNN);

      // Delay completeFile
      DelayAnswer delayer = new DelayAnswer();
      doAnswer(delayer).when(spyNN).complete(anyString(), anyString());
View Full Code Here

      createFile(fs1, "/datanodeFailsCommit.test", 1, BBW_SIZE);
      stm.sync();
      loseLeases(fs1);

      // Make the NN fail to commitBlockSynchronization one time
      NameNode nn = cluster.getNameNode();
      nn.namesystem = spy(nn.namesystem);
      doAnswer(new ThrowNTimesAnswer(IOException.class, 1)).
        when(nn.namesystem).
        commitBlockSynchronization((Block)anyObject(), anyInt(), anyInt(),
                                   anyBoolean(), anyBoolean(),
View Full Code Here

    ;
    final FileSystem fs2 = AppendTestUtil.createHdfsWithDifferentUsername(fs1.getConf());

    // Allow us to delay commitBlockSynchronization
    DelayAnswer delayer = new DelayAnswer();
    NameNode nn = cluster.getNameNode();
    nn.namesystem = spy(nn.namesystem);
    doAnswer(delayer).
      when(nn.namesystem).
      commitBlockSynchronization((Block) anyObject(), anyInt(), anyInt(),
        anyBoolean(), anyBoolean(),
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.