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;
}
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));
}
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" + "====================");
}
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);
}
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 } });
*/
}
Aggregations