Search in sources :

Example 36 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class ClusterUpgradeHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeRequest> event) {
    LOGGER.debug("Accepting Cluster upgrade event..");
    ClusterUpgradeRequest request = event.getData();
    Long stackId = request.getResourceId();
    Selectable result;
    try {
        Stack stack = stackService.getByIdWithClusterInTransaction(stackId);
        Optional<String> remoteDataContext = getRemoteDataContext(stack);
        ClusterApi connector = clusterApiConnectors.getConnector(stack);
        Set<ClusterComponent> components = parcelService.getParcelComponentsByBlueprint(stack);
        connector.upgradeClusterRuntime(components, request.isPatchUpgrade(), remoteDataContext);
        ParcelOperationStatus parcelOperationStatus = parcelService.removeUnusedParcelComponents(stack, components);
        if (parcelOperationStatus.getFailed().isEmpty()) {
            result = new ClusterUpgradeSuccess(request.getResourceId());
        } else {
            LOGGER.info("There are failed parcel removals: {}", parcelOperationStatus);
            CloudbreakException exception = new CloudbreakException(format("Failed to remove the following parcels: %s", parcelOperationStatus.getFailed()));
            result = new ClusterUpgradeFailedEvent(request.getResourceId(), exception, DetailedStackStatus.CLUSTER_UPGRADE_FAILED);
        }
    } catch (Exception e) {
        LOGGER.error("Cluster upgrade event failed", e);
        result = new ClusterUpgradeFailedEvent(request.getResourceId(), e, DetailedStackStatus.CLUSTER_UPGRADE_FAILED);
    }
    return result;
}
Also used : ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ClusterUpgradeRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeRequest) ClusterUpgradeFailedEvent(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeFailedEvent) ClusterUpgradeSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.ClusterUpgradeSuccess) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException)

Example 37 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class ExecutePostClusterManagerStartRecipesHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ExecutePostClusterManagerStartRecipesRequest> event) {
    Long stackId = event.getData().getResourceId();
    Selectable response;
    try {
        clusterBuilderService.executePostClusterManagerStartRecipes(stackId);
        response = new ExecutePostClusterManagerStartRecipesSuccess(stackId);
    } catch (RuntimeException | CloudbreakException e) {
        LOGGER.error("ExecutePostClusterManagerStartRecipesHandler step failed with the following message: {}", e.getMessage());
        response = new ExecutePostClusterManagerStartRecipesFailed(stackId, e);
    }
    return response;
}
Also used : ExecutePostClusterManagerStartRecipesFailed(com.sequenceiq.cloudbreak.reactor.api.event.cluster.install.ExecutePostClusterManagerStartRecipesFailed) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) ExecutePostClusterManagerStartRecipesSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.install.ExecutePostClusterManagerStartRecipesSuccess)

Example 38 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class PrepareExtendedTemplateHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<PrepareExtendedTemplateRequest> event) {
    Long stackId = event.getData().getResourceId();
    Selectable response;
    try {
        clusterBuilderService.prepareExtendedTemplate(stackId);
        response = new PrepareExtendedTemplateSuccess(stackId);
    } catch (RuntimeException e) {
        LOGGER.error("PrepareExtendedTemplateHandler step failed with the following message: {}", e.getMessage());
        response = new PrepareExtendedTemplateFailed(stackId, e);
    }
    return response;
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PrepareExtendedTemplateFailed(com.sequenceiq.cloudbreak.reactor.api.event.cluster.install.PrepareExtendedTemplateFailed) PrepareExtendedTemplateSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.install.PrepareExtendedTemplateSuccess)

Example 39 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class SuppressClusterWarningsHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<SuppressClusterWarningsRequest> event) {
    Long stackId = event.getData().getResourceId();
    Selectable response;
    try {
        clusterBuilderService.suppressWarnings(stackId);
        response = new SuppressClusterWarningsSuccess(stackId);
    } catch (RuntimeException e) {
        LOGGER.error("SuppressClusterWarningsHandler step failed with the following message: {}", e.getMessage());
        response = new SuppressClusterWarningsFailed(stackId, e);
    }
    return response;
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) SuppressClusterWarningsFailed(com.sequenceiq.cloudbreak.reactor.api.event.cluster.install.SuppressClusterWarningsFailed) SuppressClusterWarningsSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.install.SuppressClusterWarningsSuccess)

Example 40 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class UpdateClusterConfigHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<UpdateClusterConfigRequest> event) {
    Long stackId = event.getData().getResourceId();
    Selectable response;
    try {
        clusterBuilderService.updateConfig(stackId);
        response = new UpdateClusterConfigSuccess(stackId);
    } catch (RuntimeException e) {
        LOGGER.error("UpdateClusterConfigHandler step failed with the following message: {}", e.getMessage());
        response = new UpdateClusterConfigFailed(stackId, e);
    }
    return response;
}
Also used : UpdateClusterConfigFailed(com.sequenceiq.cloudbreak.reactor.api.event.cluster.install.UpdateClusterConfigFailed) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpdateClusterConfigSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.install.UpdateClusterConfigSuccess)

Aggregations

Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)283 Test (org.junit.jupiter.api.Test)93 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)48 Map (java.util.Map)47 List (java.util.List)36 FlowTriggerEventQueue (com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue)35 Collectors (java.util.stream.Collectors)35 PollerException (com.dyngr.exception.PollerException)32 PollerStoppedException (com.dyngr.exception.PollerStoppedException)32 UserBreakException (com.dyngr.exception.UserBreakException)32 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)30 Optional (java.util.Optional)30 Set (java.util.Set)30 Bean (org.springframework.context.annotation.Bean)28 Event (reactor.bus.Event)28 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)27 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)27 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)27 Inject (javax.inject.Inject)24 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)23