Search in sources :

Example 36 with Status

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));
}
Also used : InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 37 with Status

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());
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) CloudVmInstanceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) InstanceStatus(com.sequenceiq.cloudbreak.cloud.model.InstanceStatus) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)

Example 38 with Status

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);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) SERVICES_RUNNING(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.SERVICES_RUNNING) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) AVAILABLE(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.AVAILABLE) LoggerFactory(org.slf4j.LoggerFactory) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) STACK_INFRASTRUCTURE_STOPPING(com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_INFRASTRUCTURE_STOPPING) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException) Inject(javax.inject.Inject) STACK_INFRASTRUCTURE_STOPPED(com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_INFRASTRUCTURE_STOPPED) TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) Service(org.springframework.stereotype.Service) InstancesStatusResult(com.sequenceiq.cloudbreak.cloud.event.instance.InstancesStatusResult) CloudbreakFlowMessageService(com.sequenceiq.cloudbreak.core.flow2.stack.CloudbreakFlowMessageService) FAILED(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.FAILED) StackUpdater(com.sequenceiq.cloudbreak.service.StackUpdater) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) StartInstancesResult(com.sequenceiq.cloudbreak.cloud.event.instance.StartInstancesResult) MetadataSetupService(com.sequenceiq.cloudbreak.service.stack.flow.MetadataSetupService) CloudVmInstanceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus) Logger(org.slf4j.Logger) Collection(java.util.Collection) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) Set(java.util.Set) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) STACK_INFRASTRUCTURE_STARTED(com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_INFRASTRUCTURE_STARTED) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) List(java.util.List) OperationException(com.sequenceiq.cloudbreak.service.OperationException) InstanceStatus(com.sequenceiq.cloudbreak.cloud.model.InstanceStatus) STACK_INFRASTRUCTURE_STARTING(com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_INFRASTRUCTURE_STARTING) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) StopInstancesResult(com.sequenceiq.cloudbreak.cloud.event.instance.StopInstancesResult) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) Optional(java.util.Optional) STOPPED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.STOPPED) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) CloudVmInstanceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus)

Example 39 with Status

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;
}
Also used : DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) EnvironmentStatus(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentStatus) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 40 with Status

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);
    }
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) AVAILABLE(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.AVAILABLE) LoggerFactory(org.slf4j.LoggerFactory) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException) Inject(javax.inject.Inject) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) ImageService(com.sequenceiq.cloudbreak.service.image.ImageService) STACK_SYNC_INSTANCE_DELETED_CBMETADATA(com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_SYNC_INSTANCE_DELETED_CBMETADATA) CloudbreakEventService(com.sequenceiq.cloudbreak.structuredevent.event.CloudbreakEventService) Service(org.springframework.stereotype.Service) STACK_SYNC_INSTANCE_DELETED_BY_PROVIDER_CBMETADATA(com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_SYNC_INSTANCE_DELETED_BY_PROVIDER_CBMETADATA) Map(java.util.Map) StackUpdater(com.sequenceiq.cloudbreak.service.StackUpdater) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) INSTANCE_NAME(com.sequenceiq.cloudbreak.cloud.model.CloudInstance.INSTANCE_NAME) CloudVmInstanceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus) Logger(org.slf4j.Logger) EnumMap(java.util.EnumMap) Collection(java.util.Collection) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) Collectors(java.util.stream.Collectors) CLUSTER_FAILED_NODES_REPORTED_CLUSTER_EVENT(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_FAILED_NODES_REPORTED_CLUSTER_EVENT) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) NODE_FAILURE(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.NODE_FAILURE) STACK_SYNC_INSTANCE_STATUS_RETRIEVAL_FAILED(com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_SYNC_INSTANCE_STATUS_RETRIEVAL_FAILED) Json(com.sequenceiq.cloudbreak.common.json.Json) List(java.util.List) DELETE_FAILED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.DELETE_FAILED) WAIT_FOR_SYNC(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.WAIT_FOR_SYNC) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Optional(java.util.Optional) UNREACHABLE(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UNREACHABLE) STOPPED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.STOPPED) Collections(java.util.Collections) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CloudVmInstanceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Json(com.sequenceiq.cloudbreak.common.json.Json) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)

Aggregations

DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)23 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)22 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)18 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)12 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 StackStatusV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)9 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)7 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)7 Map (java.util.Map)7 Collectors (java.util.stream.Collectors)7 CloudVmInstanceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus)6 Collection (java.util.Collection)6 List (java.util.List)6 Set (java.util.Set)6 Inject (javax.inject.Inject)6 PollerStoppedException (com.dyngr.exception.PollerStoppedException)5 ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)5 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)5