本文整理汇总了Java中org.pentaho.di.core.metrics.MetricsDuration类的典型用法代码示例。如果您正苦于以下问题:Java MetricsDuration类的具体用法?Java MetricsDuration怎么用?Java MetricsDuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetricsDuration类属于org.pentaho.di.core.metrics包,在下文中一共展示了MetricsDuration类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: determinePeriod
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
private void determinePeriod(List<MetricsDuration> durations) {
periodStart=null;
periodEnd=null;
for (int i=0;i<durations.size();i++) {
MetricsDuration duration = durations.get(i);
long periodStartTime = duration.getDate().getTime();
if (periodStart==null || periodStartTime<periodStart) {
periodStart = periodStartTime;
}
long periodEndTime = duration.getEndDate().getTime();
if (periodEnd==null || periodEnd<periodEndTime) {
periodEnd = periodEndTime;
}
}
}
示例2: testBasics
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
public void testBasics() throws Exception {
LogChannel log = new LogChannel("BASICS");
log.setGatheringMetrics(true);
log.snap(METRIC_START);
Thread.sleep(50);
log.snap(METRIC_STOP);
Deque<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);
}
示例3: testTransformation
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
public void testTransformation() throws Exception {
TransMeta transMeta = new TransMeta("testfiles/metrics/simple-test.ktr");
Trans trans = new Trans(transMeta);
trans.setGatheringMetrics(true);
trans.execute(null);
trans.waitUntilFinished();
LogChannelInterface log = trans.getLogChannel();
Deque<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(log.getLogChannelId());
}
示例4: testBasics
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
@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 );
}
示例5: paint
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
/**
* Draws a metrics tab.
*
* @param durations
* is a list of metrics durations
* @return list of drawing areas.Throw IllegalArgumentException in case if input parameter is null or an empty
*/
public List<MetricsDrawArea> paint( List<MetricsDuration> durations ) {
if ( Utils.isEmpty( durations ) ) {
throw new IllegalArgumentException();
}
int width = getGc().getArea().x - 4;
int height = getGc().getArea().y - 4;
List<MetricsDrawArea> areas = new ArrayList<MetricsDrawArea>();
// First determine the period
//
determinePeriod( durations );
if ( periodStart == null || periodEnd == null || periodEnd <= periodStart ) {
return areas; // nothing to do;
}
double pixelsPerMs = (double) width / ( (double) ( periodEnd - periodStart ) );
long periodInMs = periodEnd - periodStart;
drawTimeScaleLine( height, pixelsPerMs, periodInMs );
drawDurations( durations, areas, pixelsPerMs );
return areas;
}
示例6: testTransformation
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
@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());
}
示例7: drawDurations
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
private void drawDurations( List<MetricsDuration> durations, List<MetricsDrawArea> areas, double pixelsPerMs ) {
// set top indent
int y = 20;
for ( MetricsDuration duration : durations ) {
Long realDuration = duration.getEndDate().getTime() - duration.getDate().getTime();
// How many pixels does it take to drawn this duration?
//
int durationWidth = (int) ( realDuration * pixelsPerMs );
int x = 2 + (int) ( ( duration.getDate().getTime() - periodStart ) * pixelsPerMs );
getGc().setBackground( EColor.BACKGROUND );
getGc().setForeground( EColor.LIGHTBLUE );
getGc().fillGradientRectangle( x, y, durationWidth, barHeight, false );
getGc().setForeground( EColor.BLACK );
getGc().drawRectangle( x, y, durationWidth, barHeight );
areas.add( new MetricsDrawArea( new Rectangle( x, y, durationWidth, barHeight ), duration ) );
LoggingObjectInterface loggingObject =
LoggingRegistry.getInstance().getLoggingObject( duration.getLogChannelId() );
String message =
duration.getDescription() + " - " + loggingObject.getObjectName() + " : " + duration.getDuration() + "ms";
if ( duration.getCount() > 1 ) {
message += " " + duration.getCount() + " calls, avg=" + ( duration.getDuration() / duration.getCount() );
}
getGc().setFont( EFont.GRAPH );
getGc().textExtent( message );
getGc().drawText( message, x + 3, y + 4, true );
y += barHeight + 5;
}
}
示例8: determinePeriod
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
private void determinePeriod( List<MetricsDuration> durations ) {
periodStart = null;
periodEnd = null;
for ( MetricsDuration duration : durations ) {
long periodStartTime = duration.getDate().getTime();
if ( periodStart == null || periodStartTime < periodStart ) {
periodStart = periodStartTime;
}
long periodEndTime = duration.getEndDate().getTime();
if ( periodEnd == null || periodEnd < periodEndTime ) {
periodEnd = periodEndTime;
}
}
}
示例9: MetricsDrawArea
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
public MetricsDrawArea(Rectangle area, MetricsDuration duration) {
this.area = area;
this.duration = duration;
}
示例10: getDuration
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
public MetricsDuration getDuration() {
return duration;
}
示例11: MetricsDrawArea
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
public MetricsDrawArea( Rectangle area, MetricsDuration duration ) {
this.area = area;
this.duration = duration;
}
示例12: testIllegalArgumentExceptionEmptyArgPaint
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
@Test( expected = IllegalArgumentException.class )
public void testIllegalArgumentExceptionEmptyArgPaint() {
durations = new ArrayList<MetricsDuration>();
callPaint( durations );
}
示例13: callPaint
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
private void callPaint( List<MetricsDuration> durations ) {
doCallRealMethod().when( metricsPainter ).paint( anyListOf( MetricsDuration.class ) );
metricsPainter.paint( durations );
}
示例14: refreshImage
import org.pentaho.di.core.metrics.MetricsDuration; //导入依赖的package包/类
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;
}
// For performance reasons, only ever refresh this image at most every 5 seconds...
//
if ( image != null && ( System.currentTimeMillis() - lastRefreshTime ) < 5000 ) {
return;
}
lastRefreshTime = System.currentTimeMillis();
if ( image != null ) {
image.dispose(); // prevent out of memory...
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();
}