@Test public void shouldGetGarbageCollectionData() throws Exception { target.event( new EventScheduler() { @Override public void schedule(long delay, TimeUnit timeUnit) { assertEquals(TimeUnit.SECONDS.toMillis(10), timeUnit.toMillis(delay)); schedules++; } }, new EventAdder() { @Override public void add(byte[] event) { assertEquals(2, event.length); adds++; } } ); assertEquals(1, schedules); assertEquals(1, adds); }
@Override public void event(EventScheduler scheduler, EventAdder adder) { long sum = 0; for (GarbageCollectorMXBean garbageCollectorMXBean : garbageCollectorMXBeans) { sum += garbageCollectorMXBean.getCollectionCount() + garbageCollectorMXBean.getCollectionTime(); } adder.add(Util.twoLeastSignificantBytes(sum)); scheduler.schedule(10, TimeUnit.SECONDS); }
GarbageCollectorEntropySource implements EntropySource { @Override public void event(EventScheduler scheduler, EventAdder adder) { long sum = 0; for (GarbageCollectorMXBean garbageCollectorMXBean : garbageCollectorMXBeans) { sum += garbageCollectorMXBean.getCollectionCount() + garbageCollectorMXBean.getCollectionTime(); } adder.add(Util.twoLeastSignificantBytes(sum)); scheduler.schedule(10, TimeUnit.SECONDS); } }
GarbageCollectorEntropySource implements EntropySource { @Override public void event(EventScheduler scheduler, EventAdder adder) { long sum = 0; for (GarbageCollectorMXBean garbageCollectorMXBean : garbageCollectorMXBeans) { sum += garbageCollectorMXBean.getCollectionCount() + garbageCollectorMXBean.getCollectionTime(); } adder.add(Util.twoLeastSignificantBytes(sum)); scheduler.schedule(10, TimeUnit.SECONDS); }  }
GarbageCollectorEntropySource implements EntropySource { @Override public void event(EventScheduler scheduler, EventAdder adder) { long sum = 0; for (GarbageCollectorMXBean garbageCollectorMXBean : garbageCollectorMXBeans) { sum += garbageCollectorMXBean.getCollectionCount() + garbageCollectorMXBean.getCollectionTime(); } adder.add(Util.twoLeastSignificantBytes(sum)); scheduler.schedule(10, TimeUnit.SECONDS); }  @Override void event(EventScheduler scheduler, EventAdder adder); }
GarbageCollectorEntropySource implements EntropySource { @Override public void event(EventScheduler scheduler, EventAdder adder) { long sum = 0; for (GarbageCollectorMXBean garbageCollectorMXBean : garbageCollectorMXBeans) { sum += garbageCollectorMXBean.getCollectionCount() + garbageCollectorMXBean.getCollectionTime(); } adder.add(Util.twoLeastSignificantBytes(sum)); scheduler.schedule(10, TimeUnit.SECONDS); }  @Override void event(EventScheduler scheduler, EventAdder adder);  }