@Test public void testAddValue2() throws RemoteException { String id = "watch"; GaugeWatch watch = new GaugeWatch(id); DataSourceMonitor mon = new DataSourceMonitor(watch); final int checkpoints[] = new int[] {0, 1, 50, 1000, 1001, 2000, 10000}; final int collectionSize = 1000; List<Long> added = new ArrayList<Long>(); for (int checkpoint : checkpoints) { if(watch.getWatchDataSource().getMaxSize()<checkpoint) { watch.getWatchDataSource().setMaxSize(1000); } while (added.size() < checkpoint) { long l = (long) (Math.random() * 1000); added.add(l); watch.addValue(l); } mon.waitFor(Math.min(collectionSize, checkpoint)); Calculable[] calcs = watch.getWatchDataSource().getCalculable(); int offset = Math.max(added.size() - collectionSize, 0); List<Long> expected = added.subList(offset, added.size()); List<Long> actual = new ArrayList<Long>(); for (Calculable calc : calcs) { Assert.assertEquals(id, calc.getId()); actual.add((long) calc.getValue()); } Assert.assertEquals(expected, actual); } Utils.close(watch.getWatchDataSource()); }
public void addValue(long value) { addWatchRecord(new Calculable(id, (double)value, System.currentTimeMillis())); }
GaugeWatch extends ThresholdWatch { public void addValue(long value) { addWatchRecord(new Calculable(id, (double)value, System.currentTimeMillis())); } }
GaugeWatch extends ThresholdWatch { public void addValue(long value) { addWatchRecord(new Calculable(id, (double)value, System.currentTimeMillis())); } GaugeWatch(String id);  GaugeWatch(String id, Configuration config);  GaugeWatch(WatchDataSource watchDataSource, String id); }
GaugeWatch extends ThresholdWatch { public void addValue(long value) { addWatchRecord(new Calculable(id, (double)value, System.currentTimeMillis())); } GaugeWatch(String id);  GaugeWatch(String id, Configuration config);  GaugeWatch(WatchDataSource watchDataSource, String id); void addValue(long value); void addValue(double value); @SuppressWarnings("unused") void addValue(double value, String detail); }
GaugeWatch extends ThresholdWatch { public void addValue(long value) { addWatchRecord(new Calculable(id, (double)value, System.currentTimeMillis())); } GaugeWatch(String id);  GaugeWatch(String id, Configuration config);  GaugeWatch(WatchDataSource watchDataSource, String id); void addValue(long value); void addValue(double value); @SuppressWarnings("unused") void addValue(double value, String detail);  }