use of org.pentaho.di.engine.api.reporting.LogEntry in project pentaho-kettle by pentaho.
the class MessageEncoderDecoderTest method testErrorEvent.
@Test
public void testErrorEvent() throws Exception {
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("key", "value");
LogEntry logEntry = new LogEntry.LogEntryBuilder().withMessage("log message").withLogLevel(LogLevel.DEBUG).withTimestamp(new Date()).withExtras(hashMap).build();
ErrorEvent errorEvent = new ErrorEvent(new RemoteSource(ModelType.TRANSFORMATION), logEntry);
String sMessage = encoder.encode(errorEvent);
Message decodeMessage = decoder.decode(sMessage);
assertTrue(((RemoteSource) errorEvent.getSource()).getModelType() == ((RemoteSource) ((ErrorEvent) decodeMessage).getSource()).getModelType());
LogEntry decodeLogEntry = (LogEntry) ((ErrorEvent) decodeMessage).getData();
assertTrue(logEntry.getMessage().equals(decodeLogEntry.getMessage()));
assertTrue(logEntry.getLogLogLevel().equals(decodeLogEntry.getLogLogLevel()));
assertTrue(logEntry.getTimestamp().getTime() == decodeLogEntry.getTimestamp().getTime());
assertTrue(logEntry.getExtras().hashCode() == decodeLogEntry.getExtras().hashCode());
}
use of org.pentaho.di.engine.api.reporting.LogEntry 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