Search in sources :

Example 11 with LoggingObjectInterface

use of org.pentaho.di.core.logging.LoggingObjectInterface in project pentaho-kettle by pentaho.

the class MetricsUtil method getAllDurations.

public static List<MetricsDuration> getAllDurations(String parentLogChannelId) {
    List<MetricsDuration> durations = new ArrayList<MetricsDuration>();
    List<String> logChannelIds = LoggingRegistry.getInstance().getLogChannelChildren(parentLogChannelId);
    for (String logChannelId : logChannelIds) {
        LoggingObjectInterface object = LoggingRegistry.getInstance().getLoggingObject(logChannelId);
        if (object != null) {
            durations.addAll(getDurations(logChannelId));
        }
    }
    return durations;
}
Also used : ArrayList(java.util.ArrayList) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface)

Example 12 with LoggingObjectInterface

use of org.pentaho.di.core.logging.LoggingObjectInterface in project pentaho-kettle by pentaho.

the class SubtransExecutorTest method testRunsATrans.

@Test
public void testRunsATrans() throws Exception {
    TransMeta parentMeta = new TransMeta(this.getClass().getResource("subtrans-executor-parent.ktr").getPath(), new Variables());
    TransMeta subMeta = new TransMeta(this.getClass().getResource("subtrans-executor-sub.ktr").getPath(), new Variables());
    LoggingObjectInterface loggingObject = new LoggingObject("anything");
    Trans parentTrans = spy(new Trans(parentMeta, loggingObject));
    SubtransExecutor subtransExecutor = new SubtransExecutor("subtransname", parentTrans, subMeta, true, new TransExecutorParameters(), "Group By");
    RowMetaInterface rowMeta = parentMeta.getStepFields("Data Grid");
    List<RowMetaAndData> rows = Arrays.asList(new RowMetaAndData(rowMeta, "Pentaho", 1L), new RowMetaAndData(rowMeta, "Pentaho", 2L), new RowMetaAndData(rowMeta, "Pentaho", 3L), new RowMetaAndData(rowMeta, "Pentaho", 4L));
    Optional<Result> optionalResult = subtransExecutor.execute(rows);
    assertEquals(1, optionalResult.orElseThrow(AssertionError::new).getRows().size());
    verify(this.logChannel).logBasic(Const.CR + "------------> Linenr 1------------------------------" + Const.CR + "name = Pentaho" + Const.CR + "sum = 10" + Const.CR + Const.CR + "====================");
    Map<String, StepStatus> statuses = subtransExecutor.getStatuses();
    assertEquals(3, statuses.size());
    List<StepStatus> statusList = new ArrayList<>(statuses.values());
    assertEquals("Get rows from result", statusList.get(0).getStepname());
    assertEquals("Group by", statusList.get(1).getStepname());
    assertEquals("Write to log", statusList.get(2).getStepname());
    for (Map.Entry<String, StepStatus> entry : statuses.entrySet()) {
        StepStatus statusSpy = spy(entry.getValue());
        statuses.put(entry.getKey(), statusSpy);
    }
    subtransExecutor.execute(rows);
    for (Map.Entry<String, StepStatus> entry : statuses.entrySet()) {
        verify(entry.getValue()).updateAll(any());
    }
    verify(parentTrans, atLeastOnce()).addActiveSubTransformation(eq("subtransname"), any(Trans.class));
}
Also used : ArrayList(java.util.ArrayList) LoggingObject(org.pentaho.di.core.logging.LoggingObject) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StepStatus(org.pentaho.di.trans.step.StepStatus) Result(org.pentaho.di.core.Result) Variables(org.pentaho.di.core.variables.Variables) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface) TransExecutorParameters(org.pentaho.di.trans.steps.transexecutor.TransExecutorParameters) Map(java.util.Map) Test(org.junit.Test)

Example 13 with LoggingObjectInterface

use of org.pentaho.di.core.logging.LoggingObjectInterface in project pentaho-kettle by pentaho.

