use of com.sequenceiq.cloudbreak.cloud.event.Payload in project cloudbreak by hortonworks.
the class DisableOnGCPRestartAction method restart.
@Override
public void restart(String flowId, String flowChainId, String event, Object payload) {
Payload stackPayload = (Payload) payload;
Stack stack = stackService.getById(stackPayload.getStackId());
if (stack.getPlatformVariant().equals(GCP)) {
flowLogService.terminate(stackPayload.getStackId(), flowId);
} else {
restart(flowId, flowChainId, event, payload, stack);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.Payload in project cloudbreak by hortonworks.
the class FillInMemoryStateStoreRestartAction method restart.
@Override
public void restart(String flowId, String flowChainId, String event, Object payload) {
Payload stackPayload = (Payload) payload;
Stack stack = stackService.getByIdWithLists(stackPayload.getStackId());
restart(flowId, flowChainId, event, payload, stack);
}
use of com.sequenceiq.cloudbreak.cloud.event.Payload in project cloudbreak by hortonworks.
the class AbstractStackDownscaleAction method extractInstanceIds.
private Set<String> extractInstanceIds(P payload, Map<Object, Object> variables, Stack stack) {
if (payload instanceof StackDownscaleTriggerEvent) {
StackDownscaleTriggerEvent ssc = (StackDownscaleTriggerEvent) payload;
Set<String> instanceIds;
if (ssc.getHostNames() == null || ssc.getHostNames().isEmpty()) {
Map<String, String> unusedInstanceIds = stackScalingService.getUnusedInstanceIds(ssc.getInstanceGroup(), ssc.getAdjustment(), stack);
instanceIds = new HashSet<>(unusedInstanceIds.keySet());
} else {
Set<InstanceMetaData> imds = stack.getInstanceGroupByInstanceGroupName(ssc.getInstanceGroup()).getInstanceMetaData();
instanceIds = imds.stream().filter(imd -> ssc.getHostNames().contains(imd.getDiscoveryFQDN())).map(InstanceMetaData::getInstanceId).collect(Collectors.toSet());
}
variables.put(INSTANCEIDS, instanceIds);
return instanceIds;
}
return getInstanceIds(variables);
}
use of com.sequenceiq.cloudbreak.cloud.event.Payload in project cloudbreak by hortonworks.
the class StackStopRestartAction 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.STOP_REQUESTED, stack.getStatusReason());
super.restart(flowId, flowChainId, event, payload);
}
use of com.sequenceiq.cloudbreak.cloud.event.Payload in project cloudbreak by hortonworks.
the class Flow2Handler method accept.
@Override
public void accept(Event<? extends Payload> event) {
String key = (String) event.getKey();
Payload payload = event.getData();
String flowId = getFlowId(event);
String flowChainId = getFlowChainId(event);
switch(key) {
case FLOW_CANCEL:
cancelRunningFlows(payload.getStackId());
break;
case FLOW_FINAL:
finalizeFlow(flowId, flowChainId, payload.getStackId());
break;
default:
if (flowId == null) {
LOGGER.debug("flow trigger arrived: key: {}, payload: {}", key, payload);
FlowConfiguration<?> flowConfig = flowConfigurationMap.get(key);
if (flowConfig != null && flowConfig.getFlowTriggerCondition().isFlowTriggerable(payload.getStackId())) {
if (!isFlowAcceptable(key, payload)) {
LOGGER.info("Flow operation not allowed, other flow is running. Stack ID {}, event {}", payload.getStackId(), key);
return;
}
flowId = UUID.randomUUID().toString();
Flow flow = flowConfig.createFlow(flowId, payload.getStackId());
flow.initialize();
flowLogService.save(flowId, flowChainId, key, payload, null, flowConfig.getClass(), flow.getCurrentState());
acceptFlow(payload);
pruneMDCContext(flowId);
runningFlows.put(flow, flowChainId);
flow.sendEvent(key, payload);
}
} else {
LOGGER.debug("flow control event arrived: key: {}, flowid: {}, payload: {}", key, flowId, payload);
Flow flow = runningFlows.get(flowId);
if (flow != null) {
flowLogService.save(flowId, flowChainId, key, payload, flow.getVariables(), flow.getFlowConfigClass(), flow.getCurrentState());
flow.sendEvent(key, payload);
} else {
LOGGER.info("Cancelled flow finished running. Stack ID {}, flow ID {}, event {}", payload.getStackId(), flowId, key);
}
}
break;
}
}
Aggregations