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);
}
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);
}
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()));
}
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));
}
}
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);
}
Aggregations