use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class PollResourcesStateTask method doCall.
@Override
protected ResourcesStatePollerResult doCall() {
List<CloudResourceStatus> results = resourceConnector.check(getAuthenticatedContext(), cloudResource);
CloudResourceStatus status = ResourceStatusLists.aggregate(results);
return new ResourcesStatePollerResult(getAuthenticatedContext().getCloudContext(), status.getStatus(), status.getStatusReason(), results);
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class CloudFailureHandler method handleExceptions.
private void handleExceptions(AuthenticatedContext auth, List<CloudResourceStatus> cloudResourceStatuses, Group group, ResourceBuilderContext ctx, ResourceBuilders resourceBuilders, Collection<Long> ids, Boolean upscale) {
List<CloudResource> resources = new ArrayList<>(cloudResourceStatuses.size());
for (CloudResourceStatus exception : cloudResourceStatuses) {
if (ResourceStatus.FAILED.equals(exception.getStatus()) || ids.contains(exception.getPrivateId())) {
LOGGER.error("Failed to create instance: " + exception.getStatusReason());
resources.add(exception.getCloudResource());
}
}
if (!resources.isEmpty()) {
LOGGER.info("Resource list not empty so rollback will start.Resource list size is: " + resources.size());
doRollbackAndDecreaseNodeCount(auth, cloudResourceStatuses, ids, group, ctx, resourceBuilders, upscale);
}
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class StackCreationService method updateNodeCount.
private void updateNodeCount(Long stackId, Iterable<Group> originalGroups, Iterable<CloudResourceStatus> statuses) {
for (Group group : originalGroups) {
int nodeCount = group.getInstancesSize();
List<CloudResourceStatus> failedResources = removeFailedMetadata(stackId, statuses, group);
if (!failedResources.isEmpty()) {
int failedCount = failedResources.size();
InstanceGroup instanceGroup = instanceGroupRepository.findOneByGroupNameInStack(stackId, group.getName());
instanceGroup.setNodeCount(nodeCount - failedCount);
instanceGroupRepository.save(instanceGroup);
flowMessageService.fireEventAndLog(stackId, Msg.STACK_INFRASTRUCTURE_ROLLBACK_MESSAGE, UPDATE_IN_PROGRESS.name(), failedCount, group.getName(), failedResources.get(0).getStatusReason());
}
}
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class YarnResourceConnector method check.
@Override
public List<CloudResourceStatus> check(AuthenticatedContext authenticatedContext, List<CloudResource> resources) {
YarnClient yarnClient = yarnClientUtil.createYarnClient(authenticatedContext);
List<CloudResourceStatus> result = new ArrayList<>();
for (CloudResource resource : resources) {
switch(resource.getType()) {
case YARN_APPLICATION:
LOGGER.info("Checking Yarn application status of: {}", resource.getName());
try {
ApplicationDetailRequest applicationDetailRequest = new ApplicationDetailRequest();
applicationDetailRequest.setName(resource.getName());
ResponseContext responseContext = yarnClient.getApplicationDetail(applicationDetailRequest);
if (responseContext.getStatusCode() == YarnResourceConstants.HTTP_SUCCESS) {
ApplicationDetailResponse applicationDetailResponse = (ApplicationDetailResponse) responseContext.getResponseObject();
result.add(new CloudResourceStatus(resource, YarnApplicationStatus.mapResourceStatus(applicationDetailResponse.getState())));
} else if (responseContext.getStatusCode() == YarnResourceConstants.HTTP_NOT_FOUND) {
result.add(new CloudResourceStatus(resource, ResourceStatus.DELETED, "Yarn application has been killed."));
} else if (responseContext.getResponseError() != null) {
throw new CloudConnectorException(String.format("Yarn Application status check failed: HttpStatusCode: %d, Error: %s", responseContext.getStatusCode(), responseContext.getResponseError().getDiagnostics()));
} else {
throw new CloudConnectorException(String.format("Yarn Application status check failed: Invalid HttpStatusCode: %d", responseContext.getStatusCode()));
}
} catch (MalformedURLException | RuntimeException e) {
throw new CloudConnectorException(String.format("Invalid resource exception: %s", e.getMessage()), e);
}
break;
default:
throw new CloudConnectorException(String.format("Invalid resource type: %s", resource.getType()));
}
}
return result;
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus in project cloudbreak by hortonworks.
the class StackCreationService method provisioningFinished.
public Stack provisioningFinished(StackContext context, LaunchStackResult result, Map<Object, Object> variables) {
Date startDate = getStartDateIfExist(variables);
Stack stack = context.getStack();
validateResourceResults(context.getCloudContext(), result);
List<CloudResourceStatus> results = result.getResults();
stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.METADATA_COLLECTION, "Metadata collection");
updateNodeCount(stack.getId(), context.getCloudStack().getGroups(), results);
flowMessageService.fireEventAndLog(stack.getId(), Msg.STACK_INFRASTRUCTURE_TIME, UPDATE_IN_PROGRESS.name(), calculateStackCreationTime(startDate));
return stackService.getByIdWithLists(stack.getId());
}
Aggregations