Search in sources :

Example 1 with Metrics

use of org.pentaho.di.engine.api.reporting.Metrics in project pentaho-kettle by pentaho.

the class MessageEncoderDecoderTest method testOperationRemoteSource.

@Test
public void testOperationRemoteSource() throws Exception {
    RemoteSource step = new RemoteSource(ModelType.OPERATION, "step");
    Metrics metrics = new Metrics(1, 2, 3, 4);
    Message metricEvent = new MetricsEvent<>(step, metrics);
    String sMessage = encoder.encode(metricEvent);
    Message decodeMessage = decoder.decode(sMessage);
    assertTrue(((RemoteSource) step).getModelType() == ((RemoteSource) ((MetricsEvent) decodeMessage).getSource()).getModelType());
    assertTrue(((RemoteSource) step).getId().equals(((RemoteSource) ((MetricsEvent) decodeMessage).getSource()).getId()));
}
Also used : Metrics(org.pentaho.di.engine.api.reporting.Metrics) MetricsEvent(org.pentaho.di.engine.api.events.MetricsEvent) Test(org.junit.Test)

Example 2 with Metrics

use of org.pentaho.di.engine.api.reporting.Metrics in project pentaho-kettle by pentaho.

the class MessageEncoderDecoderTest method testTransformationRemoteSource.

@Test
public void testTransformationRemoteSource() throws Exception {
    RemoteSource step = new RemoteSource(ModelType.TRANSFORMATION);
    Metrics metrics = new Metrics(1, 2, 3, 4);
    Message statusEvent = new StatusEvent<>(step, Status.FAILED);
    String sMessage = encoder.encode(statusEvent);
    Message decodeMessage = decoder.decode(sMessage);
    assertTrue(((RemoteSource) step).getModelType() == ((RemoteSource) ((StatusEvent) decodeMessage).getSource()).getModelType());
    assertNull(((RemoteSource) ((StatusEvent) decodeMessage).getSource()).getId());
}
Also used : Metrics(org.pentaho.di.engine.api.reporting.Metrics) StatusEvent(org.pentaho.di.engine.api.events.StatusEvent) Test(org.junit.Test)

Example 3 with Metrics

use of org.pentaho.di.engine.api.reporting.Metrics in project pentaho-kettle by pentaho.

the class MessageEncoderDecoderTest method assertMetricsEvent.

private void assertMetricsEvent(MetricsEvent expected, MetricsEvent actual) {
    // Assert Operation
    Operation expectedOperation = (Operation) expected.getSource();
    Operation actualOperation = (Operation) actual.getSource();
    assertThat(expectedOperation.getId(), equalTo(actualOperation.getId()));
    assertThat(expectedOperation.getFrom().size(), equalTo(actualOperation.getFrom().size()));
    assertThat(expectedOperation.getTo().size(), equalTo(actualOperation.getTo().size()));
    // Assert Metrics
    Metrics expectedMetrics = (Metrics) expected.getData();
    Metrics actualMetrics = (Metrics) actual.getData();
    assertThat(expectedMetrics.getIn(), equalTo(actualMetrics.getIn()));
    assertThat(expectedMetrics.getOut(), equalTo(actualMetrics.getOut()));
    assertThat(expectedMetrics.getDropped(), equalTo(actualMetrics.getDropped()));
    assertThat(expectedMetrics.getInFlight(), equalTo(actualMetrics.getInFlight()));
}
Also used : Metrics(org.pentaho.di.engine.api.reporting.Metrics) Operation(org.pentaho.di.engine.api.model.Operation)

Example 4 with Metrics

use of org.pentaho.di.engine.api.reporting.Metrics in project pentaho-kettle by pentaho.

the class MessageEncoderDecoderTest method metricsEvent.

private MetricsEvent metricsEvent() {
    Operation step1 = new TestOperation("step2");
    Operation step2 = new TestOperation("step2");
    Operation step3 = new TestOperation("step2");
    step1.getTo().add(step2);
    step2.getFrom().add(step1);
    step2.getTo().add(step3);
    step3.getFrom().add(step2);
    Metrics metrics = new Metrics(1, 2, 3, 4);
    return new MetricsEvent<>(step2, metrics);
}
Also used : Metrics(org.pentaho.di.engine.api.reporting.Metrics) MetricsEvent(org.pentaho.di.engine.api.events.MetricsEvent) Operation(org.pentaho.di.engine.api.model.Operation)

Aggregations

Metrics (org.pentaho.di.engine.api.reporting.Metrics)4 Test (org.junit.Test)2 MetricsEvent (org.pentaho.di.engine.api.events.MetricsEvent)2 Operation (org.pentaho.di.engine.api.model.Operation)2 StatusEvent (org.pentaho.di.engine.api.events.StatusEvent)1