private long calculateRawCapacityInBytes() { long capacityInBytes = 0; for (Datacenter datacenter : datacenters) { capacityInBytes += datacenter.getRawCapacityInBytes(); } return capacityInBytes; }
@Test public void basics() throws JSONException { JSONObject jsonObject = TestUtils.getJsonDatacenter("XYZ1", getDataNodes()); ClusterMapConfig clusterMapConfig = new ClusterMapConfig(new VerifiableProperties(new Properties())); Datacenter datacenter = new TestDatacenter(jsonObject, clusterMapConfig); assertEquals(datacenter.getName(), "XYZ1"); assertEquals(datacenter.getDataNodes().size(), dataNodeCount); assertEquals( datacenter.getRawCapacityInBytes(), dataNodeCount * diskCount * diskCapacityInBytes); assertFalse(datacenter.isRackAware()); assertEquals(datacenter.toJSONObject().toString(), jsonObject.toString()); assertEquals(datacenter, new TestDatacenter(datacenter.toJSONObject(), clusterMapConfig)); jsonObject = TestUtils.getJsonDatacenter("XYZ1", getDataNodesRackAware()); datacenter = new TestDatacenter(jsonObject, clusterMapConfig); assertTrue(datacenter.isRackAware()); assertEquals(datacenter.toJSONObject().toString(), jsonObject.toString()); assertEquals(datacenter, new TestDatacenter(datacenter.toJSONObject(), clusterMapConfig)); }