Author: [log in to unmask] Date: Wed Jan 28 16:18:26 2015 New Revision: 2000 Log: Simplify and make more clear the ET strip charts. HPSJAVA-340 Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatistics.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemStripCharts.java Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatistics.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatistics.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatistics.java Wed Jan 28 16:18:26 2015 @@ -41,7 +41,7 @@ * Get the number of millis since the session started. * @return The number of millis since session start. */ - long getTimeElapsedMillis(); + long getTotalElapsedMillis(); /** * Get the Unix start time of the session. @@ -59,13 +59,13 @@ * Get the number of events in the current tick. * @return The number of events in the current tick. */ - long getEventsInTick(); + long getEventsReceived(); /** * Get the total number of events processed thusfar. * @return The total number of events processed so far. */ - long getCumulativeEvents(); + long getTotalEvents(); /** * Get the average number of events per second in the session. It simply divides the number of @@ -78,34 +78,34 @@ * Get the number of bytes received in the current tick. * @return The number of bytes received in the tick. */ - long getBytesInTick(); + long getBytesReceived(); /** * Get the total number of megabytes of data received thusfar. * @return The amount of data in megabytes received in the session. */ - double getCumulativeMb(); + double getTotalMegabytes(); /** * Get the average Mb per second of the session, which is the total amount of data divided by * the total time. * @return The average megabytes per second. */ - double getAverageMbPerSecond(); + double getAverageMegabytesPerSecond(); /** * Get the immediate event rate which is the number of events received in the current tick over * the time elapsed in the tick. * @return The event rate in [events/second]. */ - double getEventRate(); + double getEventsPerSecond(); /** * Get the immediate data rate which is the amount of data in bytes received in the current tick * over the tim elapsed in the tick. * @return The data rate in [bytes/second]. */ - public double getDataRateBytes(); + public double getBytesPerSecond(); /** * Get the number of milliseconds since the last tick. Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java Wed Jan 28 16:18:26 2015 @@ -29,7 +29,7 @@ static final long Kb = 1 * 1024; static final long Mb = Kb * 1024; static final double milliToSecond = 0.001; - static final DecimalFormat decimalFormat = new DecimalFormat("#.##"); + static final DecimalFormat decimalFormat = new DecimalFormat("#.####"); Timer timer; List<TimerTask> subtasks = new ArrayList<TimerTask>(); @@ -51,7 +51,7 @@ } @Override - public long getTimeElapsedMillis() { + public long getTotalElapsedMillis() { return sessionElapsedMillis; } @@ -64,52 +64,28 @@ public long getStopTimeMillis() { return this.stopTimeMillis; } - - @Override - public long getCumulativeEvents() { - return totalEvents; - } - - @Override - public double getAverageEventsPerSecond() { - try { - return Double.parseDouble(decimalFormat.format(totalEvents / millisToSeconds(getTimeElapsedMillis()))); - } catch (NumberFormatException e) { - return Double.NaN; - } - } - - @Override - public double getCumulativeMb() { - return bytesToMb(totalBytes); - } - - @Override - public double getAverageMbPerSecond() { - try { - return Double.parseDouble(decimalFormat.format(bytesToMb(totalBytes) / millisToSeconds(getTimeElapsedMillis()))); - } catch (NumberFormatException e) { - return Double.NaN; - } - } - - @Override - public long getEventsInTick() { - return eventsSinceTick; - } - - @Override - public long getBytesInTick() { - return bytesSinceTick; - } - + @Override public long getTickElapsedMillis() { return tickElapsedMillis; } - @Override - public double getEventRate() { + /** + * Event statistics. + */ + + @Override + public long getEventsReceived() { + return eventsSinceTick; + } + + @Override + public long getTotalEvents() { + return totalEvents; + } + + @Override + public double getEventsPerSecond() { if (eventsSinceTick > 0 && tickElapsedMillis > 0) return (double) eventsSinceTick / millisToSeconds(tickElapsedMillis); else @@ -117,7 +93,39 @@ } @Override - public double getDataRateBytes() { + public double getAverageEventsPerSecond() { + try { + return Double.parseDouble(decimalFormat.format(totalEvents / millisToSeconds(getTotalElapsedMillis()))); + } catch (NumberFormatException e) { + return 0; + } + } + + /** + * Data statistics. + */ + + @Override + public long getBytesReceived() { + return bytesSinceTick; + } + + @Override + public double getTotalMegabytes() { + return bytesToMb(totalBytes); + } + + @Override + public double getAverageMegabytesPerSecond() { + try { + return Double.parseDouble(decimalFormat.format(bytesToMb(totalBytes) / millisToSeconds(getTotalElapsedMillis()))); + } catch (NumberFormatException e) { + return Double.NaN; + } + } + + @Override + public double getBytesPerSecond() { if (bytesSinceTick > 0 && tickElapsedMillis > 0) return (double) bytesSinceTick / millisToSeconds(tickElapsedMillis); else @@ -163,10 +171,10 @@ @Override public void printSession(PrintStream ps) { ps.println("session statistics ..."); - ps.println(" timeElapsedMillis = " + this.getTimeElapsedMillis()); - ps.println(" cumulativeEvents = " + this.getCumulativeEvents()); + ps.println(" timeElapsedMillis = " + this.getTotalElapsedMillis()); + ps.println(" cumulativeEvents = " + this.getTotalEvents()); ps.println(" averageEventsPerSecond = " + this.getAverageEventsPerSecond()); - ps.println(" averageMegaBytesPerSecond = " + this.getAverageMbPerSecond()); + ps.println(" averageMegaBytesPerSecond = " + this.getAverageMegabytesPerSecond()); } @@ -174,8 +182,8 @@ public void printTick(PrintStream ps) { ps.println("tick statistics ..."); ps.println(" tickElapsedMillis = " + this.getTickElapsedMillis()); - ps.println(" eventsSinceTick = " + this.getEventsInTick()); - ps.println(" bytesSinceTick = " + this.getBytesInTick()); + ps.println(" eventsSinceTick = " + this.getEventsReceived()); + ps.println(" bytesSinceTick = " + this.getBytesReceived()); } @Override @@ -213,70 +221,79 @@ tickElapsedMillis = 0; tickStartMillis = System.currentTimeMillis(); } - + public abstract class SystemStatisticsUpdater extends StripChartUpdater { SystemStatisticsUpdater() { addSubTask(this); } } - - public class AverageEventRateUpdater extends SystemStatisticsUpdater { + + public class AverageEventsPerSecondUpdater extends SystemStatisticsUpdater { @Override public float nextValue() { return (float) getAverageEventsPerSecond(); } } - - public class EventsInTickUpdater extends SystemStatisticsUpdater { - - @Override - public float nextValue() { - return getEventsInTick(); - } - } - - public class CumulativeEventsUpdater extends SystemStatisticsUpdater { - @Override - public float nextValue() { - return getCumulativeEvents(); - } - } - - public class BytesInTickUpdater extends SystemStatisticsUpdater { - @Override - public float nextValue() { - return getBytesInTick(); - } - } - - public class AverageMbUpdater extends SystemStatisticsUpdater { - @Override - public float nextValue() { - return (float) getAverageMbPerSecond(); - } - } - - public class CumulativeMbUpdater extends SystemStatisticsUpdater { - @Override - public float nextValue() { - return (float) getCumulativeMb(); - } - } - - public class EventRateUpdater extends SystemStatisticsUpdater { - - @Override - public float nextValue() { - return (float) getEventRate(); - } - } - - public class DataRateUpdater extends SystemStatisticsUpdater { - - @Override - public float nextValue() { - return (float) getDataRateBytes(); - } - } + + public class EventsPerSecondUpdater extends SystemStatisticsUpdater { + + @Override + public float nextValue() { + return (float) getEventsPerSecond(); + } + } + + public class EventsReceivedUpdater extends SystemStatisticsUpdater { + + @Override + public float nextValue() { + return getEventsReceived(); + } + } + + public class TotalEventsUpdater extends SystemStatisticsUpdater { + @Override + public float nextValue() { + return getTotalEvents(); + } + } + + public class BytesReceivedUpdater extends SystemStatisticsUpdater { + @Override + public float nextValue() { + return getBytesReceived(); + } + } + + public class AverageMegabytesPerSecondUpdater extends SystemStatisticsUpdater { + @Override + public float nextValue() { + return (float) getAverageMegabytesPerSecond(); + } + } + + public class TotalMegabytesUpdater extends SystemStatisticsUpdater { + @Override + public float nextValue() { + return (float) getTotalMegabytes(); + } + } + + public class BytesPerSecondUpdater extends SystemStatisticsUpdater { + + @Override + public float nextValue() { + return (float) getBytesPerSecond(); + } + } + + public class MegabytesPerSecondUpdater extends SystemStatisticsUpdater { + @Override + public float nextValue() { + return (float) getBytesPerSecond() / 1000000; + } + } + + } Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemStripCharts.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemStripCharts.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemStripCharts.java Wed Jan 28 16:18:26 2015 @@ -14,28 +14,19 @@ SystemStatisticsImpl stats = new SystemStatisticsImpl(); MonitoringPlotFactory plotFactory = (MonitoringPlotFactory) AIDA.defaultInstance().analysisFactory().createPlotterFactory("ET System Monitoring"); + public EtSystemStripCharts() { + stats.setTickLengthMillis(2000); + } + /** * Setup the strip charts for ET system monitoring and start accumulating statistics. */ @Override - public void startJob() { - - plotFactory.createStripChart("Event Rate", "Event Count", 100, stats.new EventRateUpdater()); - - plotFactory.createStripChart("Average Event Rate", "Event Count", 100, stats.new AverageEventRateUpdater()); - - plotFactory.createStripChart("Events in Tick", "Event Count", 100, stats.new EventsInTickUpdater()); - - plotFactory.createStripChart("Cumulative Events", "Event Count", 100, stats.new CumulativeEventsUpdater()); - - plotFactory.createStripChart("Data Rate", "Bytes", 100, stats.new DataRateUpdater()); - - plotFactory.createStripChart("Bytes in Tick", "Bytes", 100, stats.new BytesInTickUpdater()); - - plotFactory.createStripChart("Average Megabytes", "Megabytes", 100, stats.new AverageMbUpdater()); - - plotFactory.createStripChart("Cumulative Megabytes", "Megabytes", 100, stats.new CumulativeMbUpdater()); - + public void startJob() { + plotFactory.createStripChart("Data Rate", "MB / second", 100, stats.new MegabytesPerSecondUpdater()); + plotFactory.createStripChart("Total Data", "Megabytes", 100, stats.new TotalMegabytesUpdater()); + plotFactory.createStripChart("Event Rate", "Events / second", 100, stats.new EventsPerSecondUpdater()); + plotFactory.createStripChart("Total Events", "Number of Events", 100, stats.new TotalEventsUpdater()); stats.start(); } @@ -48,4 +39,4 @@ public void endJob() { stats.stop(); } -} +}