Search in sources :

Example 6 with Payload

use of com.sequenceiq.cloudbreak.cloud.event.Payload in project cloudbreak by hortonworks.

the class WaitForSyncRestartAction method restart.

@Override
public void restart(String flowId, String flowChainId, String event, Object payload) {
    Payload stackPayload = (Payload) payload;
    Stack stack = stackService.getByIdWithLists(stackPayload.getStackId());
    stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.WAIT_FOR_SYNC, stack.getStatusReason());
    flowLogService.terminate(stackPayload.getStackId(), flowId);
}
Also used : Payload(com.sequenceiq.cloudbreak.cloud.event.Payload) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 7 with Payload

use of com.sequenceiq.cloudbreak.cloud.event.Payload in project cloudbreak by hortonworks.

the class Flow2Handler method restartFlow.

public void restartFlow(String flowId) {
    FlowLog flowLog = flowLogRepository.findFirstByFlowIdOrderByCreatedDesc(flowId);
    if (RESTARTABLE_FLOWS.contains(flowLog.getFlowType())) {
        Optional<FlowConfiguration<?>> flowConfig = flowConfigs.stream().filter(fc -> fc.getClass().equals(flowLog.getFlowType())).findFirst();
        Payload payload = (Payload) JsonReader.jsonToJava(flowLog.getPayload());
        Flow flow = flowConfig.get().createFlow(flowId, payload.getStackId());
        runningFlows.put(flow, flowLog.getFlowChainId());
        if (flowLog.getFlowChainId() != null) {
            flowChainHandler.restoreFlowChain(flowLog.getFlowChainId());
        }
        Map<Object, Object> variables = (Map<Object, Object>) JsonReader.jsonToJava(flowLog.getVariables());
        flow.initialize(flowLog.getCurrentState(), variables);
        RestartAction restartAction = flowConfig.get().getRestartAction(flowLog.getNextEvent());
        if (restartAction != null) {
            restartAction.restart(flowId, flowLog.getFlowChainId(), flowLog.getNextEvent(), payload);
            return;
        }
    }
    flowLogService.terminate(flowLog.getStackId(), flowId);
}
Also used : ClusterUpgradeFlowConfig(com.sequenceiq.cloudbreak.core.flow2.cluster.upgrade.ClusterUpgradeFlowConfig) Arrays(java.util.Arrays) FlowConfiguration(com.sequenceiq.cloudbreak.core.flow2.config.FlowConfiguration) StackStopFlowConfig(com.sequenceiq.cloudbreak.core.flow2.stack.stop.StackStopFlowConfig) StackSyncFlowConfig(com.sequenceiq.cloudbreak.core.flow2.stack.sync.StackSyncFlowConfig) LoggerFactory(org.slf4j.LoggerFactory) JsonReader(com.cedarsoftware.util.io.JsonReader) FlowLog(com.sequenceiq.cloudbreak.domain.FlowLog) TERMINATION_EVENT(com.sequenceiq.cloudbreak.core.flow2.stack.termination.StackTerminationEvent.TERMINATION_EVENT) MDCBuilder(com.sequenceiq.cloudbreak.logger.MDCBuilder) Acceptable(com.sequenceiq.cloudbreak.cloud.Acceptable) Inject(javax.inject.Inject) ClusterDownscaleFlowConfig(com.sequenceiq.cloudbreak.core.flow2.cluster.downscale.ClusterDownscaleFlowConfig) ManualStackRepairTriggerFlowConfig(com.sequenceiq.cloudbreak.core.flow2.stack.repair.ManualStackRepairTriggerFlowConfig) Event(reactor.bus.Event) ClusterTerminationFlowConfig(com.sequenceiq.cloudbreak.core.flow2.cluster.termination.ClusterTerminationFlowConfig) ClusterStopFlowConfig(com.sequenceiq.cloudbreak.core.flow2.cluster.stop.ClusterStopFlowConfig) Map(java.util.Map) FlowChains(com.sequenceiq.cloudbreak.core.flow2.chain.FlowChains) FlowLogService(com.sequenceiq.cloudbreak.service.flowlog.FlowLogService) ChangePrimaryGatewayFlowConfig(com.sequenceiq.cloudbreak.core.flow2.cluster.repair.ChangePrimaryGatewayFlowConfig) StackTerminationFlowConfig(com.sequenceiq.cloudbreak.core.flow2.stack.termination.StackTerminationFlowConfig) StackDownscaleConfig(com.sequenceiq.cloudbreak.core.flow2.stack.downscale.StackDownscaleConfig) InstanceTerminationFlowConfig(com.sequenceiq.cloudbreak.core.flow2.stack.instance.termination.InstanceTerminationFlowConfig) Logger(org.slf4j.Logger) ClusterCreationFlowConfig(com.sequenceiq.cloudbreak.core.flow2.cluster.provision.ClusterCreationFlowConfig) ClusterCredentialChangeFlowConfig(com.sequenceiq.cloudbreak.core.flow2.cluster.userpasswd.ClusterCredentialChangeFlowConfig) Resource(javax.annotation.Resource) Set(java.util.Set) ClusterResetFlowConfig(com.sequenceiq.cloudbreak.core.flow2.cluster.reset.ClusterResetFlowConfig) ClusterUpscaleFlowConfig(com.sequenceiq.cloudbreak.core.flow2.cluster.upscale.ClusterUpscaleFlowConfig) UUID(java.util.UUID) StackCreationFlowConfig(com.sequenceiq.cloudbreak.core.flow2.stack.provision.StackCreationFlowConfig) Payload(com.sequenceiq.cloudbreak.cloud.event.Payload) ClusterStartFlowConfig(com.sequenceiq.cloudbreak.core.flow2.cluster.start.ClusterStartFlowConfig) ClusterSyncFlowConfig(com.sequenceiq.cloudbreak.core.flow2.cluster.sync.ClusterSyncFlowConfig) List(java.util.List) Component(org.springframework.stereotype.Component) StackUpscaleConfig(com.sequenceiq.cloudbreak.core.flow2.stack.upscale.StackUpscaleConfig) FlowChainHandler(com.sequenceiq.cloudbreak.core.flow2.chain.FlowChainHandler) LoggerContextKey(com.sequenceiq.cloudbreak.logger.LoggerContextKey) FlowLogRepository(com.sequenceiq.cloudbreak.repository.FlowLogRepository) Optional(java.util.Optional) StackStartFlowConfig(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackStartFlowConfig) Consumer(reactor.fn.Consumer) Collections(java.util.Collections) FlowConfiguration(com.sequenceiq.cloudbreak.core.flow2.config.FlowConfiguration) FlowLog(com.sequenceiq.cloudbreak.domain.FlowLog) Payload(com.sequenceiq.cloudbreak.cloud.event.Payload) Map(java.util.Map)

