public static List<MetricsSnapshotInterface> getResultsList( Metrics metric ) { List<MetricsSnapshotInterface> snapshots = new ArrayList<MetricsSnapshotInterface>(); Map<String, Map<String, MetricsSnapshotInterface>> snapshotMaps = MetricsRegistry.getInstance().getSnapshotMaps(); Iterator<Map<String, MetricsSnapshotInterface>> mapsIterator = snapshotMaps.values().iterator(); while ( mapsIterator.hasNext() ) { Map<String, MetricsSnapshotInterface> map = mapsIterator.next(); Iterator<MetricsSnapshotInterface> snapshotIterator = map.values().iterator(); while ( snapshotIterator.hasNext() ) { MetricsSnapshotInterface snapshot = snapshotIterator.next(); if ( snapshot.getMetric().equals( metric ) ) { snapshots.add( snapshot ); } } } return snapshots; }
public static Long getResult( Metrics metric ) { Map<String, Map<String, MetricsSnapshotInterface>> snapshotMaps = MetricsRegistry.getInstance().getSnapshotMaps(); Iterator<Map<String, MetricsSnapshotInterface>> mapsIterator = snapshotMaps.values().iterator(); while ( mapsIterator.hasNext() ) { Map<String, MetricsSnapshotInterface> map = mapsIterator.next(); Iterator<MetricsSnapshotInterface> snapshotIterator = map.values().iterator(); while ( snapshotIterator.hasNext() ) { MetricsSnapshotInterface snapshot = snapshotIterator.next(); if ( snapshot.getMetric().equals( metric ) ) { return snapshot.getValue(); } } } return null; }
public void addSnapshot( LogChannelInterface logChannel, MetricsSnapshotInterface snapshot ) { MetricsInterface metric = snapshot.getMetric(); String channelId = logChannel.getLogChannelId(); switch ( metric.getType() ) { case START: case STOP: Queue<MetricsSnapshotInterface> list = getSnapshotList( channelId ); list.add( snapshot ); break; case MIN: case MAX: case SUM: case COUNT: Map<String, MetricsSnapshotInterface> map = getSnapshotMap( channelId ); map.put( snapshot.getKey(), snapshot ); break; default: break; } }
while ( iterator.hasNext() ) { MetricsSnapshotInterface snapshot = iterator.next(); if ( snapshot.getMetric().equals( metric ) ) { if ( snapshot.getMetric().getType() == MetricsSnapshotType.START ) { if ( start != null ) { durations.add( new MetricsDuration( start.getDate(), snapshot.getMetric().getDescription(), snapshot .getSubject(), logChannelId, null ) ); } else { long duration = snapshot.getDate().getTime() - start.getDate().getTime(); durations.add( new MetricsDuration( start.getDate(), snapshot.getMetric().getDescription(), snapshot .getSubject(), logChannelId, duration ) ); start = null;
snapshot.getMetric().getDescription() + ( snapshot.getSubject() == null ? "" : ( " - " + snapshot.getSubject() ) ); MetricsSnapshotInterface lastSnapshot = last.get( key ); MetricsInterface metric = lastSnapshot.getMetric(); if ( metric.getType() == MetricsSnapshotType.START && snapshot.getMetric().getType() == MetricsSnapshotType.STOP ) { long extraDuration = snapshot.getDate().getTime() - lastSnapshot.getDate().getTime();