use of com.sequenceiq.cloudbreak.orchestrator.yarn.model.request.ApplicationDetailRequest in project cloudbreak by hortonworks.
the class YarnApplicationPoller method getApplicationDetailRequest.
private ApplicationDetailRequest getApplicationDetailRequest(String appName) {
ApplicationDetailRequest applicationDetailRequest = new ApplicationDetailRequest();
applicationDetailRequest.setName(appName);
return applicationDetailRequest;
}
use of com.sequenceiq.cloudbreak.orchestrator.yarn.model.request.ApplicationDetailRequest 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.request.ApplicationDetailRequest 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;
}
Aggregations