@Test public void helixInitiatedIdealStateChangeTest() throws Exception { assumeTrue(!useComposite && !overrideEnabled); HelixClusterManager helixClusterManager = (HelixClusterManager) clusterManager; verifyInitialClusterChanges(helixClusterManager, helixCluster, helixDcs); String resourceName = "newResource"; String partitionName = String.valueOf(helixCluster.getAllPartitions().size()); IdealState idealState = new IdealState(resourceName); idealState.setPreferenceList(partitionName, new ArrayList<>()); helixCluster.addNewResource(resourceName, idealState, localDc); verifyInitialClusterChanges(helixClusterManager, helixCluster, new String[]{localDc}); Map<String, Map<String, String>> partitionToResource = (helixClusterManager).getPartitionToResourceMap(); assertEquals("localDc should have one more partition", partitionToResource.get(localDc).size(), partitionToResource.get(remoteDc).size() + 1); assertTrue(partitionToResource.get(localDc).containsKey(partitionName) && !partitionToResource.get(remoteDc) .containsKey(partitionName)); }
Map<String, Map<String, String>> getPartitionToResourceMap() { Map<String, Map<String, String>> partitionToResourceNameByDc = new HashMap<>(); for (DcInfo dcInfo : dcToDcInfo.values()) { partitionToResourceNameByDc.put(dcInfo.dcName, dcInfo.clusterChangeHandler.getPartitionToResourceMap()); } return partitionToResourceNameByDc; }
HelixClusterManager implements ClusterMap { Map<String, Map<String, String>> getPartitionToResourceMap() { Map<String, Map<String, String>> partitionToResourceNameByDc = new HashMap<>(); for (DcInfo dcInfo : dcToDcInfo.values()) { partitionToResourceNameByDc.put(dcInfo.dcName, dcInfo.clusterChangeHandler.getPartitionToResourceMap()); } return partitionToResourceNameByDc; } }
HelixClusterManager implements ClusterMap { Map<String, Map<String, String>> getPartitionToResourceMap() { Map<String, Map<String, String>> partitionToResourceNameByDc = new HashMap<>(); for (DcInfo dcInfo : dcToDcInfo.values()) { partitionToResourceNameByDc.put(dcInfo.dcName, dcInfo.clusterChangeHandler.getPartitionToResourceMap()); } return partitionToResourceNameByDc; } HelixClusterManager(ClusterMapConfig clusterMapConfig, String instanceName, HelixFactory helixFactory,
      MetricRegistry metricRegistry); }
HelixClusterManager implements ClusterMap { Map<String, Map<String, String>> getPartitionToResourceMap() { Map<String, Map<String, String>> partitionToResourceNameByDc = new HashMap<>(); for (DcInfo dcInfo : dcToDcInfo.values()) { partitionToResourceNameByDc.put(dcInfo.dcName, dcInfo.clusterChangeHandler.getPartitionToResourceMap()); } return partitionToResourceNameByDc; } 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 { Map<String, Map<String, String>> getPartitionToResourceMap() { Map<String, Map<String, String>> partitionToResourceNameByDc = new HashMap<>(); for (DcInfo dcInfo : dcToDcInfo.values()) { partitionToResourceNameByDc.put(dcInfo.dcName, dcInfo.clusterChangeHandler.getPartitionToResourceMap()); } return partitionToResourceNameByDc; } 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();  }