// add ideal-state according to ideal-state-mode
String resourceName = "TestDB";
IdealState idealState = null;
switch (idealStateMode) {
case SEMI_AUTO: {
AutoModeISBuilder builder = new AutoModeISBuilder(resourceName);
builder.setStateModel("MasterSlave").setNumPartitions(2).setNumReplica(2);
builder.assignPreferenceList(buildPartitionName(resourceName, 0), "localhost_12918",
"localhost_12919").assignPreferenceList(buildPartitionName(resourceName, 1),
"localhost_12919", "localhost_12918");
idealState = builder.build();
break;
}
case FULL_AUTO: {
AutoRebalanceModeISBuilder builder = new AutoRebalanceModeISBuilder(resourceName);
builder.setStateModel("MasterSlave").setNumPartitions(2).setNumReplica(2)
.setMaxPartitionsPerNode(2);
builder.add(buildPartitionName(resourceName, 0)).add(buildPartitionName(resourceName, 1));
idealState = builder.build();
break;
}
case CUSTOMIZED: {
CustomModeISBuilder builder = new CustomModeISBuilder(resourceName);
builder.setStateModel("MasterSlave").setNumPartitions(2).setNumReplica(2);
builder
.assignInstanceAndState(buildPartitionName(resourceName, 0), "localhost_12918", "MASTER")
.assignInstanceAndState(buildPartitionName(resourceName, 0), "localhost_12919", "SLAVE")
.assignInstanceAndState(buildPartitionName(resourceName, 1), "localhost_12918", "SLAVE")
.assignInstanceAndState(buildPartitionName(resourceName, 1), "localhost_12919", "MASTER");
idealState = builder.build();
break;
}
default:
break;
}