@Override
public boolean startCluster(ClusterBlueprint clusterBlueprint, ClusterReportQueue reportQueue) throws SoftwareManagementPluginException {
assert(clusterBlueprint != null && clusterBlueprint.getName() != null && !clusterBlueprint.getName().isEmpty());
String clusterName = clusterBlueprint.getName();
CmClusterDef clusterDef = null;
ClusterReport report = null;
boolean succeed = false;
try {
if (!isProvisioned(clusterName)) {
return true;
}
clusterDef = new CmClusterDef(clusterBlueprint);
report = clusterDef.getCurrentReport();
if (isExistingServiceStarted(clusterName)) {
succeed = true;
return true;
}
ReflectionUtils.getPreStartServicesHook().preStartServices(clusterDef.getName(), 120);
executeAndReport("Starting Services",
apiResourceRootV6.getClustersResource().startCommand(clusterName),
ProgressSplit.START_SERVICES.getProgress(),
report,
reportQueue,
true);
succeed = true;
return true;
} catch (Exception e) {
report.setClusterAndNodesServiceStatus(ServiceStatus.STARTUP_FAILED);
logger.error("Got an exception when cloudera manager starting cluster", e);
HashMap<String, Set<String>> unstartedRoles = getFailedRoles(clusterName, ApiRoleState.STARTED);
setRolesErrorMsg(report, unstartedRoles, "starting");
throw SoftwareManagementPluginException.START_CLUSTER_FAILED(e, Constants.CDH_PLUGIN_NAME, clusterDef.getName());
} finally {
if (clusterDef != null) {
report.setFinished(true);
if (succeed) {
report.setProgress(ProgressSplit.START_SERVICES.getProgress());
report.setClusterAndNodesServiceStatus(ServiceStatus.STARTED);
logger.info("Cloudera Manager started all services successfully.");
}
report.setClusterAndNodesAction("");//clean action field
report.setFinished(true);
report.setSuccess(succeed);
reportQueue.addClusterReport(report.clone());
}
}
}