@Test public void inconsistentReplicaCapacityTest() throws Exception { assumeTrue(listenCrossColo); clusterManager.close(); metricRegistry = new MetricRegistry(); String staticClusterName = "TestOnly"; File tempDir = Files.createTempDirectory("helixClusterManagerTest").toFile(); tempDir.deleteOnExit(); String tempDirPath = tempDir.getAbsolutePath(); String testHardwareLayoutPath = tempDirPath + File.separator + "hardwareLayoutTest.json"; String testPartitionLayoutPath = tempDirPath + File.separator + "partitionLayoutTest.json"; String testZkLayoutPath = tempDirPath + File.separator + "zkLayoutPath.json"; TestHardwareLayout testHardwareLayout1 = constructInitialHardwareLayoutJSON(staticClusterName); TestPartitionLayout testPartitionLayout1 = constructInitialPartitionLayoutJSON(testHardwareLayout1, 3, localDc); JSONObject zkJson = constructZkLayoutJSON(dcsToZkInfo.values()); Utils.writeJsonObjectToFile(zkJson, testZkLayoutPath); Utils.writeJsonObjectToFile(testHardwareLayout1.getHardwareLayout().toJSONObject(), testHardwareLayoutPath); Utils.writeJsonObjectToFile(testPartitionLayout1.getPartitionLayout().toJSONObject(), testPartitionLayoutPath); MockHelixCluster testCluster = new MockHelixCluster("AmbryTest-", testHardwareLayoutPath, testPartitionLayoutPath, testZkLayoutPath); List<DataNode> initialNodes = testHardwareLayout1.getAllExistingDataNodes(); Partition partitionToTest = (Partition) testPartitionLayout1.getPartitionLayout().getPartitions(null).get(0); testHardwareLayout1.addNewDataNodes(1); Utils.writeJsonObjectToFile(testHardwareLayout1.getHardwareLayout().toJSONObject(), testHardwareLayoutPath); DataNode newAddedNode = testHardwareLayout1.getAllExistingDataNodes().stream().filter(n -> !initialNodes.contains(n)).findAny().get(); Disk diskOnNewNode = newAddedNode.getDisks().get(0); partitionToTest.replicaCapacityInBytes += 1; partitionToTest.addReplica(new Replica(partitionToTest, diskOnNewNode, testHardwareLayout1.clusterMapConfig)); Utils.writeJsonObjectToFile(testPartitionLayout1.getPartitionLayout().toJSONObject(), testPartitionLayoutPath); testCluster.upgradeWithNewHardwareLayout(testHardwareLayoutPath); testCluster.upgradeWithNewPartitionLayout(testPartitionLayoutPath); testHardwareLayout1 = constructInitialHardwareLayoutJSON(staticClusterName); testPartitionLayout1 = constructInitialPartitionLayoutJSON(testHardwareLayout1, 3, localDc); Utils.writeJsonObjectToFile(testHardwareLayout1.getHardwareLayout().toJSONObject(), testHardwareLayoutPath); Utils.writeJsonObjectToFile(testPartitionLayout1.getPartitionLayout().toJSONObject(), testPartitionLayoutPath); testCluster.upgradeWithNewHardwareLayout(testHardwareLayoutPath); testCluster.upgradeWithNewPartitionLayout(testPartitionLayoutPath); Properties props = new Properties(); props.setProperty("clustermap.host.name", hostname); props.setProperty("clustermap.cluster.name", "AmbryTest-" + staticClusterName); props.setProperty("clustermap.datacenter.name", localDc); props.setProperty("clustermap.port", Integer.toString(portNum)); props.setProperty("clustermap.dcs.zk.connect.strings", zkJson.toString(2)); props.setProperty("clustermap.current.xid", Long.toString(CURRENT_XID)); ClusterMapConfig clusterMapConfig = new ClusterMapConfig(new VerifiableProperties(props)); try { new HelixClusterManager(clusterMapConfig, selfInstanceName, new MockHelixManagerFactory(testCluster, null, null), metricRegistry); fail("Initialization should fail due to inconsistent replica capacity"); } catch (IOException e) { } }
@Override public void close() { for (DcInfo dcInfo : dcToDcInfo.values()) { dcInfo.close(); } dcToDcInfo.clear(); }
HelixClusterManager implements ClusterMap { @Override public void close() { for (DcInfo dcInfo : dcToDcInfo.values()) { dcInfo.close(); } dcToDcInfo.clear(); } }
HelixClusterManager implements ClusterMap { @Override public void close() { for (DcInfo dcInfo : dcToDcInfo.values()) { dcInfo.close(); } dcToDcInfo.clear(); } HelixClusterManager(ClusterMapConfig clusterMapConfig, String instanceName, HelixFactory helixFactory,
      MetricRegistry metricRegistry); }
HelixClusterManager implements ClusterMap { @Override public void close() { for (DcInfo dcInfo : dcToDcInfo.values()) { dcInfo.close(); } dcToDcInfo.clear(); } HelixClusterManager(ClusterMapConfig clusterMapConfig, String instanceName, HelixFactory helixFactory,
      MetricRegistry metricRegistry); @Override boolean hasDatacenter(String datacenterName); @Override byte getLocalDatacenterId(); @Override String getDatacenterName(byte id); @Override AmbryDataNode getDataNodeId(String hostname, int port); @Override List<AmbryReplica> getReplicaIds(DataNodeId dataNodeId); @Override List<AmbryDataNode> getDataNodeIds(); @Override MetricRegistry getMetricRegistry(); @Override void onReplicaEvent(ReplicaId replicaId, ReplicaEventType event); @Override JSONObject getSnapshot(); @Override PartitionId getPartitionIdFromStream(InputStream stream); @Override List<PartitionId> getWritablePartitionIds(String partitionClass); @Override PartitionId getRandomWritablePartition(String partitionClass, List<PartitionId> partitionsToExclude); @Override List<PartitionId> getAllPartitionIds(String partitionClass); @Override ReplicaId getBootstrapReplica(String partitionIdStr, DataNodeId dataNodeId); @Override void registerClusterMapListener(ClusterMapChangeListener clusterMapChangeListener); @Override void close(); }
HelixClusterManager implements ClusterMap { @Override public void close() { for (DcInfo dcInfo : dcToDcInfo.values()) { dcInfo.close(); } dcToDcInfo.clear(); } HelixClusterManager(ClusterMapConfig clusterMapConfig, String instanceName, HelixFactory helixFactory,
      MetricRegistry metricRegistry); @Override boolean hasDatacenter(String datacenterName); @Override byte getLocalDatacenterId(); @Override String getDatacenterName(byte id); @Override AmbryDataNode getDataNodeId(String hostname, int port); @Override List<AmbryReplica> getReplicaIds(DataNodeId dataNodeId); @Override List<AmbryDataNode> getDataNodeIds(); @Override MetricRegistry getMetricRegistry(); @Override void onReplicaEvent(ReplicaId replicaId, ReplicaEventType event); @Override JSONObject getSnapshot(); @Override PartitionId getPartitionIdFromStream(InputStream stream); @Override List<PartitionId> getWritablePartitionIds(String partitionClass); @Override PartitionId getRandomWritablePartition(String partitionClass, List<PartitionId> partitionsToExclude); @Override List<PartitionId> getAllPartitionIds(String partitionClass); @Override ReplicaId getBootstrapReplica(String partitionIdStr, DataNodeId dataNodeId); @Override void registerClusterMapListener(ClusterMapChangeListener clusterMapChangeListener); @Override void close();  }