List of usage examples for org.apache.hadoop.hdfs DFSConfigKeys DFS_HEARTBEAT_INTERVAL_DEFAULT
long DFS_HEARTBEAT_INTERVAL_DEFAULT
To view the source code for org.apache.hadoop.hdfs DFSConfigKeys DFS_HEARTBEAT_INTERVAL_DEFAULT.
Click Source Link
From source file:mzb.Balancer.java
License:Apache License
/** * Balance all namenodes./* w w w . ja v a2 s. co m*/ * For each iteration, * for each namenode, * execute a {@link Balancer} to work through all datanodes once. */ static int run(Collection<URI> namenodes, Configuration conf) throws IOException, InterruptedException { final long sleeptime = 2000 * conf.getLong(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_DEFAULT); LOG.info("namenodes = " + namenodes); // LOG.info("p = " + p); final Formatter formatter = new Formatter(System.out); System.out.println( "Time Stamp Iteration# Bytes Already Moved Bytes Left To Move Bytes Being Moved"); final List<NameNodeConnector> connectors = new ArrayList<NameNodeConnector>(namenodes.size()); try { for (URI uri : namenodes) { connectors.add(new NameNodeConnector(uri, conf)); } boolean done = false; for (int iteration = 0; !done; iteration++) { done = true; Collections.shuffle(connectors); for (NameNodeConnector nnc : connectors) { final Balancer b = new Balancer(nnc, conf); final ReturnStatus r = b.run(iteration, formatter, conf); // clean all lists b.resetData(conf); if (r == ReturnStatus.IN_PROGRESS) { done = false; } else if (r != ReturnStatus.SUCCESS) { //must be an error statue, return. return r.code; } } if (!done) { Thread.sleep(sleeptime); } } } finally { for (NameNodeConnector nnc : connectors) { nnc.close(); } } return ReturnStatus.SUCCESS.code; }