Search in sources :

Example 1 with RemoveHostsFailed

use of com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsFailed in project cloudbreak by hortonworks.

the class RemoveHostsHandler method accept.

@Override
public void accept(Event<RemoveHostsRequest> removeHostsRequestEvent) {
    RemoveHostsRequest request = removeHostsRequestEvent.getData();
    Set<String> hostNames = request.getHostNames();
    Selectable result;
    try {
        Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
        if (stack.getPrimaryGatewayInstance() != null && stack.getPrimaryGatewayInstance().isReachable()) {
            List<GatewayConfig> allGatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
            PollingResult orchestratorRemovalPollingResult = removeHostsFromOrchestrator(stack, new ArrayList<>(hostNames), hostOrchestrator, allGatewayConfigs);
            if (!orchestratorRemovalPollingResult.isSuccess()) {
                LOGGER.warn("Can not remove hosts from orchestrator: {}", hostNames);
            }
        } else {
            LOGGER.warn("Primary gateway is not reachable, can't remove hosts from orchestrator");
        }
        result = new RemoveHostsSuccess(request.getResourceId(), request.getHostGroupNames(), hostNames);
    } catch (Exception e) {
        result = new RemoveHostsFailed(removeHostsRequestEvent.getData().getResourceId(), e, request.getHostGroupNames(), hostNames);
    }
    eventBus.notify(result.selector(), new Event<>(removeHostsRequestEvent.getHeaders(), result));
}
Also used : RemoveHostsSuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsSuccess) RemoveHostsFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsFailed) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) RemoveHostsRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollingResult(com.sequenceiq.cloudbreak.polling.PollingResult) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 2 with RemoveHostsFailed

use of com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsFailed in project cloudbreak by hortonworks.

the class ClusterDownscaleActions method updateInstanceMetadataOrchestrationFailedAction.

@Bean(name = "REMOVE_HOSTS_FROM_ORCHESTRATION_FAILED_STATE")
public Action<?, ?> updateInstanceMetadataOrchestrationFailedAction() {
    return new AbstractClusterAction<>(RemoveHostsFailed.class) {

        @Override
        protected void doExecute(ClusterViewContext context, RemoveHostsFailed payload, Map<Object, Object> variables) {
            clusterDownscaleService.updateMetadataStatusToFailed(payload);
            sendEvent(context, FAILURE_EVENT.event(), new StackFailureEvent(payload.getResourceId(), payload.getException()));
        }
    };
}
Also used : RemoveHostsFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsFailed) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) AbstractClusterAction(com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction) Map(java.util.Map) ClusterViewContext(com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext) Bean(org.springframework.context.annotation.Bean)

Aggregations

RemoveHostsFailed (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsFailed)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 AbstractClusterAction (com.sequenceiq.cloudbreak.core.flow2.cluster.AbstractClusterAction)1 ClusterViewContext (com.sequenceiq.cloudbreak.core.flow2.cluster.ClusterViewContext)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)1 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)1 PollingResult (com.sequenceiq.cloudbreak.polling.PollingResult)1 StackFailureEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent)1 RemoveHostsRequest (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsRequest)1 RemoveHostsSuccess (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsSuccess)1 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1