use of com.sequenceiq.cloudbreak.exception.FlowNotAcceptedException in project cloudbreak by hortonworks.
the class EventSender method doSend.
private FlowIdentifier doSend(BaseFlowEvent event, Event.Headers headers, String resourceName) {
Event<BaseFlowEvent> eventWithErrHandler = eventFactory.createEventWithErrHandler(new HashMap<>(headers.asMap()), event);
reactor.notify(event.selector(), eventWithErrHandler);
Promise<AcceptResult> accepted = eventWithErrHandler.getData().accepted();
String resourceCrn = event.getResourceCrn();
if (accepted != null) {
try {
FlowAcceptResult acceptResult = (FlowAcceptResult) accepted.await(TIMEOUT, TimeUnit.SECONDS);
return createFlowIdentifier(acceptResult, resourceCrn);
} catch (InterruptedException e) {
throw new IllegalStateException(e.getMessage());
}
}
if (headers.contains(FLOW_ID)) {
return new FlowIdentifier(FlowType.FLOW, headers.get(FLOW_ID));
} else if (headers.contains(FLOW_CHAIN_ID)) {
return new FlowIdentifier(FlowType.FLOW_CHAIN, headers.get(FLOW_CHAIN_ID));
}
LOGGER.error("Accepted is null, header does not contains flow or flow chain id, event: {}, header: {}", event, headers);
reactorReporter.logErrorReport();
throw new FlowNotAcceptedException(String.format("Timeout happened when trying to start the flow for stack %s.", resourceCrn));
}
use of com.sequenceiq.cloudbreak.exception.FlowNotAcceptedException in project cloudbreak by hortonworks.
the class ReactorNotifier method checkFlowStatus.
private FlowIdentifier checkFlowStatus(Event<? extends Acceptable> event, String identifier) {
try {
FlowAcceptResult accepted = (FlowAcceptResult) event.getData().accepted().await(WAIT_FOR_ACCEPT, TimeUnit.SECONDS);
if (accepted == null) {
LOGGER.error("Event not accepted: {}", event);
reactorReporter.logErrorReport();
throw new FlowNotAcceptedException(String.format("Timeout happened when trying to start the flow for stack %s.", identifier));
}
switch(accepted.getResultType()) {
case ALREADY_EXISTING_FLOW:
reactorReporter.logErrorReport();
throw new FlowsAlreadyRunningException(String.format("Request not allowed, cluster '%s' already has a running operation. " + "Running operation(s): [%s]", identifier, flowNameFormatService.formatFlows(accepted.getAlreadyRunningFlows())));
case RUNNING_IN_FLOW:
return new FlowIdentifier(FlowType.FLOW, accepted.getAsFlowId());
case RUNNING_IN_FLOW_CHAIN:
return new FlowIdentifier(FlowType.FLOW_CHAIN, accepted.getAsFlowChainId());
default:
throw new IllegalStateException("Unsupported accept result type: " + accepted.getClass());
}
} catch (InterruptedException e) {
throw new CloudbreakApiException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.exception.FlowNotAcceptedException in project cloudbreak by hortonworks.
the class SdxReactorFlowManager method notify.
private FlowIdentifier notify(String selector, SdxEvent acceptable, String identifier) {
Map<String, Object> flowTriggerUserCrnHeader = Map.of(FlowConstants.FLOW_TRIGGER_USERCRN, acceptable.getUserId());
Event<Acceptable> event = eventFactory.createEventWithErrHandler(flowTriggerUserCrnHeader, acceptable);
reactor.notify(selector, event);
try {
FlowAcceptResult accepted = (FlowAcceptResult) event.getData().accepted().await(WAIT_FOR_ACCEPT, TimeUnit.SECONDS);
if (accepted == null) {
throw new FlowNotAcceptedException(String.format("Timeout happened when trying to start the flow for sdx cluster %s.", event.getData().getResourceId()));
} else {
switch(accepted.getResultType()) {
case ALREADY_EXISTING_FLOW:
throw new FlowsAlreadyRunningException(String.format("Request not allowed, datalake cluster '%s' already has a running operation. " + "Running operation(s): [%s]", identifier, flowNameFormatService.formatFlows(accepted.getAlreadyRunningFlows())));
case RUNNING_IN_FLOW:
return new FlowIdentifier(FlowType.FLOW, accepted.getAsFlowId());
case RUNNING_IN_FLOW_CHAIN:
return new FlowIdentifier(FlowType.FLOW_CHAIN, accepted.getAsFlowChainId());
default:
throw new IllegalStateException("Unsupported accept result type: " + accepted.getClass());
}
}
} catch (InterruptedException e) {
throw new CloudbreakApiException(e.getMessage());
}
}
Aggregations