the class SubtransExecutorTest method doesNotExecuteWhenStopped.

@Test
public void doesNotExecuteWhenStopped() throws KettleException {
    TransMeta parentMeta = new TransMeta(this.getClass().getResource("subtrans-executor-parent.ktr").getPath(), new Variables());
    TransMeta subMeta = new TransMeta(this.getClass().getResource("subtrans-executor-sub.ktr").getPath(), new Variables());
    LoggingObjectInterface loggingObject = new LoggingObject("anything");
    Trans parentTrans = new Trans(parentMeta, loggingObject);
    SubtransExecutor subtransExecutor = new SubtransExecutor("subtransname", parentTrans, subMeta, true, new TransExecutorParameters(), "");
    RowMetaInterface rowMeta = parentMeta.getStepFields("Data Grid");
    List<RowMetaAndData> rows = Arrays.asList(new RowMetaAndData(rowMeta, "Pentaho", 1L), new RowMetaAndData(rowMeta, "Pentaho", 2L), new RowMetaAndData(rowMeta, "Pentaho", 3L), new RowMetaAndData(rowMeta, "Pentaho", 4L));
    subtransExecutor.stop();
    subtransExecutor.execute(rows);
    verify(this.logChannel, never()).logBasic("\n" + "------------> Linenr 1------------------------------\n" + "name = Pentaho\n" + "sum = 10\n" + "\n" + "====================");
}
Also used : Variables(org.pentaho.di.core.variables.Variables) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LoggingObject(org.pentaho.di.core.logging.LoggingObject) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface) TransExecutorParameters(org.pentaho.di.trans.steps.transexecutor.TransExecutorParameters) Test(org.junit.Test)

Example 14 with LoggingObjectInterface

use of org.pentaho.di.core.logging.LoggingObjectInterface in project pentaho-kettle by pentaho.

the class MappingInputFieldsTest method setUp.

@Before
public void setUp() throws Exception {
    meta = new MappingInputMeta();
    meta.setFieldName(new String[] { "n2", "n4" });
    meta.setFieldType(new int[] { ValueMetaInterface.TYPE_INTEGER, ValueMetaInterface.TYPE_INTEGER });
    meta.setFieldLength(new int[] { 0, 0 });
    meta.setFieldPrecision(new int[] { 0, 0 });
    StepMeta sm = new StepMeta("MappingInput", "SubTrans", meta);
    TransMeta tm = new TransMeta();
    tm.addStep(sm);
    LoggingObjectInterface loi = new SimpleLoggingObject("lo", LoggingObjectType.STEP, null);
    Trans tr = new Trans(tm, loi);
    step = new MappingInput(sm, null, 0, tm, tr);
    step.getTrans().setRunning(true);
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) StepMeta(org.pentaho.di.trans.step.StepMeta) Trans(org.pentaho.di.trans.Trans) Before(org.junit.Before)

Example 15 with LoggingObjectInterface

use of org.pentaho.di.core.logging.LoggingObjectInterface in project pentaho-kettle by pentaho.

the class TransMetricsDelegate method setupContent.

