Search in sources :

Example 11 with FlowTriggerEventQueue

use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.

the class BackupDatalakeDatabaseFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(DatabaseBackupTriggerEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new StackEvent(SaltUpdateEvent.SALT_UPDATE_EVENT.event(), event.getResourceId(), event.accepted()));
    flowEventChain.add(new DatabaseBackupTriggerEvent(DATABASE_BACKUP_EVENT.event(), event.getResourceId(), event.getBackupLocation(), event.getBackupId(), event.getCloseConnections()));
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) DatabaseBackupTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.DatabaseBackupTriggerEvent) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 12 with FlowTriggerEventQueue

use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.

the class FlowChainHandler method restoreFlowChain.

public void restoreFlowChain(String flowChainId) {
    Optional<FlowChainLog> chainLog = flowLogService.findFirstByFlowChainIdOrderByCreatedDesc(flowChainId);
    if (chainLog.isPresent()) {
        String flowChainType = chainLog.get().getFlowChainType();
        Queue<Selectable> queue = (Queue<Selectable>) JsonReader.jsonToJava(chainLog.get().getChain());
        Payload triggerEvent = tryDeserializeTriggerEvent(chainLog.get());
        FlowTriggerEventQueue chain = new FlowTriggerEventQueue(flowChainType, triggerEvent, queue);
        if (chainLog.get().getParentFlowChainId() != null) {
            chain.setParentFlowChainId(chainLog.get().getParentFlowChainId());
        }
        flowChains.putFlowChain(flowChainId, chainLog.get().getParentFlowChainId(), chain);
        Selectable selectable = queue.peek();
        if (selectable != null) {
            OperationType operationType = flowChainOperationTypeConfig.getFlowTypeOperationTypeMap().getOrDefault(flowChainType, OperationType.UNKNOWN);
            flowStatCache.putByFlowChainId(flowChainId, selectable.getResourceId(), operationType.name(), true);
        }
        if (chainLog.get().getParentFlowChainId() != null) {
            restoreFlowChain(chainLog.get().getParentFlowChainId());
        }
    }
}
Also used : FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) Payload(com.sequenceiq.cloudbreak.common.event.Payload) OperationType(com.sequenceiq.flow.api.model.operation.OperationType) FlowChainLog(com.sequenceiq.flow.domain.FlowChainLog) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Queue(java.util.Queue)

Example 13 with FlowTriggerEventQueue

use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.

the class FlowChains method triggerNextFlow.

public void triggerNextFlow(String flowChainId, String flowTriggerUserCrn, Map<Object, Object> contextParams, String operationType, Optional<Runnable> finalizerCallback) {
    FlowTriggerEventQueue flowTriggerEventQueue = flowChainMap.get(flowChainId);
    if (flowTriggerEventQueue != null) {
        Queue<Selectable> queue = flowTriggerEventQueue.getQueue();
        if (queue != null) {
            Selectable selectable = queue.peek();
            if (selectable != null) {
                sendEvent(flowTriggerEventQueue.getFlowChainName(), flowChainId, flowTriggerUserCrn, selectable, contextParams, operationType);
            } else {
                String parentFlowChainId = getParentFlowChainId(flowChainId);
                if (parentFlowChainId != null) {
                    flowChainMap.get(parentFlowChainId).getQueue().poll();
                    flowLogService.saveChain(parentFlowChainId, getParentFlowChainId(parentFlowChainId), flowChainMap.get(parentFlowChainId), flowTriggerUserCrn);
                }
                triggerParentFlowChain(flowChainId, flowTriggerUserCrn, contextParams, operationType, finalizerCallback);
            }
        }
    }
}
Also used : FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable)

Example 14 with FlowTriggerEventQueue

use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.

the class FlowChains method putFlowChain.

public void putFlowChain(String flowChainId, String parentFlowChainId, FlowTriggerEventQueue flowChain) {
    if (parentFlowChainId != null) {
        FlowTriggerEventQueue parentFlowChain = flowChainMap.get(parentFlowChainId);
        if (parentFlowChain != null) {
            flowChain = new FlowTriggerEventQueue(parentFlowChain.getFlowChainName() + "/" + flowChain.getFlowChainName(), flowChain.getTriggerEvent(), flowChain.getQueue());
            flowChain.setParentFlowChainId(parentFlowChainId);
        }
    }
    flowChainMap.put(flowChainId, flowChain);
}
Also used : FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue)

Example 15 with FlowTriggerEventQueue

use of com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue in project cloudbreak by hortonworks.

the class HelloWorldFlowChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(BaseFlowEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedDeque<>();
    flowEventChain.add(new BaseFlowEvent(HELLOWORLD_TRIGGER_EVENT.event(), event.getResourceId(), event.getResourceCrn(), event.accepted()));
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : BaseFlowEvent(com.sequenceiq.flow.reactor.api.event.BaseFlowEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Aggregations

FlowTriggerEventQueue (com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue)52 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)35 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)26 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)15 Test (org.junit.Test)10 Test (org.junit.jupiter.api.Test)9 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)5 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)4 TerminationEvent (com.sequenceiq.cloudbreak.reactor.api.event.stack.TerminationEvent)4 ClusterTerminationEvent (com.sequenceiq.cloudbreak.core.flow2.cluster.termination.ClusterTerminationEvent)3 StackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackDownscaleTriggerEvent)3 StackSyncTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackSyncTriggerEvent)3 StackTerminationEvent (com.sequenceiq.cloudbreak.core.flow2.stack.termination.StackTerminationEvent)3 DatalakeResizeRecoveryFlowChainStartEvent (com.sequenceiq.datalake.flow.detach.event.DatalakeResizeRecoveryFlowChainStartEvent)3 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)2 Payload (com.sequenceiq.cloudbreak.common.event.Payload)2 ClusterAndStackDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterAndStackDownscaleTriggerEvent)2 ClusterDownscaleTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.ClusterDownscaleTriggerEvent)2