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; }
break; case CHANNEL_ID: value = snapshot.getLogChannelId(); break; case LOG_DATE: break; case METRICS_DATE: value = snapshot.getDate(); break; case METRICS_CODE: value = snapshot.getMetric().getCode(); break; case METRICS_DESCRIPTION: value = snapshot.getMetric().getDescription(); break; case METRICS_SUBJECT: value = snapshot.getSubject(); break; case METRICS_TYPE: value = snapshot.getMetric().getType().name(); break; case METRICS_VALUE: value = snapshot.getValue(); break; default:
snapshot.getMetric().getDescription() + ( snapshot.getSubject() == null ? "" : ( " - " + snapshot.getSubject() ) ); MetricsSnapshotInterface lastSnapshot = last.get( key ); if ( lastSnapshot == null ) { MetricsInterface metric = lastSnapshot.getMetric(); if ( metric.getType() == MetricsSnapshotType.START && snapshot.getMetric().getType() == MetricsSnapshotType.STOP ) { long extraDuration = snapshot.getDate().getTime() - lastSnapshot.getDate().getTime(); metricsDuration = new MetricsDuration( lastSnapshot.getDate(), metric.getDescription(), lastSnapshot.getSubject(), logChannelId, extraDuration ); } else { metricsDuration.setDuration( metricsDuration.getDuration() + extraDuration ); metricsDuration.incrementCount(); if ( metricsDuration.getEndDate().getTime() < snapshot.getDate().getTime() ) { metricsDuration.setEndDate( snapshot.getDate() );
snapshot = metricsMap.get( key ); if ( snapshot != null ) { if ( value[0] > snapshot.getValue() ) { snapshot.setValue( value[0] ); snapshot.setDate( new Date() ); snapshot = metricsMap.get( key ); if ( snapshot != null ) { if ( value[0] < snapshot.getValue() ) { snapshot.setValue( value[0] ); snapshot.setDate( new Date() ); snapshot = metricsMap.get( key ); if ( snapshot != null ) { snapshot.setValue( snapshot.getValue() + value[0] ); } else { snapshot = new MetricsSnapshot( MetricsSnapshotType.SUM, metric, subject, value[0], logChannelId ); snapshot = metricsMap.get( key ); if ( snapshot != null ) { snapshot.setValue( snapshot.getValue() + 1L ); } else { snapshot = new MetricsSnapshot( MetricsSnapshotType.COUNT, metric, subject, 1L, logChannelId );
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; } }
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; }
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 ) ); long duration = snapshot.getDate().getTime() - start.getDate().getTime(); durations.add( new MetricsDuration( start.getDate(), snapshot.getMetric().getDescription(), snapshot .getSubject(), logChannelId, duration ) ); start = null;