/** * Creates a new instance of this filter. * * @param numberOfEntries * Maximal number of entries in a XYPlot * @param recordsTimeUnit * Time unit to interpret the timestamp of a record passed to the input port */ public MemSwapUtilizationDisplayFilter(final int numberOfEntries, final TimeUnit recordsTimeUnit) { this.recordsTimeUnit = recordsTimeUnit; // Create the display objects this.xyplot = new XYPlot(numberOfEntries); this.memPieChart = new PieChart(); this.swapPieChart = new PieChart(); }
private void updateDisplays(final MemSwapUsageRecord record) { // Calculate the minutes and seconds of the logging timestamp of the record final Date date = new Date(TimeUnit.MILLISECONDS.convert(record.getLoggingTimestamp(), super.recordsTimeUnitFromProjectContext)); final String minutesAndSeconds = date.toString().substring(14, 19); final String id = record.getHostname(); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.MEM_FREE, minutesAndSeconds, record.getMemFree() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.MEM_TOTAL, minutesAndSeconds, record.getMemTotal() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.MEM_USED, minutesAndSeconds, record.getMemUsed() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_FREE, minutesAndSeconds, record.getSwapFree() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_TOTAL, minutesAndSeconds, record.getSwapTotal() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_USED, minutesAndSeconds, record.getSwapUsed() / 1048576); this.memPieChart.setValue(id + " - " + MemSwapUtilizationDisplayFilter.MEM_FREE, record.getMemFree()); this.memPieChart.setValue(id + " - " + MemSwapUtilizationDisplayFilter.MEM_USED, record.getMemUsed()); this.swapPieChart.setValue(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_FREE, record.getSwapFree()); this.swapPieChart.setValue(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_USED, record.getSwapUsed()); }
/** * Tests if the mem-pie-chart received the correct values. */ @Test public void memPieChartShouldBeCorrect() { StageTester.test(this.memSwapUtilFilter).and().send(this.record).to(this.memSwapUtilFilter.getInputPort()).start(); final long actualMemFree = this.memSwapUtilFilter.getMemPieChart().getValue(this.id + " - " + MemSwapUtilizationDisplayFilter.MEM_FREE).longValue(); final long actualMemUsed = this.memSwapUtilFilter.getMemPieChart().getValue(this.id + " - " + MemSwapUtilizationDisplayFilter.MEM_USED).longValue(); Assert.assertThat(actualMemFree, Is.is(MEM_FREE)); Assert.assertThat(actualMemUsed, Is.is(MEM_USED)); }
private void updateDisplays(final MemSwapUsageRecord record) { // Calculate the minutes and seconds of the logging timestamp of the record final Date date = new Date(TimeUnit.MILLISECONDS.convert(record.getLoggingTimestamp(), super.recordsTimeUnitFromProjectContext)); final String minutesAndSeconds = date.toString().substring(14, 19); final String id = record.getHostname(); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.MEM_FREE, minutesAndSeconds, record.getMemFree() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.MEM_TOTAL, minutesAndSeconds, record.getMemTotal() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.MEM_USED, minutesAndSeconds, record.getMemUsed() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_FREE, minutesAndSeconds, record.getSwapFree() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_TOTAL, minutesAndSeconds, record.getSwapTotal() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_USED, minutesAndSeconds, record.getSwapUsed() / 1048576); this.memPieChart.setValue(id + " - " + MemSwapUtilizationDisplayFilter.MEM_FREE, record.getMemFree()); this.memPieChart.setValue(id + " - " + MemSwapUtilizationDisplayFilter.MEM_USED, record.getMemUsed()); this.swapPieChart.setValue(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_FREE, record.getSwapFree()); this.swapPieChart.setValue(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_USED, record.getSwapUsed()); }
/** * Tests if the swap-pie-chart received the correct values. */ @Test public void swapPieChartShouldBeCorrect() { StageTester.test(this.memSwapUtilFilter).and().send(this.record).to(this.memSwapUtilFilter.getInputPort()).start(); final long actualSwapFree = this.memSwapUtilFilter.getSwapPieChart().getValue(this.id + " - " + MemSwapUtilizationDisplayFilter.SWAP_FREE).longValue(); final long actualSwapUsed = this.memSwapUtilFilter.getSwapPieChart().getValue(this.id + " - " + MemSwapUtilizationDisplayFilter.SWAP_USED).longValue(); Assert.assertThat(actualSwapFree, Is.is(SWAR_FREE)); Assert.assertThat(actualSwapUsed, Is.is(SWAP_USED)); }
private void updateDisplays(final MemSwapUsageRecord record) { // Calculate the minutes and seconds of the logging timestamp of the record final Date date = new Date(TimeUnit.MILLISECONDS.convert(record.getLoggingTimestamp(), this.recordsTimeUnit)); final String minutesAndSeconds = date.toString().substring(14, 19); final String id = record.getHostname(); // Sets Entries in MB instead of Bytes this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.MEM_FREE, minutesAndSeconds, record.getMemFree() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.MEM_TOTAL, minutesAndSeconds, record.getMemTotal() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.MEM_USED, minutesAndSeconds, record.getMemUsed() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_FREE, minutesAndSeconds, record.getSwapFree() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_TOTAL, minutesAndSeconds, record.getSwapTotal() / 1048576); this.xyplot.setEntry(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_USED, minutesAndSeconds, record.getSwapUsed() / 1048576); this.memPieChart.setValue(id + " - " + MemSwapUtilizationDisplayFilter.MEM_FREE, record.getMemFree()); this.memPieChart.setValue(id + " - " + MemSwapUtilizationDisplayFilter.MEM_USED, record.getMemUsed()); this.swapPieChart.setValue(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_FREE, record.getSwapFree()); this.swapPieChart.setValue(id + " - " + MemSwapUtilizationDisplayFilter.SWAP_USED, record.getSwapUsed()); }
/** * Creates a new instance of this class using the given parameters. * * @param configuration * The configuration for this filter. * @param projectContext * The project context for this filter. */ public MemSwapUtilizationDisplayFilter(final Configuration configuration, final IProjectContext projectContext) { super(configuration, projectContext); // Read the configuration this.numberOfEntries = configuration.getIntProperty(CONFIG_PROPERTY_NAME_NUMBER_OF_ENTRIES); // Create the display objects this.xyplot = new XYPlot(this.numberOfEntries); this.memPieChart = new PieChart(); this.swapPieChart = new PieChart(); }
/** * Creates a new instance of this class using the given parameters. * * @param configuration * The configuration for this filter. * @param projectContext * The project context for this filter. */ public MemSwapUtilizationDisplayFilter(final Configuration configuration, final IProjectContext projectContext) { super(configuration, projectContext); // Read the configuration this.numberOfEntries = configuration.getIntProperty(CONFIG_PROPERTY_NAME_NUMBER_OF_ENTRIES); // Create the display objects this.xyplot = new XYPlot(this.numberOfEntries); this.memPieChart = new PieChart(); this.swapPieChart = new PieChart(); }