public void setupContent() {
    if (metricsComposite.isDisposed()) {
        return;
    }
    // 
    for (Control control : metricsComposite.getChildren()) {
        if (!control.isDisposed()) {
            control.dispose();
        }
    }
    emptyGraph = false;
    canvas = new Canvas(metricsComposite, SWT.NONE);
    spoon.props.setLook(canvas);
    FormData fdCanvas = new FormData();
    fdCanvas.left = new FormAttachment(0, 0);
    fdCanvas.right = new FormAttachment(100, 0);
    fdCanvas.top = new FormAttachment(0, 0);
    fdCanvas.bottom = new FormAttachment(100, 0);
    canvas.setLayoutData(fdCanvas);
    metricsComposite.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent event) {
            updateGraph();
        }
    });
    metricsComposite.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent event) {
            if (image != null) {
                image.dispose();
            }
        }
    });
    canvas.addPaintListener(new PaintListener() {

        public void paintControl(final PaintEvent event) {
            if (transGraph.trans != null && transGraph.trans.isFinished()) {
                refreshImage(event.gc);
                if (image != null && !image.isDisposed()) {
                    event.gc.drawImage(image, 0, 0);
                }
            } else {
                Rectangle bounds = canvas.getBounds();
                if (bounds.width <= 0 || bounds.height <= 0) {
                    return;
                }
                event.gc.setForeground(GUIResource.getInstance().getColorWhite());
                event.gc.setBackground(GUIResource.getInstance().getColorWhite());
                event.gc.fillRectangle(new Rectangle(0, 0, bounds.width, bounds.height));
                event.gc.setForeground(GUIResource.getInstance().getColorBlack());
                String metricsMessage = BaseMessages.getString(PKG, "TransMetricsDelegate.TransformationIsNotRunning.Message");
                org.eclipse.swt.graphics.Point extent = event.gc.textExtent(metricsMessage);
                event.gc.drawText(metricsMessage, (bounds.width - extent.x) / 2, (bounds.height - extent.y) / 2);
            }
        }
    });
    // Refresh automatically every 5 seconds as well.
    // 
    final Timer timer = new Timer("TransMetricsDelegate Timer");
    timer.schedule(new TimerTask() {

        public void run() {
            updateGraph();
        }
    }, 0, 5000);
    // When the tab is closed, we remove the update timer
    // 
    transMetricsTab.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent arg0) {
            timer.cancel();
        }
    });
    // Show tool tips with details...
    // 
    canvas.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent event) {
            if (drawAreas == null) {
                return;
            }
            for (int i = drawAreas.size() - 1; i >= 0; i--) {
                MetricsDrawArea drawArea = drawAreas.get(i);
                if (drawArea.getArea().contains(event.x, event.y)) {
                    MetricsDuration duration = drawArea.getDuration();
                    if (duration == null) {
                        continue;
                    }
                    System.out.println(duration.toString());
                    LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject(duration.getLogChannelId());
                    if (loggingObject == null) {
                        continue;
                    }
                    System.out.println(loggingObject.getObjectType() + " : " + loggingObject.getObjectName());
                }
            }
        }
    });
/*
     * canvas.addControlListener(new ControlAdapter() {
     *
     * @Override public void controlResized(ControlEvent arg0) { lastRefreshTime=0; // force a refresh } });
     */
}
Also used : FormData(org.eclipse.swt.layout.FormData) MetricsDrawArea(org.pentaho.di.core.logging.MetricsPainter.MetricsDrawArea) DisposeListener(org.eclipse.swt.events.DisposeListener) PaintEvent(org.eclipse.swt.events.PaintEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) ControlAdapter(org.eclipse.swt.events.ControlAdapter) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) Rectangle(org.eclipse.swt.graphics.Rectangle) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Point(org.pentaho.di.core.gui.Point) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Control(org.eclipse.swt.widgets.Control) Timer(java.util.Timer) TimerTask(java.util.TimerTask) ControlEvent(org.eclipse.swt.events.ControlEvent) LoggingObjectInterface(org.pentaho.di.core.logging.LoggingObjectInterface) MetricsDuration(org.pentaho.di.core.metrics.MetricsDuration) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

LoggingObjectInterface (org.pentaho.di.core.logging.LoggingObjectInterface)17 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 Database (org.pentaho.di.core.database.Database)3 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)3 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)3 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)3 Timer (java.util.Timer)2 TimerTask (java.util.TimerTask)2 ControlAdapter (org.eclipse.swt.events.ControlAdapter)2 ControlEvent (org.eclipse.swt.events.ControlEvent)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)2 DisposeListener (org.eclipse.swt.events.DisposeListener)2 MouseAdapter (org.eclipse.swt.events.MouseAdapter)2 MouseEvent (org.eclipse.swt.events.MouseEvent)2 PaintEvent (org.eclipse.swt.events.PaintEvent)2 PaintListener (org.eclipse.swt.events.PaintListener)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2