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