use of org.pentaho.di.engine.api.remote.Message in project pentaho-kettle by pentaho.
the class MessageEventService method getHandlersFor.
public List<MessageEventHandler> getHandlersFor(final Message eventType) {
List<MessageEventHandler> toRet = null;
if (eventType == null || registeredHandlers.isEmpty()) {
return toRet;
}
MessageComparator msgComparator = new MessageComparator();
for (Message e : registeredHandlers.keySet()) {
if (msgComparator.compare(e, eventType) == 0) {
toRet = registeredHandlers.get(e);
}
}
return toRet;
}
use of org.pentaho.di.engine.api.remote.Message 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