protected void setupLiveInstances(int numLiveInstances) { // setup liveInstances for (int i = 0; i < numLiveInstances; i++) { LiveInstance liveInstance = new LiveInstance("localhost_" + i); liveInstance.setSessionId("session_" + i); Builder keyBuilder = accessor.keyBuilder(); accessor.setProperty(keyBuilder.liveInstance("localhost_" + i), liveInstance); } }
private void prepare( String controllerVersion, String participantVersion, String minSupportedParticipantVersion) { List<String> instances = Arrays.asList("localhost_0", "localhost_1", "localhost_2", "localhost_3", "localhost_4"); int partitions = 10; int replicas = 1; // set ideal state String resourceName = "testResource"; ZNRecord record = DefaultTwoStateStrategy.calculateIdealState( instances, partitions, replicas, resourceName, "MASTER", "SLAVE"); IdealState idealState = new IdealState(record); idealState.setStateModelDefId(StateModelDefinitionId.from("MasterSlave")); PropertyKeyBuilder keyBuilder = accessor.keyBuilder(); accessor.setProperty(keyBuilder.idealStates(resourceName), idealState); // set live instances record = new ZNRecord("localhost_0"); if (participantVersion != null) { record.setSimpleField(LiveInstanceProperty.HELIX_VERSION.toString(), participantVersion); } LiveInstance liveInstance = new LiveInstance(record); liveInstance.setSessionId("session_0"); accessor.setProperty(keyBuilder.liveInstance("localhost_0"), liveInstance); InstanceConfig config = new InstanceConfig(liveInstance.getInstanceName()); accessor.setProperty(keyBuilder.instanceConfig(config.getInstanceName()), config); if (controllerVersion != null) { ((Mocks.MockManager) manager).setVersion(controllerVersion); } if (minSupportedParticipantVersion != null) { manager .getProperties() .getProperties() .put("minimum_supported_version.participant", minSupportedParticipantVersion); } event.addAttribute("helixmanager", manager); runStage(event, new ReadClusterDataStage()); }