use of org.pentaho.di.engine.api.events.PDIEvent in project pentaho-kettle by pentaho.
the class TransWebSocketEngineAdapter method wireStatusToTransListeners.
private void wireStatusToTransListeners() throws KettleException {
messageEventService.addHandler(Util.getTransformationStatusEvent(), new MessageEventHandler() {
@Override
public void execute(Message message) throws MessageEventHandlerExecutionException {
PDIEvent<RemoteSource, Status> transStatusEvent = (PDIEvent<RemoteSource, Status>) message;
addStepPerformanceSnapShot();
getTransListeners().forEach(l -> {
try {
switch(transStatusEvent.getData()) {
case RUNNING:
l.transStarted(TransWebSocketEngineAdapter.this);
l.transActive(TransWebSocketEngineAdapter.this);
break;
case PAUSED:
break;
case STOPPED:
break;
case FAILED:
case FINISHED:
l.transFinished(TransWebSocketEngineAdapter.this);
setFinished(true);
break;
}
} catch (KettleException e) {
throw new RuntimeException(e);
}
});
}
@Override
public String getIdentifier() {
return TRANSFORMATION_STATUS;
}
});
messageEventService.addHandler(Util.getTransformationErrorEvent(), new MessageEventHandler() {
@Override
public void execute(Message message) throws MessageEventHandlerExecutionException {
Throwable throwable = ((PDIEvent<RemoteSource, LogEntry>) message).getData().getThrowable();
getLogChannel().logError("Error Executing Transformation", throwable);
errors.incrementAndGet();
finishProcess(true);
}
@Override
public String getIdentifier() {
return TRANSFORMATION_ERROR;
}
});
messageEventService.addHandler(Util.getStopMessage(), new MessageEventHandler() {
@Override
public void execute(Message message) throws MessageEventHandlerExecutionException {
StopMessage stopMessage = (StopMessage) message;
if (stopMessage.sessionWasKilled() || stopMessage.operationFailed()) {
getLogChannel().logError("Finalizing execution: " + stopMessage.getReasonPhrase());
} else {
getLogChannel().logBasic("Finalizing execution: " + stopMessage.getReasonPhrase());
}
finishProcess(false);
try {
getDaemonEndpoint().close(stopMessage.getReasonPhrase());
} catch (KettleException e) {
getLogChannel().logError("Error finalizing", e);
}
// let's shutdown the session monitor thread
closeSessionMonitor();
// Signal for the the waitUntilFinished blocker...
transFinishedSignal.countDown();
}
@Override
public String getIdentifier() {
return TRANSFORMATION_STOP;
}
});
}
Aggregations