コード例 #1
0
ファイル: HardwareLayout.java プロジェクト: XUZHOUWANG/ambry
 private long calculateRawCapacityInBytes() {
   long capacityInBytes = 0;
   for (Datacenter datacenter : datacenters) {
     capacityInBytes += datacenter.getRawCapacityInBytes();
   }
   return capacityInBytes;
 }
コード例 #2
0
ファイル: DatacenterTest.java プロジェクト: XUZHOUWANG/ambry
  @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));
  }