clusterName, clusterReport, reports,
ProgressSplit.OPERATION_FINISHED.getProgress());
poller.waitForComplete();
boolean success = false;
ApiRequest apiRequest =
apiManager.getRequestWithTasks(clusterName, apiRequestSummary
.getApiRequestInfo().getRequestId());
ClusterRequestStatus clusterRequestStatus =
ClusterRequestStatus.valueOf(apiRequest.getApiRequestInfo()
.getRequestStatus());
if (!clusterRequestStatus.isFailedState()) {
success = true;
} else {
logger.error("Failed to do request: " + ApiUtils.objectToJson(apiRequest.getApiRequestInfo()));
List<ApiTask> apiTasks = apiRequest.getApiTasks();
Map<String, NodeReport> nodeReports = clusterReport.getNodeReports();
HashMap<String, List<String>> errMsg = new HashMap<>();
for (ApiTask apiTask : apiTasks) {
ApiTaskInfo taskInfo = apiTask.getApiTaskInfo();
if (TaskStatus.valueOf(taskInfo.getStatus()).isFailedState()) {
if (!errMsg.containsKey(taskInfo.getHostName())) {
List<String> errs = new ArrayList<>();
errMsg.put(taskInfo.getHostName(), errs);
}
String taskErrMsg = taskInfo.getCommandDetail() + " " + taskInfo.getStatus();
errMsg.get(taskInfo.getHostName()).add(taskErrMsg);
logger.error("command: " + taskInfo.getCommandDetail() +
"role: " + taskInfo.getRole() +
"stderr: " + taskInfo.getStderr() +
"status: " + taskInfo.getStatus());
}
}
for (NodeReport nodeReport: nodeReports.values()) {
if (errMsg.containsKey(nodeReport.getHostname())) {
nodeReport.setErrMsg(errMsg.get(nodeReport.getHostname()).toString());
}
}
String requestErrorMsg = "Failed to execute request: " +
apiRequest.getApiRequestInfo().getRequestStatus() + ". Refer to each node for details.";
clusterReport.setErrMsg(requestErrorMsg);
reportStatus(clusterReport.clone(), reports);
throw new RuntimeException(requestErrorMsg);
}
return success;