int nodesNb,
int replica,
String stateModelDef,
boolean doRebalance) throws Exception
{
ZkClient zkClient = new ZkClient(ZkAddr);
if (zkClient.exists("/" + clusterName))
{
LOG.warn("Cluster already exists:" + clusterName + ". Deleting it");
zkClient.deleteRecursive("/" + clusterName);
}
ClusterSetup setupTool = new ClusterSetup(ZkAddr);
setupTool.addCluster(clusterName, true);
setupTool.addStateModelDef(clusterName,
"Bootstrap",
TestHelper.generateStateModelDefForBootstrap());
for (int i = 0; i < nodesNb; i++)
{
int port = startPort + i;
setupTool.addInstanceToCluster(clusterName, participantNamePrefix + ":" + port);
}
for (int i = 0; i < resourceNb; i++)
{
String dbName = resourceNamePrefix + i;
setupTool.addResourceToCluster(clusterName, dbName, partitionNb, stateModelDef);
if (doRebalance)
{
setupTool.rebalanceStorageCluster(clusterName, dbName, replica);
}
}
zkClient.close();
}