Search in sources :

Example 46 with FlowTriggerEventQueue

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

the class RecovereyTeardownFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(TerminationEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new TerminationEvent(ClusterTerminationEvent.TERMINATION_EVENT.event(), event.getResourceId(), TerminationType.RECOVERY, event.accepted()));
    flowEventChain.add(new TerminationEvent(StackTerminationEvent.TERMINATION_EVENT.event(), event.getResourceId(), TerminationType.RECOVERY, event.accepted()));
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) ClusterTerminationEvent(com.sequenceiq.cloudbreak.core.flow2.cluster.termination.ClusterTerminationEvent) StackTerminationEvent(com.sequenceiq.cloudbreak.core.flow2.stack.termination.StackTerminationEvent) TerminationEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.TerminationEvent)

Example 47 with FlowTriggerEventQueue

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

the class StackRepairFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(StackRepairTriggerEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedDeque<>();
    flowEventChain.add(new StackEvent(FlowChainTriggers.FULL_SYNC_TRIGGER_EVENT, event.getResourceId(), event.accepted()));
    UnhealthyInstances unhealthyInstances = event.getUnhealthyInstances();
    String fullUpscaleTriggerEvent = FlowChainTriggers.FULL_UPSCALE_TRIGGER_EVENT;
    CloudPlatformVariant variant = stackService.getPlatformVariantByStackId(event.getResourceId());
    for (String hostGroupName : unhealthyInstances.getHostGroups()) {
        List<String> instances = unhealthyInstances.getInstancesForGroup(hostGroupName);
        flowEventChain.add(new StackAndClusterUpscaleTriggerEvent(fullUpscaleTriggerEvent, event.getResourceId(), Collections.singletonMap(hostGroupName, instances.size()), ScalingType.UPSCALE_TOGETHER, NetworkScaleDetails.getEmpty(), new AdjustmentTypeWithThreshold(AdjustmentType.EXACT, (long) instances.size()), variant.getVariant().value()));
    }
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : StackAndClusterUpscaleTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackAndClusterUpscaleTriggerEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UnhealthyInstances(com.sequenceiq.cloudbreak.service.stack.repair.UnhealthyInstances) AdjustmentTypeWithThreshold(com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 48 with FlowTriggerEventQueue

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

the class FlowChains method saveAllUnsavedFlowChains.

public void saveAllUnsavedFlowChains(String flowChainId, String flowTriggerUserCrn) {
    List<Pair<String, FlowTriggerEventQueue>> flowTriggerEventQueues = new ArrayList<>();
    while (flowChainId != null && notSavedFlowChains.contains(flowChainId)) {
        String parentFlowChainId = getParentFlowChainId(flowChainId);
        FlowTriggerEventQueue flowTriggerEventQueue = flowChainMap.get(flowChainId);
        if (flowTriggerEventQueue != null) {
            flowTriggerEventQueues.add(Pair.of(flowChainId, flowTriggerEventQueue));
        }
        flowChainId = parentFlowChainId;
    }
    Collections.reverse(flowTriggerEventQueues);
    flowTriggerEventQueues.forEach(chainIdTriggerQueue -> {
        String chainId = chainIdTriggerQueue.getLeft();
        FlowTriggerEventQueue queue = chainIdTriggerQueue.getRight();
        flowLogService.saveChain(chainId, queue.getParentFlowChainId(), queue, flowTriggerUserCrn);
    });
    notSavedFlowChains.removeAll(flowTriggerEventQueues.stream().map(Pair::getLeft).collect(Collectors.toList()));
}
Also used : FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) ArrayList(java.util.ArrayList) Pair(org.apache.commons.lang3.tuple.Pair)

Example 49 with FlowTriggerEventQueue

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

the class FlowChains method getRootTriggerEvent.

public Optional<Pair<String, Payload>> getRootTriggerEvent(String flowChainId) {
    String rootFlowChainId = getRootFlowChainId(flowChainId);
    FlowTriggerEventQueue flowTriggerEventQueue = flowChainMap.get(rootFlowChainId);
    if (flowTriggerEventQueue != null) {
        return Optional.of(Pair.of(rootFlowChainId, flowTriggerEventQueue.getTriggerEvent()));
    }
    Optional<FlowChainLog> initFlowChainLog = flowChainLogService.findRootInitFlowChainLog(flowChainId);
    if (initFlowChainLog.isEmpty()) {
        return Optional.empty();
    }
    LOGGER.info("Found root init flow chain log {} for flow chain {}", initFlowChainLog.get(), flowChainId);
    Payload triggerEvent = FlowLogUtil.tryDeserializeTriggerEvent(initFlowChainLog.get());
    if (triggerEvent == null) {
        return Optional.empty();
    } else {
        return Optional.of(Pair.of(initFlowChainLog.get().getFlowChainId(), triggerEvent));
    }
}
Also used : FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Payload(com.sequenceiq.cloudbreak.common.event.Payload) FlowChainLog(com.sequenceiq.flow.domain.FlowChainLog)

Example 50 with FlowTriggerEventQueue

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

the class RepairFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(RepairEvent event) {
    Set<String> terminatedOrRemovedInstanceIdsSet = new HashSet<>(event.getRepairInstanceIds());
    terminatedOrRemovedInstanceIdsSet.addAll(event.getAdditionalTerminatedInstanceIds());
    ArrayList<String> terminatedOrRemovedInstanceIds = new ArrayList<>(terminatedOrRemovedInstanceIdsSet);
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new ChangePrimaryGatewayEvent(ChangePrimaryGatewayFlowEvent.CHANGE_PRIMARY_GATEWAY_EVENT.event(), event.getResourceId(), terminatedOrRemovedInstanceIds, Boolean.FALSE, event.getOperationId(), event.accepted()));
    flowEventChain.add(new DownscaleEvent(DownscaleFlowEvent.DOWNSCALE_EVENT.event(), event.getResourceId(), terminatedOrRemovedInstanceIds, event.getInstanceCountByGroup(), true, true, false, event.getOperationId()));
    flowEventChain.add(new UpscaleEvent(UpscaleFlowEvent.UPSCALE_EVENT.event(), event.getResourceId(), event.getInstanceCountByGroup(), true, true, false, event.getOperationId()));
    flowEventChain.add(new ChangePrimaryGatewayEvent(ChangePrimaryGatewayFlowEvent.CHANGE_PRIMARY_GATEWAY_EVENT.event(), event.getResourceId(), terminatedOrRemovedInstanceIds, true, event.getOperationId()));
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : DownscaleEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpscaleEvent(com.sequenceiq.freeipa.flow.freeipa.upscale.event.UpscaleEvent) ArrayList(java.util.ArrayList) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) HashSet(java.util.HashSet) ChangePrimaryGatewayEvent(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.ChangePrimaryGatewayEvent)

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