Search in sources :

Example 1 with RemoteSource

use of org.pentaho.di.engine.api.remote.RemoteSource in project pentaho-kettle by pentaho.

the class MessageEventServiceTest method testOperationFireEventThrowException.

@Test(expected = MessageEventFireEventException.class)
public void testOperationFireEventThrowException() throws KettleException {
    addHandlers(operationMessageEvent, messageEventHandler, messageEventHandler2);
    doThrow(new RuntimeException("Test")).when(messageEventHandler).execute(any(Message.class));
    LogEvent logEvent = new LogEvent<>(new RemoteSource(ModelType.OPERATION, "Operation_ID"), logEntry);
    messageEventService.fireEvent(logEvent);
    verify(messageEventHandler, never()).execute(logEvent);
    verify(messageEventHandler2).execute(logEvent);
}
Also used : StopMessage(org.pentaho.di.engine.api.remote.StopMessage) Message(org.pentaho.di.engine.api.remote.Message) RemoteSource(org.pentaho.di.engine.api.remote.RemoteSource) LogEvent(org.pentaho.di.engine.api.events.LogEvent) Test(org.junit.Test)

Example 2 with RemoteSource

use of org.pentaho.di.engine.api.remote.RemoteSource in project pentaho-kettle by pentaho.

the class MessageEventServiceTest method testTransformationFireEvent.

@Test
public void testTransformationFireEvent() throws Exception {
    addHandlers(transformationMessageEvent, messageEventHandler, messageEventHandler2);
    LogEvent logEvent = new LogEvent<>(new RemoteSource(ModelType.TRANSFORMATION, "Operation_ID"), logEntry);
    messageEventService.fireEvent(logEvent);
    verify(messageEventHandler).execute(logEvent);
    verify(messageEventHandler2).execute(logEvent);
}
Also used : RemoteSource(org.pentaho.di.engine.api.remote.RemoteSource) LogEvent(org.pentaho.di.engine.api.events.LogEvent) Test(org.junit.Test)

Example 3 with RemoteSource

use of org.pentaho.di.engine.api.remote.RemoteSource 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;
        }
    });
}
Also used : Status(org.pentaho.di.engine.api.reporting.Status) Transformation(org.pentaho.di.engine.api.model.Transformation) Result(org.pentaho.di.core.Result) Trans(org.pentaho.di.trans.Trans) TransMetaConverter(org.pentaho.di.trans.ael.adapters.TransMetaConverter) Arrays(java.util.Arrays) LogLevel(org.pentaho.di.engine.api.reporting.LogLevel) KettleException(org.pentaho.di.core.exception.KettleException) HashMap(java.util.HashMap) Operation(org.pentaho.di.engine.api.model.Operation) Function(java.util.function.Function) ArrayList(java.util.ArrayList) MessageEventHandler(org.pentaho.di.trans.ael.websocket.handler.MessageEventHandler) LogEntry(org.pentaho.di.engine.api.reporting.LogEntry) TransMeta(org.pentaho.di.trans.TransMeta) Collectors.toMap(java.util.stream.Collectors.toMap) Status(org.pentaho.di.engine.api.reporting.Status) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MessageEventHandlerExecutionException(org.pentaho.di.trans.ael.websocket.exception.MessageEventHandlerExecutionException) Map(java.util.Map) ExecutorService(java.util.concurrent.ExecutorService) StepInterface(org.pentaho.di.trans.step.StepInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) StopMessage(org.pentaho.di.engine.api.remote.StopMessage) ExecutionRequest(org.pentaho.di.engine.api.remote.ExecutionRequest) ResourceEntry(org.pentaho.di.resource.ResourceEntry) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) TimeUnit(java.util.concurrent.TimeUnit) RemoteSource(org.pentaho.di.engine.api.remote.RemoteSource) CountDownLatch(java.util.concurrent.CountDownLatch) StepMetaDataCombi(org.pentaho.di.trans.step.StepMetaDataCombi) List(java.util.List) Principal(java.security.Principal) HandlerRegistrationException(org.pentaho.di.trans.ael.websocket.exception.HandlerRegistrationException) PDIEvent(org.pentaho.di.engine.api.events.PDIEvent) Optional(java.util.Optional) Message(org.pentaho.di.engine.api.remote.Message) ActingPrincipal(org.pentaho.di.engine.model.ActingPrincipal) RowProducer(org.pentaho.di.trans.RowProducer) KettleException(org.pentaho.di.core.exception.KettleException) StopMessage(org.pentaho.di.engine.api.remote.StopMessage) Message(org.pentaho.di.engine.api.remote.Message) RemoteSource(org.pentaho.di.engine.api.remote.RemoteSource) StopMessage(org.pentaho.di.engine.api.remote.StopMessage) MessageEventHandlerExecutionException(org.pentaho.di.trans.ael.websocket.exception.MessageEventHandlerExecutionException) MessageEventHandler(org.pentaho.di.trans.ael.websocket.handler.MessageEventHandler) PDIEvent(org.pentaho.di.engine.api.events.PDIEvent)

Example 4 with RemoteSource

use of org.pentaho.di.engine.api.remote.RemoteSource in project pentaho-kettle by pentaho.

the class MessageEventServiceTest method testOperationFireEvent.

@Test
public void testOperationFireEvent() throws KettleException {
    addHandlers(operationMessageEvent, messageEventHandler, messageEventHandler2);
    LogEvent logEvent = new LogEvent<>(new RemoteSource(ModelType.OPERATION, "Operation_ID"), logEntry);
    messageEventService.fireEvent(logEvent);
    verify(messageEventHandler).execute(logEvent);
    verify(messageEventHandler2).execute(logEvent);
}
Also used : RemoteSource(org.pentaho.di.engine.api.remote.RemoteSource) LogEvent(org.pentaho.di.engine.api.events.LogEvent) Test(org.junit.Test)

Aggregations

RemoteSource (org.pentaho.di.engine.api.remote.RemoteSource)4 Test (org.junit.Test)3 LogEvent (org.pentaho.di.engine.api.events.LogEvent)3 Message (org.pentaho.di.engine.api.remote.Message)2 StopMessage (org.pentaho.di.engine.api.remote.StopMessage)2 Maps (com.google.common.collect.Maps)1 Principal (java.security.Principal)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1