use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class StackScalabilityCondition method isScalable.
boolean isScalable(Stack stack, String instanceGroupName) {
InstanceGroup instanceGroup = getInstanceGroupByName(stack, instanceGroupName);
List<InstanceStatus> statuses = getStatuses(instanceGroup);
return statuses.stream().noneMatch(status -> status.equals(InstanceStatus.REQUESTED));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class StackStartStopService method handleError.
private void handleError(StackView stackView, Exception exception, DetailedStackStatus detailedStackStatus, ResourceEvent resourceEvent, String logMessage) {
LOGGER.debug(logMessage, exception);
Status stackStatus = detailedStackStatus.getStatus();
stackUpdater.updateStackStatus(stackView.getId(), detailedStackStatus, logMessage + exception.getMessage());
flowMessageService.fireEventAndLog(stackView.getId(), stackStatus.name(), resourceEvent, exception.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class StackStartStopService method updateInstancesToStopped.
private void updateInstancesToStopped(Stack stack, Collection<CloudVmInstanceStatus> instanceStatuses) {
Set<InstanceMetaData> allInstanceMetadataSet = instanceMetaDataService.getNotDeletedAndNotZombieInstanceMetadataByStackId(stack.getId());
for (InstanceMetaData metaData : allInstanceMetadataSet) {
Optional<CloudVmInstanceStatus> status = instanceStatuses.stream().filter(is -> is != null && is.getCloudInstance().getInstanceId() != null && is.getCloudInstance().getInstanceId().equals(metaData.getInstanceId())).findFirst();
if (status.isPresent()) {
CloudVmInstanceStatus cloudVmInstanceStatus = status.get();
com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus state = cloudVmInstanceStatus.getStatus() == InstanceStatus.STOPPED ? com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.STOPPED : FAILED;
metaData.setInstanceStatus(state);
}
}
instanceMetaDataService.saveAll(allInstanceMetadataSet);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class StackOperationService method start.
@VisibleForTesting
FlowIdentifier start(Stack stack) {
FlowIdentifier flowIdentifier = FlowIdentifier.notTriggered();
environmentService.checkEnvironmentStatus(stack, EnvironmentStatus.startable());
dataLakeStatusCheckerService.validateRunningState(stack);
if (stack.isAvailable()) {
eventService.fireCloudbreakEvent(stack.getId(), AVAILABLE.name(), STACK_START_IGNORED);
} else if (stack.isReadyForStart() || stack.isStartFailed()) {
flowIdentifier = flowManager.triggerStackStart(stack.getId());
} else {
throw new BadRequestException(String.format("Can't start the cluster because it is in %s state.", Optional.ofNullable(stack.getStatus()).map(Status::name).orElse("N/A")));
}
return flowIdentifier;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status in project cloudbreak by hortonworks.
the class StackSyncService method updateInstances.
public void updateInstances(Stack stack, Iterable<InstanceMetaData> instanceMetaDataList, Collection<CloudVmInstanceStatus> instanceStatuses, SyncConfig syncConfig) {
try {
Map<InstanceSyncState, Integer> counts = initInstanceStateCounts();
Json imageJson = new Json(imageService.getImage(stack.getId()));
for (InstanceMetaData metaData : instanceMetaDataList) {
Optional<CloudVmInstanceStatus> status = instanceStatuses.stream().filter(is -> is != null && is.getCloudInstance().getInstanceId() != null && is.getCloudInstance().getInstanceId().equals(metaData.getInstanceId())).findFirst();
InstanceSyncState state;
if (status.isPresent()) {
CloudVmInstanceStatus cloudVmInstanceStatus = status.get();
CloudInstance cloudInstance = cloudVmInstanceStatus.getCloudInstance();
state = InstanceSyncState.getInstanceSyncState(cloudVmInstanceStatus.getStatus());
syncInstance(metaData, cloudInstance, imageJson);
} else {
state = InstanceSyncState.DELETED;
}
try {
syncInstanceStatusByState(stack, counts, metaData, state);
} catch (TransactionRuntimeExecutionException e) {
LOGGER.error("Can't sync instance status by state!", e);
}
}
handleSyncResult(stack, counts, syncConfig);
} catch (CloudbreakImageNotFoundException | IllegalArgumentException ex) {
LOGGER.info("Error during stack sync:", ex);
throw new CloudbreakServiceException("Stack sync failed", ex);
}
}
Aggregations