/** Construct a balancer from the given configuration and threshold */ Balancer(Configuration conf, double threshold) { setConf(conf); this.threshold = threshold; }
/** Construct a balancer from the given configuration */ Balancer(Configuration conf) { setConf(conf); }
/** Construct a balancer from the given configuration */ Balancer(Configuration conf) throws UnsupportedActionException { setConf(conf); checkReplicationPolicyCompatibility(conf); }
/** Construct a balancer from the given configuration and threshold */ Balancer(Configuration conf, double threshold) throws UnsupportedActionException { setConf(conf); checkReplicationPolicyCompatibility(conf); Balancer.threshold = threshold; }
private void runBalancerDefaultConstructor(Configuration conf, long totalUsedSpace, long totalCapacity) throws Exception { waitForHeartBeat(totalUsedSpace, totalCapacity); // start rebalancing balancer = new Balancer(); balancer.setConf(conf); balancer.run(new String[0]); waitForHeartBeat(totalUsedSpace, totalCapacity); boolean balanced; do { DatanodeInfo[] datanodeReport = client .getDatanodeReport(DatanodeReportType.ALL); assertEquals(datanodeReport.length, cluster.getDataNodes().size()); balanced = true; double avgUtilization = ((double) totalUsedSpace) / totalCapacity * 100; for (DatanodeInfo datanode : datanodeReport) { if (Math.abs(avgUtilization - ((double) datanode.getDfsUsed()) / datanode.getCapacity() * 100) > 10) { balanced = false; try { Thread.sleep(100); } catch (InterruptedException ignored) { } break; } } } while (!balanced); }