Search in sources :

Example 1 with FlowDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails in project cloudbreak by hortonworks.

the class FlowStructuredEventHandler method stateMachineStopped.

@Override
public void stateMachineStopped(StateMachine<S, E> stateMachine) {
    if (!stateMachine.isComplete()) {
        State<S, E> currentState = stateMachine.getState();
        Long currentTime = System.currentTimeMillis();
        String fromId = currentState != null ? currentState.getId().toString() : "unknown";
        FlowDetails flowDetails = new FlowDetails("", flowType, "", flowId, fromId, "unknown", "FLOW_CANCEL", lastStateChange == -1L ? -1L : currentTime - lastStateChange);
        StructuredEvent structuredEvent = structuredFlowEventFactory.createStucturedFlowEvent(stackId, flowDetails, true);
        structuredEventClient.sendStructuredEvent(structuredEvent);
        lastStateChange = currentTime;
    }
}
Also used : StructuredEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredEvent) FlowDetails(com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails)

Example 2 with FlowDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails in project cloudbreak by hortonworks.

the class FlowStructuredEventHandler method transition.

@Override
public void transition(Transition<S, E> transition) {
    State<S, E> from = transition.getSource();
    State<S, E> to = transition.getTarget();
    Trigger<S, E> trigger = transition.getTrigger();
    Long currentTime = System.currentTimeMillis();
    String fromId = from != null ? from.getId().toString() : "unknown";
    String toId = to != null ? to.getId().toString() : "unknown";
    String eventId = trigger != null ? trigger.getEvent().toString() : "unknown";
    Boolean detailed = toId.equals(initState.toString()) || toId.equals(finalState.toString());
    FlowDetails flowDetails = new FlowDetails("", flowType, "", flowId, fromId, toId, eventId, lastStateChange == -1L ? -1L : currentTime - lastStateChange);
    StructuredEvent structuredEvent;
    if (exception == null) {
        structuredEvent = structuredFlowEventFactory.createStucturedFlowEvent(stackId, flowDetails, detailed);
    } else {
        structuredEvent = structuredFlowEventFactory.createStucturedFlowEvent(stackId, flowDetails, true, exception);
        exception = null;
    }
    structuredEventClient.sendStructuredEvent(structuredEvent);
    lastStateChange = currentTime;
}
Also used : StructuredEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredEvent) FlowDetails(com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails)

Aggregations

FlowDetails (com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails)2 StructuredEvent (com.sequenceiq.cloudbreak.structuredevent.event.StructuredEvent)2