use of org.pentaho.di.core.metrics.MetricsDuration in project pentaho-kettle by pentaho.
the class TransMetricsDelegate method refreshImage.
private void refreshImage(GC canvasGc) {
List<MetricsDuration> durations = MetricsUtil.getAllDurations(transGraph.trans.getLogChannelId());
if (Utils.isEmpty(durations)) {
// In case of an empty durations or null there is nothing to draw
return;
}
// Sort the metrics.
Collections.sort(durations, new Comparator<MetricsDuration>() {
@Override
public int compare(MetricsDuration o1, MetricsDuration o2) {
return o1.getDate().compareTo(o2.getDate());
}
});
Rectangle bounds = canvas.getBounds();
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
if (transGraph.trans == null) {
image = null;
return;
}
//
if (image != null && (System.currentTimeMillis() - lastRefreshTime) < 5000) {
return;
}
lastRefreshTime = System.currentTimeMillis();
if (image != null) {
// prevent out of memory...
image.dispose();
image = null;
}
// Correct size of canvas.
org.eclipse.swt.graphics.Point textExtent = canvasGc.textExtent("AagKkiw");
int height = textExtent.y + 8;
// Make the height larger if needed for clarify
//
bounds.height = Math.max(durations.size() * height, bounds.height);
canvas.setSize(bounds.width, bounds.height);
SWTGC gc = new SWTGC(Display.getCurrent(), new Point(bounds.width, bounds.height), PropsUI.getInstance().getIconSize());
MetricsPainter painter = new MetricsPainter(gc, height);
drawAreas = painter.paint(durations);
image = (Image) gc.getImage();
// refresh the scrolled composite
//
sMetricsComposite.setMinHeight(bounds.height);
sMetricsComposite.setMinWidth(bounds.width);
sMetricsComposite.layout(true, true);
// Draw the image on the canvas...
//
canvas.redraw();
// close shop on the SWT GC side.
//
gc.dispose();
}
use of org.pentaho.di.core.metrics.MetricsDuration in project pentaho-kettle by pentaho.
the class JobMetricsDelegate method refreshImage.
private void refreshImage(GC canvasGc) {
List<MetricsDuration> durations = MetricsUtil.getAllDurations(jobGraph.job.getLogChannelId());
if (Utils.isEmpty(durations)) {
// In case of an empty durations or null there is nothing to draw
return;
}
// Sort the metrics.
Collections.sort(durations, new Comparator<MetricsDuration>() {
@Override
public int compare(MetricsDuration o1, MetricsDuration o2) {
return o1.getDate().compareTo(o2.getDate());
}
});
Rectangle bounds = canvas.getBounds();
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
if (jobGraph.job == null) {
image = null;
return;
}
//
if (image != null && (System.currentTimeMillis() - lastRefreshTime) < 5000) {
return;
}
lastRefreshTime = System.currentTimeMillis();
if (image != null) {
// prevent out of memory...
image.dispose();
image = null;
}
// Correct size of canvas.
//
org.eclipse.swt.graphics.Point textExtent = canvasGc.textExtent("AagKkiw");
int barHeight = textExtent.y + 8;
// Make the height larger if needed for clarify
//
bounds.height = Math.max(durations.size() * barHeight, bounds.height);
canvas.setSize(bounds.width, bounds.height);
SWTGC gc = new SWTGC(Display.getCurrent(), new Point(bounds.width, bounds.height), PropsUI.getInstance().getIconSize());
MetricsPainter painter = new MetricsPainter(gc, barHeight);
// checking according to method's contract
drawAreas = painter.paint(durations);
image = (Image) gc.getImage();
// refresh the scrolled composite
//
// sMetricsComposite.setMinHeight(bounds.height);
// sMetricsComposite.setMinWidth(bounds.width);
sMetricsComposite.layout(true, true);
// close shop on the SWT GC side.
//
gc.dispose();
// Draw the image on the canvas...
//
canvas.redraw();
}
use of org.pentaho.di.core.metrics.MetricsDuration in project pentaho-kettle by pentaho.
the class MetricsIT method testBasics.
@Test
public void testBasics() throws Exception {
LogChannel log = new LogChannel("BASICS");
log.setGatheringMetrics(true);
log.snap(METRIC_START);
Thread.sleep(50);
log.snap(METRIC_STOP);
Queue<MetricsSnapshotInterface> snapshotList = MetricsRegistry.getInstance().getSnapshotList(log.getLogChannelId());
assertEquals(2, snapshotList.size());
List<MetricsDuration> durationList = MetricsUtil.getDuration(log.getLogChannelId(), METRIC_START);
assertEquals(1, durationList.size());
MetricsDuration duration = durationList.get(0);
assertTrue(duration.getDuration() >= 50 && duration.getDuration() <= 100);
}
use of org.pentaho.di.core.metrics.MetricsDuration in project pentaho-kettle by pentaho.
the class MetricsIT method testTransformation.
@Test
public void testTransformation() throws Exception {
TransMeta transMeta = new TransMeta("src/it/resources/metrics/simple-test.ktr");
transMeta.setGatheringMetrics(true);
Trans trans = new Trans(transMeta);
trans.setGatheringMetrics(true);
trans.execute(null);
trans.waitUntilFinished();
LogChannelInterface log = trans.getLogChannel();
Queue<MetricsSnapshotInterface> snapshotList = MetricsRegistry.getInstance().getSnapshotList(log.getLogChannelId());
assertTrue(snapshotList.size() >= 4);
List<MetricsDuration> durationList = MetricsUtil.getDuration(log.getLogChannelId(), Metrics.METRIC_TRANSFORMATION_EXECUTION_START);
assertEquals(1, durationList.size());
MetricsDuration duration = durationList.get(0);
assertTrue(duration.getDuration() >= 20 && duration.getDuration() <= 5000);
assertEquals(Long.valueOf(1L), duration.getCount());
// Get all durations...
//
// durationList = MetricsUtil.getDurations(trans.getLogChannelId());
}
Aggregations