org.apache.hadoop.hdfs.server.datanode.DataNode.isDatanodeUp()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中org.apache.hadoop.hdfs.server.datanode.DataNode.isDatanodeUp()方法的一些代码示例,展示了DataNode.isDatanodeUp()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataNode.isDatanodeUp()方法的具体详情如下:
包路径:org.apache.hadoop.hdfs.server.datanode.DataNode
类名称:DataNode
方法名:isDatanodeUp

DataNode.isDatanodeUp介绍

[英]A data node is considered to be up if one of the bp services is up
[中]如果某个bp服务启动,则认为数据节点已启动

代码示例

代码示例来源:origin: com.facebook.hadoop/hadoop-core

public static boolean isDatanodeUp(DataNode dn) {
 return dn.isDatanodeUp();
}

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs-test

private void waitForDatanodeDeath(DataNode dn) 
  throws InterruptedException, TimeoutException {
 final int ATTEMPTS = 10;
 int count = 0;
 do {
  Thread.sleep(1000);
  count++;
 } while (DataNode.isDatanodeUp(dn) && count < ATTEMPTS);
 if (count == ATTEMPTS) {
  throw new TimeoutException("Timed out waiting for DN to die");
 }
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

public Boolean isAlive() {
 return isDatanodeUp() && isDataNodeBeingAlive();
}

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

/**
 * Returns true if there is at least one DataNode running.
 */
public boolean isDataNodeUp() {
 if (dataNodes == null || dataNodes.size() == 0) {
  return false;
 }
 for (DataNodeProperties dn : dataNodes) {
  if (dn.datanode.isDatanodeUp()) {
   return true;
  }
 }
 return false;
}

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

public static void waitForDatanodeDeath(DataNode dn) 
  throws InterruptedException, TimeoutException {
 final int ATTEMPTS = 10;
 int count = 0;
 do {
  Thread.sleep(1000);
  count++;
 } while (dn.isDatanodeUp() && count < ATTEMPTS);
 if (count == ATTEMPTS) {
  throw new TimeoutException("Timed out waiting for DN to die");
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs-test

for (int i=0; DataNode.isDatanodeUp(dn); i++) {
 Path fileName = new Path("/test.txt"+i);
 DFSTestUtil.createFile(fs, fileName, 1024, (short)2, 1L);

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

/**
 * Test BPService Thread Exit
 */
@Test
public void testBPServiceExit() throws Exception {
 DataNode dn = cluster.getDataNodes().get(0);
 stopBPServiceThreads(1, dn);
 assertTrue("DataNode should not exit", dn.isDatanodeUp());
 stopBPServiceThreads(2, dn);
 assertFalse("DataNode should exit", dn.isDatanodeUp());
}

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs-test

DFSTestUtil.waitReplication(fs, file1, (short)3);
ArrayList<DataNode> dns = cluster.getDataNodes();
assertTrue("DN1 should be up", DataNode.isDatanodeUp(dns.get(0)));
assertTrue("DN2 should be up", DataNode.isDatanodeUp(dns.get(1)));
assertTrue("DN3 should be up", DataNode.isDatanodeUp(dns.get(2)));
DFSTestUtil.waitReplication(fs, file2, (short)3);
assertTrue("DN3 should still be up", DataNode.isDatanodeUp(dns.get(2)));
assertEquals("Vol3 should report 1 failure",
  1, metrics3.volumeFailures.getCurrentIntervalValue());

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

assertTrue("DN1 should be up", dns.get(0).isDatanodeUp());
assertTrue("DN2 should be up", dns.get(1).isDatanodeUp());
assertTrue("DN3 should be up", dns.get(2).isDatanodeUp());

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

assertTrue("DN1 should be up", dns.get(0).isDatanodeUp());
assertTrue("DN2 should be up", dns.get(1).isDatanodeUp());
assertTrue("DN3 should be up", dns.get(2).isDatanodeUp());

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

DFSTestUtil.waitReplication(fs, file1, (short)3);
ArrayList<DataNode> dns = cluster.getDataNodes();
assertTrue("DN1 should be up", dns.get(0).isDatanodeUp());
assertTrue("DN2 should be up", dns.get(1).isDatanodeUp());
assertTrue("DN3 should be up", dns.get(2).isDatanodeUp());
DFSTestUtil.createFile(fs, file2, 1024, (short)3, 1L);
DFSTestUtil.waitReplication(fs, file2, (short)3);
assertTrue("DN3 should still be up", dns.get(2).isDatanodeUp());
checkFailuresAtDataNode(dns.get(2), 1, true, dn3Vol1.getAbsolutePath());

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

for (int i=0; dn.isDatanodeUp(); i++) {
 Path fileName = new Path("/test.txt"+i);
 DFSTestUtil.createFile(fs, fileName, 1024, (short)2, 1L);

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

} else {
 cluster.startDataNodes(conf, 1, false, StartupOption.REGULAR, null);
 assertFalse(cluster.getDataNodes().get(0).isDatanodeUp());

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

assertTrue("Datanode should be running", dn.isDatanodeUp());
 assertEquals("BPOfferService should be running", 1,
   dn.getAllBpOs().length);
 dn = cluster.getDataNodes().get(0);
 assertFalse("Datanode should have shutdown as only service failed",
   dn.isDatanodeUp());
} finally {
 cluster.shutdown();

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

@Test
public void testDFSAdminDatanodeUpgradeControlCommands() throws Exception {
 // start a cluster
 final Configuration conf = new HdfsConfiguration();
 MiniDFSCluster cluster = null;
 try {
  cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
  cluster.waitActive();
  final DFSAdmin dfsadmin = new DFSAdmin(conf);
  DataNode dn = cluster.getDataNodes().get(0);
  // check the datanode
  final String dnAddr = dn.getDatanodeId().getIpcAddr(false);
  final String[] args1 = {"-getDatanodeInfo", dnAddr};
  runCmd(dfsadmin, true, args1);
  // issue shutdown to the datanode.
  final String[] args2 = {"-shutdownDatanode", dnAddr, "upgrade" };
  runCmd(dfsadmin, true, args2);
  // the datanode should be down.
  GenericTestUtils.waitForThreadTermination(
    "Async datanode shutdown thread", 100, 10000);
  Assert.assertFalse("DataNode should exit", dn.isDatanodeUp());
  // ping should fail.
  assertEquals(-1, dfsadmin.run(args1));
 } finally {
  if (cluster != null) cluster.shutdown();
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

@Test(timeout = 20000)
public void testClusterIdMismatchAtStartupWithHA() throws Exception {
 MiniDFSNNTopology top = new MiniDFSNNTopology()
  .addNameservice(new MiniDFSNNTopology.NSConf("ns1")
   .addNN(new MiniDFSNNTopology.NNConf("nn0"))
   .addNN(new MiniDFSNNTopology.NNConf("nn1")))
  .addNameservice(new MiniDFSNNTopology.NSConf("ns2")
   .addNN(new MiniDFSNNTopology.NNConf("nn2").setClusterId("bad-cid"))
   .addNN(new MiniDFSNNTopology.NNConf("nn3").setClusterId("bad-cid")));
 top.setFederation(true);
 MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).nnTopology(top)
   .numDataNodes(0).build();
 
 try {
  cluster.startDataNodes(conf, 1, true, null, null);
  // let the initialization be complete
  Thread.sleep(10000);
  DataNode dn = cluster.getDataNodes().get(0);
  assertTrue("Datanode should be running", dn.isDatanodeUp());
  assertEquals("Only one BPOfferService should be running", 1,
    dn.getAllBpOs().length);
 } finally {
  cluster.shutdown();
 }
}

相关文章

DataNode类方法