|| actionRequest.getClusterName().isEmpty()
|| actionRequest.getServiceName() == null
|| actionRequest.getServiceName().isEmpty()
|| actionRequest.getActionName() == null
|| actionRequest.getActionName().isEmpty()) {
throw new AmbariException("Invalid action request : " + "cluster="
+ actionRequest.getClusterName() + ", service="
+ actionRequest.getServiceName() + ", action="
+ actionRequest.getActionName());
} else if (clusterName == null) {
clusterName = actionRequest.getClusterName();
} else if (!clusterName.equals(actionRequest.getClusterName())) {
throw new AmbariException("Requests for different clusters found");
}
}
Stage stage = stageFactory.createNew(actionManager.getNextRequestId(),
logDir, clusterName, requestContext);
stage.setStageId(0);
for (ActionRequest actionRequest : request) {
LOG.info("Received a createAction request"
+ ", clusterName=" + actionRequest.getClusterName()
+ ", serviceName=" + actionRequest.getServiceName()
+ ", request=" + actionRequest.toString());
if (actionRequest.getActionName().contains("SERVICE_CHECK")) {
addServiceCheckAction(actionRequest, stage);
} else if (actionRequest.getActionName().equals("DECOMMISSION_DATANODE")) {
addDecommissionDatanodeAction(actionRequest, stage);
} else {
throw new AmbariException("Unsupported action");
}
}
RoleGraph rg = new RoleGraph(rco);
rg.build(stage);
List<Stage> stages = rg.getStages();
if (stages != null && !stages.isEmpty()) {
actionManager.sendActions(stages);
return getRequestStatusResponse(stage.getRequestId());
} else {
throw new AmbariException("Stage was not created");
}
}