Search in sources :

Example 1 with ApplicationErrorResponse

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);
    }
}
Also used : YarnHttpClient(com.sequenceiq.cloudbreak.orchestrator.yarn.client.YarnHttpClient) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) MalformedURLException(java.net.MalformedURLException) ApplicationDetailRequest(com.sequenceiq.cloudbreak.orchestrator.yarn.model.request.ApplicationDetailRequest) ResponseContext(com.sequenceiq.cloudbreak.orchestrator.yarn.model.response.ResponseContext) ContainerInfo(com.sequenceiq.cloudbreak.orchestrator.model.ContainerInfo) ApplicationErrorResponse(com.sequenceiq.cloudbreak.orchestrator.yarn.model.response.ApplicationErrorResponse) YarnClient(com.sequenceiq.cloudbreak.orchestrator.yarn.client.YarnClient)

Example 2 with ApplicationErrorResponse

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);
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) ResponseContext(com.sequenceiq.cloudbreak.orchestrator.yarn.model.response.ResponseContext) ApplicationErrorResponse(com.sequenceiq.cloudbreak.orchestrator.yarn.model.response.ApplicationErrorResponse) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)

Aggregations

CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)2 ApplicationErrorResponse (com.sequenceiq.cloudbreak.orchestrator.yarn.model.response.ApplicationErrorResponse)2 ResponseContext (com.sequenceiq.cloudbreak.orchestrator.yarn.model.response.ResponseContext)2 ContainerInfo (com.sequenceiq.cloudbreak.orchestrator.model.ContainerInfo)1 YarnClient (com.sequenceiq.cloudbreak.orchestrator.yarn.client.YarnClient)1 YarnHttpClient (com.sequenceiq.cloudbreak.orchestrator.yarn.client.YarnHttpClient)1 ApplicationDetailRequest (com.sequenceiq.cloudbreak.orchestrator.yarn.model.request.ApplicationDetailRequest)1 MalformedURLException (java.net.MalformedURLException)1