Search in sources :

Example 1 with STACK_SYNC_INSTANCE_STATUS_RETRIEVAL_FAILED

use of com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_SYNC_INSTANCE_STATUS_RETRIEVAL_FAILED in project cloudbreak by hortonworks.

the class StackSyncService method autoSync.

public void autoSync(Stack stack, Collection<InstanceMetaData> instances, List<CloudVmInstanceStatus> instanceStatuses, InstanceSyncState defaultState, SyncConfig syncConfig) {
    Map<String, InstanceSyncState> instanceSyncStates = instanceStatuses.stream().collect(Collectors.toMap(i -> i.getCloudInstance().getInstanceId(), i -> InstanceSyncState.getInstanceSyncState(i.getStatus())));
    Map<InstanceSyncState, Integer> instanceStateCounts = initInstanceStateCounts();
    for (InstanceMetaData instance : instances) {
        try {
            InstanceSyncState instanceSyncState = calculateInstanceSyncState(defaultState, instanceSyncStates, instance);
            syncInstanceStatusByState(stack, instanceStateCounts, instance, instanceSyncState);
            if (!syncConfig.isCmServerRunning() && InstanceSyncState.RUNNING.equals(instanceSyncState) && instance.isPrimaryGateway()) {
                instanceMetaDataService.updateInstanceStatus(instance, InstanceStatus.SERVICES_UNHEALTHY, CM_SERVER_NOT_RESPONDING);
            }
        } catch (CloudConnectorException e) {
            LOGGER.warn(e.getMessage(), e);
            eventService.fireCloudbreakEvent(stack.getId(), AVAILABLE.name(), STACK_SYNC_INSTANCE_STATUS_RETRIEVAL_FAILED, Collections.singletonList(instance.getInstanceId()));
            incrementInstanceStateCount(instanceStateCounts, InstanceSyncState.UNKNOWN);
        }
    }
    handleSyncResult(stack, instanceStateCounts, syncConfig);
}
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) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)

Aggregations

DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)1 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)1 AVAILABLE (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.AVAILABLE)1 DELETE_FAILED (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.DELETE_FAILED)1 NODE_FAILURE (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.NODE_FAILURE)1 STOPPED (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.STOPPED)1 UNREACHABLE (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UNREACHABLE)1 WAIT_FOR_SYNC (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.WAIT_FOR_SYNC)1 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)1 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)1 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)1 INSTANCE_NAME (com.sequenceiq.cloudbreak.cloud.model.CloudInstance.INSTANCE_NAME)1 CloudVmInstanceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmInstanceStatus)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 TransactionRuntimeExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)1 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)1 CLUSTER_FAILED_NODES_REPORTED_CLUSTER_EVENT (com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_FAILED_NODES_REPORTED_CLUSTER_EVENT)1