|
@@ -35,6 +35,7 @@ import org.junit.Rule;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.rules.ExpectedException;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.net.URI;
|
|
|
|
|
|
public class TestDiskBalancerRPC {
|
|
@@ -43,6 +44,7 @@ public class TestDiskBalancerRPC {
|
|
|
|
|
|
private MiniDFSCluster cluster;
|
|
|
private Configuration conf;
|
|
|
+
|
|
|
@Before
|
|
|
public void setUp() throws Exception {
|
|
|
conf = new HdfsConfiguration();
|
|
@@ -113,11 +115,51 @@ public class TestDiskBalancerRPC {
|
|
|
|
|
|
// Since submitDiskBalancerPlan is not implemented yet, it throws an
|
|
|
// Exception, this will be modified with the actual implementation.
|
|
|
- thrown.expect(DiskbalancerException.class);
|
|
|
- dataNode.submitDiskBalancerPlan(planHash, planVersion, 10, plan.toJson());
|
|
|
-
|
|
|
+ try {
|
|
|
+ dataNode.submitDiskBalancerPlan(planHash, planVersion, 10, plan.toJson());
|
|
|
+ } catch (DiskbalancerException ex) {
|
|
|
+ // Let us ignore this for time being.
|
|
|
+ }
|
|
|
thrown.expect(DiskbalancerException.class);
|
|
|
dataNode.cancelDiskBalancePlan(planHash);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void TestQueryTestRpc() throws Exception {
|
|
|
+ final int dnIndex = 0;
|
|
|
+ cluster.restartDataNode(dnIndex);
|
|
|
+ cluster.waitActive();
|
|
|
+ ClusterConnector nameNodeConnector =
|
|
|
+ ConnectorFactory.getCluster(cluster.getFileSystem(0).getUri(), conf);
|
|
|
+
|
|
|
+ DiskBalancerCluster diskBalancerCluster = new DiskBalancerCluster
|
|
|
+ (nameNodeConnector);
|
|
|
+ diskBalancerCluster.readClusterInfo();
|
|
|
+ Assert.assertEquals(cluster.getDataNodes().size(),
|
|
|
+ diskBalancerCluster.getNodes().size());
|
|
|
+ diskBalancerCluster.setNodesToProcess(diskBalancerCluster.getNodes());
|
|
|
+ DiskBalancerDataNode node = diskBalancerCluster.getNodes().get(0);
|
|
|
+ GreedyPlanner planner = new GreedyPlanner(10.0f, node);
|
|
|
+ NodePlan plan = new NodePlan(node.getDataNodeName(), node.getDataNodePort
|
|
|
+ ());
|
|
|
+ planner.balanceVolumeSet(node, node.getVolumeSets().get("DISK"), plan);
|
|
|
+
|
|
|
+ final int planVersion = 0; // So far we support only one version.
|
|
|
+ DataNode dataNode = cluster.getDataNodes().get(dnIndex);
|
|
|
+ String planHash = DigestUtils.sha512Hex(plan.toJson());
|
|
|
+
|
|
|
+ // Since submitDiskBalancerPlan is not implemented yet, it throws an
|
|
|
+ // Exception, this will be modified with the actual implementation.
|
|
|
+ try {
|
|
|
+ dataNode.submitDiskBalancerPlan(planHash, planVersion, 10, plan.toJson());
|
|
|
+ } catch (DiskbalancerException ex) {
|
|
|
+ // Let us ignore this for time being.
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO : This will be fixed when we have implementation for this
|
|
|
+ // function in server side.
|
|
|
+ thrown.expect(DiskbalancerException.class);
|
|
|
+ dataNode.queryDiskBalancerPlan();
|
|
|
+ }
|
|
|
}
|