use of com.sequenceiq.flow.core.exception.FlowNotTriggerableException 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.flow.core.exception.FlowNotTriggerableException in project cloudbreak by hortonworks.
the class Flow2HandlerTest method testFlowChainFailureOnNotTriggerableFlowCreatesFailedFlow.
@Test
public void testFlowChainFailureOnNotTriggerableFlowCreatesFailedFlow() throws TransactionExecutionException {
Map<String, Object> headers = new HashMap<>();
headers.put(FlowConstants.FLOW_CHAIN_ID, FLOW_CHAIN_ID);
headers.put(FlowConstants.FLOW_TRIGGER_USERCRN, FLOW_TRIGGER_USERCRN);
dummyEvent = new Event<>(new Headers(headers), payload);
dummyEvent.setKey("KEY");
BDDMockito.<FlowConfiguration<?>>given(flowConfigurationMap.get(any())).willReturn(flowConfig);
given(flowConfig.getFlowTriggerCondition()).willReturn(flowTriggerCondition);
given(flowTriggerCondition.isFlowTriggerable(anyLong())).willReturn(new FlowTriggerConditionResult("Not triggerable."));
FlowNotTriggerableException exception = assertThrows(FlowNotTriggerableException.class, () -> underTest.accept(dummyEvent));
assertEquals("Not triggerable.", exception.getMessage());
flowLogService.save(any(), eq(FLOW_CHAIN_ID), any(), eq(payload), any(), eq(flowConfig.getClass()), eq(FlowStateConstants.INIT_STATE));
flowLogService.close(eq(payload.getResourceId()), any(), eq(true));
flowChains.removeFullFlowChain(FLOW_CHAIN_ID, false);
}
use of com.sequenceiq.flow.core.exception.FlowNotTriggerableException in project cloudbreak by hortonworks.
the class UpgradeCcmFlowIntegrationTest method testCcmUpgradeTriggerNotAllowed.
@Test
public void testCcmUpgradeTriggerNotAllowed() {
StackStatus stackStatus = new StackStatus(stack, Status.CREATE_FAILED, "no reason at all", DetailedStackStatus.PROVISION_FAILED);
stack.setStackStatus(stackStatus);
FlowNotTriggerableException actualException = Assertions.assertThrows(FlowNotTriggerableException.class, this::triggerFlow);
Assertions.assertTrue(actualException.getMessage().contains("Cluster Connectivity Manager upgrade could not " + "be triggered, because the cluster's state is not available."), "FlowNotTriggerableException exception message is not right");
}
use of com.sequenceiq.flow.core.exception.FlowNotTriggerableException in project cloudbreak by hortonworks.
the class CcmUpgradeFlowIntegrationTest method testCcmUpgradeTriggerNotAllowed.
@Test
public void testCcmUpgradeTriggerNotAllowed() {
StackStatus stackStatus = new StackStatus(stack, Status.CREATE_FAILED, "no reason at all", DetailedStackStatus.PROVISION_FAILED);
stack.setStackStatus(stackStatus);
FlowNotTriggerableException actualException = Assertions.assertThrows(FlowNotTriggerableException.class, () -> triggerFlow());
Assertions.assertTrue(actualException.getMessage().contains("Cluster Connectivity Manager upgrade could not " + "be triggered, because the cluster's state is not available."), "FlowNotTriggerableException exception message is not right");
}
Aggregations