Search in sources :

Example 36 with CloudbreakOrchestratorFailedException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.

the class YarnHttpClient method validateApiEndpoint.

@Override
public void validateApiEndpoint() throws CloudbreakOrchestratorFailedException, MalformedURLException {
    YarnEndpoint dashEndpoint = new YarnEndpoint(apiEndpoint, YarnResourceConstants.APPLICATIONS_PATH);
    ClientConfig clientConfig = new DefaultClientConfig();
    Client client = Client.create(clientConfig);
    WebResource webResource = client.resource(dashEndpoint.getFullEndpointUrl().toString());
    ClientResponse response = webResource.accept("application/json").type("application/json").get(ClientResponse.class);
    // Validate HTTP 200 status code
    if (response.getStatus() != YarnResourceConstants.HTTP_SUCCESS) {
        String msg = String.format("Received %d status code from url %s, reason: %s", response.getStatus(), dashEndpoint.getFullEndpointUrl().toString(), response.getEntity(String.class));
        LOGGER.debug(msg);
        throw new CloudbreakOrchestratorFailedException(msg);
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) WebResource(com.sun.jersey.api.client.WebResource) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) Client(com.sun.jersey.api.client.Client) YarnEndpoint(com.sequenceiq.cloudbreak.orchestrator.yarn.api.YarnEndpoint)

Example 37 with CloudbreakOrchestratorFailedException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException 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 38 with CloudbreakOrchestratorFailedException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException 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)

Example 39 with CloudbreakOrchestratorFailedException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException in project cloudbreak by hortonworks.

the class YarnAppBootstrap method call.

@Override
public Boolean call() throws Exception {
    YarnClient dashHttpClient = new YarnHttpClient(apiEndpoint);
    // Make the request
    ApplicationDetailRequest applicationDetailRequest = new ApplicationDetailRequest();
    applicationDetailRequest.setName(appName);
    ResponseContext responseContext = dashHttpClient.getApplicationDetail(applicationDetailRequest);
    // If 404, application isn't ready, sleep
    if (responseContext.getStatusCode() == YarnResourceConstants.HTTP_NOT_FOUND) {
        String msg = String.format("Application %s not ready, received %d response, sleeping 1000 ms", appName, responseContext.getStatusCode());
        LOGGER.debug(msg);
        throw new CloudbreakOrchestratorFailedException(msg);
    }
    // If 200, check application state to ensure RUNNING
    if (responseContext.getStatusCode() == YarnResourceConstants.HTTP_SUCCESS) {
        if (null != responseContext.getResponseObject()) {
            ApplicationDetailResponse applicationDetailResponse = (ApplicationDetailResponse) responseContext.getResponseObject();
            // Validate the application is "RUNNING"
            if (!applicationDetailResponse.getState().equals(ApplicationState.READY.name())) {
                LOGGER.debug(String.format("Application %s not ready, in %s state, sleeping 1000 ms", appName, applicationDetailResponse.getState()));
                throw new CloudbreakOrchestratorFailedException(String.format("Application %s not ready, in %s state, sleeping 1000 ms", appName, applicationDetailResponse.getState()));
            } else {
                // Validate the container is running
                if (!applicationDetailResponse.getContainers().isEmpty()) {
                    Container appContainer = applicationDetailResponse.getContainers().get(0);
                    if (!appContainer.getState().equals(ContainerState.READY.name())) {
                        String msg = String.format("Application %s not ready, in %s state, sleeping 1000 ms", appName, applicationDetailResponse.getState());
                        LOGGER.debug(msg);
                        throw new CloudbreakOrchestratorFailedException(msg);
                    } else {
                        String msg = String.format("Application %s has now successfully started, in %s state", appName, applicationDetailResponse.getState());
                        LOGGER.debug(msg);
                        return true;
                    }
                }
            }
        }
    }
    return true;
}
Also used : YarnHttpClient(com.sequenceiq.cloudbreak.orchestrator.yarn.client.YarnHttpClient) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) ApplicationDetailResponse(com.sequenceiq.cloudbreak.orchestrator.yarn.model.response.ApplicationDetailResponse) Container(com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.Container) ApplicationDetailRequest(com.sequenceiq.cloudbreak.orchestrator.yarn.model.request.ApplicationDetailRequest) ResponseContext(com.sequenceiq.cloudbreak.orchestrator.yarn.model.response.ResponseContext) YarnClient(com.sequenceiq.cloudbreak.orchestrator.yarn.client.YarnClient)

Aggregations

CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)39 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)14 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)14 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)12 ExecutionException (java.util.concurrent.ExecutionException)12 IOException (java.io.IOException)11 Node (com.sequenceiq.cloudbreak.orchestrator.model.Node)10 OrchestratorBootstrap (com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap)9 HostOrchestrator (com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator)9 HashSet (java.util.HashSet)9 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)7 SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)6 GrainAddRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainAddRunner)6 GrainRemoveRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainRemoveRunner)6 HighStateRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateRunner)6 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)6 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)5 RecipeModel (com.sequenceiq.cloudbreak.orchestrator.model.RecipeModel)5