}
}
public RuntimeStatusList startCluster(String clusterName)
throws InstanceException
{
RuntimeStatusList beforeStatus = getRuntimeStatus(clusterName);
String[] servers = null;
try {
servers = getServersInCluster(clusterName);
} catch (ConfigException ce) {
throw new InstanceException(_strMgr.getString("configException", clusterName));
}
List<String> members = Arrays.asList(servers);
if (beforeStatus.isEmpty()) {
//no instances
throw new InstanceException(_strMgr.getString("clusterIsEmpty",
clusterName));
} else if (beforeStatus.allRunning()) {
//already started
for (Object rso : beforeStatus)
{
RuntimeStatus rs = (RuntimeStatus)rso;
rs.resetRecentErrorMessages();
}
return beforeStatus;
} else {
ArrayList msgsList = new ArrayList();
RuntimeStatusList afterStatus = null;
try {
announceClusterStartState(clusterName, INITIATED, members);
doStartCluster(clusterName, servers, msgsList);
afterStatus = getRuntimeStatus(clusterName);
} finally {
if (afterStatus != null && afterStatus.allRunning()) {
announceClusterStartState(clusterName, COMPLETED_SUCCESS, members);
for (int i = 0; i < afterStatus.size(); i++) {
// this will get us a special error message from RuntimeStatus.toString()
afterStatus.getStatus(i).setStartClusterFlag(beforeStatus.getStatus(i));
}
} else {
announceClusterStartState(clusterName, COMPLETED_FAILED, getFailedMembers(afterStatus));
boolean bAny = afterStatus != null ? afterStatus.anyRunning() : false;
String msg = _strMgr.getString(bAny ? "clusterNotFullyStarted" : "clusterNotStarted", clusterName);
for (int i = 0; i < msgsList.size(); i++) {
msg = msg + "\n" + msgsList.get(i);
}
if (bAny) {