Aggregations

Payload (com.sequenceiq.cloudbreak.cloud.event.Payload)7 Stack (com.sequenceiq.cloudbreak.domain.Stack)5 MDCBuilder (com.sequenceiq.cloudbreak.logger.MDCBuilder)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Set (java.util.Set)2 JsonReader (com.cedarsoftware.util.io.JsonReader)1 Acceptable (com.sequenceiq.cloudbreak.cloud.Acceptable)1 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 AvailabilityZone.availabilityZone (com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone.availabilityZone)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 Location (com.sequenceiq.cloudbreak.cloud.model.Location)1 Location.location (com.sequenceiq.cloudbreak.cloud.model.Location.location)1 Region.region (com.sequenceiq.cloudbreak.cloud.model.Region.region)1 CredentialToCloudCredentialConverter (com.sequenceiq.cloudbreak.converter.spi.CredentialToCloudCredentialConverter)1 ResourceToCloudResourceConverter (com.sequenceiq.cloudbreak.converter.spi.ResourceToCloudResourceConverter)1 StackToCloudStackConverter (com.sequenceiq.cloudbreak.converter.spi.StackToCloudStackConverter)1 AbstractAction (com.sequenceiq.cloudbreak.core.flow2.AbstractAction)1 FlowChainHandler (com.sequenceiq.cloudbreak.core.flow2.chain.FlowChainHandler)1