use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class ReactorFlowManager method triggerClusterUpscale.
public FlowIdentifier triggerClusterUpscale(Long stackId, HostGroupAdjustmentV4Request hostGroupAdjustment) {
String selector = CLUSTER_UPSCALE_TRIGGER_EVENT.event();
Acceptable event = new ClusterScaleTriggerEvent(selector, stackId, Collections.singletonMap(hostGroupAdjustment.getHostGroup(), hostGroupAdjustment.getScalingAdjustment()), null, null);
return reactorNotifier.notify(stackId, selector, event);
}
use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class ReactorFlowManager method triggerClusterDownscale.
public FlowIdentifier triggerClusterDownscale(Long stackId, HostGroupAdjustmentV4Request hostGroupAdjustment) {
String selector = FlowChainTriggers.FULL_DOWNSCALE_TRIGGER_EVENT;
ScalingType scalingType = hostGroupAdjustment.getWithStackUpdate() ? ScalingType.DOWNSCALE_TOGETHER : ScalingType.DOWNSCALE_ONLY_CLUSTER;
Acceptable event = new ClusterAndStackDownscaleTriggerEvent(selector, stackId, Collections.singletonMap(hostGroupAdjustment.getHostGroup(), hostGroupAdjustment.getScalingAdjustment()), scalingType);
return reactorNotifier.notify(stackId, selector, event);
}
use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class ReactorNotifier method notify.
public FlowIdentifier notify(Long stackId, String selector, Acceptable acceptable, Function<Long, Stack> getStackFn) {
Event<Acceptable> event = eventFactory.createEventWithErrHandler(eventParameterFactory.createEventParameters(stackId), acceptable);
Stack stack = getStackFn.apply(event.getData().getResourceId());
Optional.ofNullable(stack).map(Stack::getStatus).ifPresent(isTriggerAllowedInMaintenance(selector));
reactorReporter.logInfoReport();
reactor.notify(selector, event);
return checkFlowStatus(event, stack.getName());
}
use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class Flow2Handler method doAccept.
private void doAccept(Event<? extends Payload> event, String key, Payload payload, String flowChainId, String flowChainType, FlowParameters flowParameters) {
try {
if (FLOW_CANCEL.equals(key)) {
cancelRunningFlows(payload.getResourceId());
} else if (FLOW_FINAL.equals(key)) {
finalizeFlow(flowParameters, flowChainId, payload.getResourceId(), getContextParams(event));
} else if (flowParameters.getFlowId() == null) {
AcceptResult result = handleNewFlowRequest(key, payload, flowParameters, flowChainId, flowChainType, getContextParams(event));
LOGGER.info("Create new flow result {}", result);
if (isAcceptablePayload(payload)) {
((Acceptable) payload).accepted().accept(result);
}
} else {
handleFlowControlEvent(key, payload, flowParameters, flowChainId);
}
} catch (FlowNotTriggerableException e) {
LOGGER.error("Failed to handle flow event.", e);
if (isAcceptablePayload(payload)) {
((Acceptable) payload).accepted().onError(e);
} else {
throw e;
}
} catch (CloudbreakServiceException e) {
LOGGER.error("Failed to handle flow event.", e);
throw e;
} catch (Exception e) {
LOGGER.error("Failed to handle flow event.", e);
throw new CloudbreakServiceException(e);
}
}
use of com.sequenceiq.cloudbreak.common.event.Acceptable in project cloudbreak by hortonworks.
the class FlowPayloadConstructorTest method constructorAccessible.
@Test
void constructorAccessible() {
Reflections reflections = new Reflections("com.sequenceiq", new SubTypesScanner(true));
Set<Class<? extends Acceptable>> eventClasses = reflections.getSubTypesOf(Acceptable.class);
eventClasses.stream().filter(c -> !c.isInterface() && !isAbstract(c) && !c.isAnonymousClass() && !c.isLocalClass() && !c.isMemberClass()).filter(c -> !c.getName().endsWith("Test")).forEach(this::checkForConstructor);
}
Aggregations