use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredEvent in project cloudbreak by hortonworks.
the class CloudbreakEventController method getStructuredEventsZip.
@Override
public Response getStructuredEventsZip(Long stackId) {
List<StructuredEvent> events = getStructuredEventsForStack(stackId);
StreamingOutput streamingOutput = output -> {
try (ZipOutputStream zipOutputStream = new ZipOutputStream(output)) {
zipOutputStream.putNextEntry(new ZipEntry("struct-events.json"));
zipOutputStream.write(JsonUtil.writeValueAsString(events).getBytes());
zipOutputStream.closeEntry();
}
};
return Response.ok(streamingOutput).header("content-disposition", "attachment; filename = struct-events.zip").build();
}
use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredEvent 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;
}
}
use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredEvent 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;
}
Aggregations