"MasterSlave", true); // do rebalance
// set cluster config
HelixConfigScope scope =
new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(clusterName).build();
ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
// String pidFile = ScriptTestHelper.getPrefix() + ScriptTestHelper.INTEGRATION_LOG_DIR +
// "/default/foo_{PARTITION_NAME}_pid.txt";
// the pid file path for the first partition
// delete it if exists
// String pidFileFirstPartition = ScriptTestHelper.getPrefix() +
// ScriptTestHelper.INTEGRATION_LOG_DIR + "/default/foo_TestDB0_0_pid.txt";
// File file = new File(pidFileFirstPartition);
// if (file.exists()) {
// file.delete();
// }
// set commands for state-transitions
CommandConfig.Builder builder = new CommandConfig.Builder();
CommandConfig cmdConfig =
builder.setTransition("SLAVE", "MASTER").setCommand("simpleHttpClient.py SLAVE-MASTER")
.setCommandWorkingDir(workingDir).setCommandTimeout("0")
// .setPidFile(pidFile)
.build();
configAccessor.set(scope, cmdConfig.toKeyValueMap());
builder = new CommandConfig.Builder();
cmdConfig =
builder.setTransition("OFFLINE", "SLAVE").setCommand("simpleHttpClient.py OFFLINE-SLAVE")
.setCommandWorkingDir(workingDir).build();
configAccessor.set(scope, cmdConfig.toKeyValueMap());
builder = new CommandConfig.Builder();
cmdConfig =
builder.setTransition("MASTER", "SLAVE").setCommand("simpleHttpClient.py MASTER-SLAVE")
.setCommandWorkingDir(workingDir).build();
configAccessor.set(scope, cmdConfig.toKeyValueMap());
builder = new CommandConfig.Builder();
cmdConfig =
builder.setTransition("SLAVE", "OFFLINE").setCommand("simpleHttpClient.py SLAVE-OFFLINE")
.setCommandWorkingDir(workingDir).build();
configAccessor.set(scope, cmdConfig.toKeyValueMap());
builder = new CommandConfig.Builder();
cmdConfig =
builder.setTransition("OFFLINE", "DROPPED").setCommand(CommandAttribute.NOP.getName())
.build();
configAccessor.set(scope, cmdConfig.toKeyValueMap());
// start controller
ClusterControllerManager controller = new ClusterControllerManager(zkAddr, clusterName, "controller_0");
controller.syncStart();