Source:
public void testAutoRebalance() throws Exception { _participants[0].syncStop(); ZkHelixClusterVerifier verifierTestDb = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME) .setResources(new HashSet<>(Collections.singleton(TEST_DB))) .setZkClient(_gZkClient) .setWaitTillVerify(TestHelper.DEFAULT_REBALANCE_PROCESSING_WAIT_TIME) .build(); Assert.assertTrue(verifierTestDb.verifyByPolling()); ZkHelixClusterVerifier verifierDb2 = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME) .setResources(new HashSet<>(Collections.singleton(db2))) .setZkClient(_gZkClient) .setWaitTillVerify(TestHelper.DEFAULT_REBALANCE_PROCESSING_WAIT_TIME) .build(); Assert.assertTrue(verifierDb2.verifyByPolling()); for (int i = 0; i < 2; i++) { String storageNodeName = PARTICIPANT_PREFIX + "_" + (1000 + i); _gSetupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName); MockParticipantManager participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, storageNodeName.replace(':', '_')); _extraParticipants.add(participant); participant.syncStart(); } Assert.assertTrue(verifierTestDb.verifyByPolling()); Assert.assertTrue(verifierDb2.verifyByPolling()); HelixDataAccessor accessor = new ZKHelixDataAccessor(CLUSTER_NAME, new ZkBaseDataAccessor<>(_gZkClient)); Builder keyBuilder = accessor.keyBuilder(); ExternalView ev = accessor.getProperty(keyBuilder.externalView(db2)); Set<String> instancesSet = new HashSet<>(); for (String partitionName : ev.getRecord().getMapFields().keySet()) { Map<String, String> assignmentMap = ev.getRecord().getMapField(partitionName); instancesSet.addAll(assignmentMap.keySet()); } Assert.assertEquals(instancesSet.size(), 2); }

Target:
public void testAutoRebalance() throws Exception { _participants[0].syncStop(); ZkHelixClusterVerifier verifierClusterTestDb = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME) .setResources(new HashSet<>(Collections.singleton(TEST_DB))) .setZkClient(_gZkClient) .setWaitTillVerify(TestHelper.DEFAULT_REBALANCE_PROCESSING_WAIT_TIME) .build(); Assert.assertTrue(verifierClusterTestDb.verifyByPolling()); ZkHelixClusterVerifier verifierClusterDb2 = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME) .setResources(new HashSet<>(Collections.singleton(db2))) .setZkClient(_gZkClient) .setWaitTillVerify(TestHelper.DEFAULT_REBALANCE_PROCESSING_WAIT_TIME) .build(); Assert.assertTrue(verifierClusterDb2.verifyByPolling()); for (int i = 0; i < 2; i++) { String storageNodeName = PARTICIPANT_PREFIX + "_" + (1000 + i); _gSetupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName); MockParticipantManager participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, storageNodeName.replace(':', '_')); _extraParticipants.add(participant); participant.syncStart(); } Assert.assertTrue(verifierClusterTestDb.verifyByPolling()); Assert.assertTrue(verifierClusterDb2.verifyByPolling()); HelixDataAccessor accessor = new ZKHelixDataAccessor(CLUSTER_NAME, new ZkBaseDataAccessor<>(_gZkClient)); Builder keyBuilder = accessor.keyBuilder(); ExternalView ev = accessor.getProperty(keyBuilder.externalView(db2)); Set<String> instancesSet = new HashSet<>(); for (String partitionName : ev.getRecord().getMapFields().keySet()) { Map<String, String> assignmentMap = ev.getRecord().getMapField(partitionName); instancesSet.addAll(assignmentMap.keySet()); } Assert.assertEquals(instancesSet.size(), 2); }