use of com.sequenceiq.cloudbreak.orchestrator.yarn.model.response.ApplicationErrorResponse in project cloudbreak by hortonworks.
the class ApplicationDetailHandler method getContainerInfo.
public ContainerInfo getContainerInfo(ContainerConfig config, OrchestrationCredential cred, ContainerConstraint constraint, int componentNumber) throws CloudbreakOrchestratorFailedException {
String applicationName = applicationUtils.getApplicationName(constraint, componentNumber);
// Build the ApplicationDetailRequest
ApplicationDetailRequest applicationDetailRequest = new ApplicationDetailRequest();
applicationDetailRequest.setName(applicationName);
try {
// Validate that the app exists
YarnClient yarnHttpClient = new YarnHttpClient(cred.getApiEndpoint());
ResponseContext appDetailResponseContext = yarnHttpClient.getApplicationDetail(applicationDetailRequest);
if (appDetailResponseContext.getResponseError() != null) {
ApplicationErrorResponse applicationErrorResponse = appDetailResponseContext.getResponseError();
throw new CloudbreakOrchestratorFailedException(String.format("ERROR: HTTP Return: %d Error: %s.", appDetailResponseContext.getStatusCode(), applicationErrorResponse.getDiagnostics()));
}
// Return the details
String componentHostName = applicationUtils.getComponentHostName(constraint, cred, componentNumber);
String image = String.format("%s:%s", config.getName(), config.getVersion());
return new ContainerInfo(applicationName, applicationName, componentHostName, image);
} catch (MalformedURLException e) {
String msg = String.format("ERROR: URL is malformed: %s", cred.getApiEndpoint());
throw new CloudbreakOrchestratorFailedException(msg, e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.yarn.model.response.ApplicationErrorResponse in project cloudbreak by hortonworks.
the class ApplicationSubmissionHandler method submitCreateApplicationRequest.
private void submitCreateApplicationRequest(CreateApplicationRequest createApplicationRequest, YarnClient yarnHttpClient) throws CloudbreakOrchestratorFailedException {
try {
ResponseContext createAppResponseContext = yarnHttpClient.createApplication(createApplicationRequest);
if (createAppResponseContext.getResponseError() != null) {
ApplicationErrorResponse applicationErrorResponse = createAppResponseContext.getResponseError();
String msg = String.format("ERROR: HTTP Return: %d Error: %s", createAppResponseContext.getStatusCode(), applicationErrorResponse.getDiagnostics());
LOGGER.debug(msg);
throw new CloudbreakOrchestratorFailedException(msg);
}
} catch (Exception e) {
throw new CloudbreakOrchestratorFailedException(e);
}
}
Aggregations