@Test(groups = "fast") public void testUpdateRegression() throws Exception { final QueueStats queueStats = new QueueStats("myQ", 3, 0.3); queueStats.record(0L, 0L); Assert.assertTrue(Arrays.deepEquals(queueStats.getTimestamps().toArray(), new Long[]{0L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getRawSizes().toArray(), new Long[]{0L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getSmoothedSizes().toArray(), new Double[]{0.0})); Assert.assertFalse(queueStats.isGrowing()); queueStats.record(1L, 10L); Assert.assertTrue(Arrays.deepEquals(queueStats.getTimestamps().toArray(), new Long[]{0L, 1L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getRawSizes().toArray(), new Long[]{0L, 10L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getSmoothedSizes().toArray(), new Double[]{0.0, 3.0})); Assert.assertFalse(queueStats.isGrowing()); queueStats.record(2L, 15L); Assert.assertTrue(Arrays.deepEquals(queueStats.getTimestamps().toArray(), new Long[]{0L, 1L, 2L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getRawSizes().toArray(), new Long[]{0L, 10L, 15L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getSmoothedSizes().toArray(), new Double[]{0.0, 3.0, 6.6})); Assert.assertTrue(queueStats.isGrowing()); queueStats.record(3L, 9L); Assert.assertTrue(Arrays.deepEquals(queueStats.getTimestamps().toArray(), new Long[]{1L, 2L, 3L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getRawSizes().toArray(), new Long[]{10L, 15L, 9L})); Assert.assertEquals((Double) queueStats.getSmoothedSizes().toArray()[2], 7.32, DELTA); Assert.assertTrue(queueStats.isGrowing()); queueStats.record(4L, 12L); Assert.assertTrue(Arrays.deepEquals(queueStats.getTimestamps().toArray(), new Long[]{2L, 3L, 4L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getRawSizes().toArray(), new Long[]{15L, 9L, 12L})); Assert.assertEquals((Double) queueStats.getSmoothedSizes().toArray()[2], 8.724, DELTA); Assert.assertTrue(queueStats.isGrowing()); queueStats.record(5L, 14L); Assert.assertTrue(Arrays.deepEquals(queueStats.getTimestamps().toArray(), new Long[]{3L, 4L, 5L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getRawSizes().toArray(), new Long[]{9L, 12L, 14L})); Assert.assertEquals((Double) queueStats.getSmoothedSizes().toArray()[2], 10.3068, DELTA); Assert.assertTrue(queueStats.isGrowing()); queueStats.record(6L, 18L); Assert.assertTrue(Arrays.deepEquals(queueStats.getTimestamps().toArray(), new Long[]{4L, 5L, 6L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getRawSizes().toArray(), new Long[]{12L, 14L, 18L})); Assert.assertEquals((Double) queueStats.getSmoothedSizes().toArray()[2], 12.6148, DELTA); Assert.assertTrue(queueStats.isGrowing()); queueStats.record(7L, 0L); Assert.assertTrue(Arrays.deepEquals(queueStats.getTimestamps().toArray(), new Long[]{5L, 6L, 7L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getRawSizes().toArray(), new Long[]{14L, 18L, 0L})); Assert.assertEquals((Double) queueStats.getSmoothedSizes().toArray()[2], 8.8303, DELTA); Assert.assertFalse(queueStats.isGrowing()); queueStats.record(8L, 0L); Assert.assertTrue(Arrays.deepEquals(queueStats.getTimestamps().toArray(), new Long[]{6L, 7L, 8L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getRawSizes().toArray(), new Long[]{18L, 0L, 0L})); Assert.assertEquals((Double) queueStats.getSmoothedSizes().toArray()[2], 6.1812, DELTA); Assert.assertFalse(queueStats.isGrowing()); queueStats.record(9L, 0L); Assert.assertTrue(Arrays.deepEquals(queueStats.getTimestamps().toArray(), new Long[]{7L, 8L, 9L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getRawSizes().toArray(), new Long[]{0L, 0L, 0L})); Assert.assertEquals((Double) queueStats.getSmoothedSizes().toArray()[2], 4.3268, DELTA); Assert.assertFalse(queueStats.isGrowing()); queueStats.record(10L, 0L); Assert.assertTrue(Arrays.deepEquals(queueStats.getTimestamps().toArray(), new Long[]{8L, 9L, 10L})); Assert.assertTrue(Arrays.deepEquals(queueStats.getRawSizes().toArray(), new Long[]{0L, 0L, 0L})); Assert.assertEquals((Double) queueStats.getSmoothedSizes().toArray()[2], 3.0288, DELTA); Assert.assertFalse(queueStats.isGrowing()); }
private void updateRegression(final String queueId, final long now, final long nbReadyEntries, final int slidingWindowSize, final double alpha) { if (statsPerQueue.get(queueId) == null) { statsPerQueue.put(queueId, new QueueStats(queueId, slidingWindowSize, alpha)); } statsPerQueue.get(queueId).record(now, nbReadyEntries); }
KillbillQueuesHealthcheck extends HealthCheck { private void updateRegression(final String queueId, final long now, final long nbReadyEntries, final int slidingWindowSize, final double alpha) { if (statsPerQueue.get(queueId) == null) { statsPerQueue.put(queueId, new QueueStats(queueId, slidingWindowSize, alpha)); } statsPerQueue.get(queueId).record(now, nbReadyEntries); } }
KillbillQueuesHealthcheck extends HealthCheck { private void updateRegression(final String queueId, final long now, final long nbReadyEntries, final int slidingWindowSize, final double alpha) { if (statsPerQueue.get(queueId) == null) { statsPerQueue.put(queueId, new QueueStats(queueId, slidingWindowSize, alpha)); } statsPerQueue.get(queueId).record(now, nbReadyEntries); } @Inject  KillbillQueuesHealthcheck(final Clock clock,
                                     final NotificationQueueService notificationQueueService,
                                     final PersistentBus bus,
                                     @Named("externalBus") final PersistentBus externalBus); }
KillbillQueuesHealthcheck extends HealthCheck { private void updateRegression(final String queueId, final long now, final long nbReadyEntries, final int slidingWindowSize, final double alpha) { if (statsPerQueue.get(queueId) == null) { statsPerQueue.put(queueId, new QueueStats(queueId, slidingWindowSize, alpha)); } statsPerQueue.get(queueId).record(now, nbReadyEntries); } @Inject  KillbillQueuesHealthcheck(final Clock clock,
                                     final NotificationQueueService notificationQueueService,
                                     final PersistentBus bus,
                                     @Named("externalBus") final PersistentBus externalBus); @Managed(description = "Kill Bill queues healthcheck") boolean isHealthy(); @Managed(description = "Deactivate healthcheck") void deactivateHealthcheck(); @Managed(description = "Activate healthcheck") void activateHealthcheck(); @Override Result check(); }
KillbillQueuesHealthcheck extends HealthCheck { private void updateRegression(final String queueId, final long now, final long nbReadyEntries, final int slidingWindowSize, final double alpha) { if (statsPerQueue.get(queueId) == null) { statsPerQueue.put(queueId, new QueueStats(queueId, slidingWindowSize, alpha)); } statsPerQueue.get(queueId).record(now, nbReadyEntries); } @Inject  KillbillQueuesHealthcheck(final Clock clock,
                                     final NotificationQueueService notificationQueueService,
                                     final PersistentBus bus,
                                     @Named("externalBus") final PersistentBus externalBus); @Managed(description = "Kill Bill queues healthcheck") boolean isHealthy(); @Managed(description = "Deactivate healthcheck") void deactivateHealthcheck(); @Managed(description = "Activate healthcheck") void activateHealthcheck(); @Override Result check();  }