@Override
  public BackupRequestsStrategyStats getStats()
  {
    return getStats(_lastDelayStats.get());
  }
@Test
  public void testGetStats()
  {

    Distribution distribution = new Distribution();

    TrackingBackupRequestsStrategy trackingStrategy =
        new TrackingBackupRequestsStrategy(new MockBackupRequestsStrategy(() -> Optional.of(distribution.next()),
            () -> ThreadLocalRandom.current().nextBoolean()));

    long totalAllowed = 0;
    long totalSuccessful = 0;
    long totalMin = Long.MAX_VALUE;
    long totalMax = Long.MIN_VALUE;

    for (int round = 0; round < 100; round++)
    {
      for (int i = 0; i < 100000; i++)
      {
        if (trackingStrategy.isBackupRequestAllowed())
        {
          if (ThreadLocalRandom.current().nextBoolean())
          {
            trackingStrategy.backupRequestSuccess();
          }
        }
        trackingStrategy.getTimeUntilBackupRequestNano();
      }
      BackupRequestsStrategyStats stats = trackingStrategy.getDiffStats();
      assertEquals((double) stats.getAllowed(), 100000d / 2, 1000d);
      assertEquals((double) stats.getSuccessful(), 100000d / 4, 1000d);
      assertEquals(stats.getMinDelayNano(), distribution._min);
      assertEquals(stats.getMaxDelayNano(), distribution._max);
      assertEquals((double) stats.getAvgDelayNano(), (double) Distribution.AVG, 1000000d);
      totalAllowed += stats.getAllowed();
      totalSuccessful += stats.getSuccessful();
      totalMin = Math.min(totalMin, stats.getMinDelayNano());
      totalMax = Math.max(totalMax, stats.getMaxDelayNano());
      distribution._min = Long.MAX_VALUE;
      distribution._max = Long.MIN_VALUE;
    }

    // total stats
    BackupRequestsStrategyStats stats = trackingStrategy.getStats();
    assertEquals(totalAllowed, stats.getAllowed());
    assertEquals(totalSuccessful, stats.getSuccessful());
    assertEquals(stats.getMinDelayNano(), totalMin);
    assertEquals(stats.getMaxDelayNano(), totalMax);
    assertEquals((double) stats.getAvgDelayNano(), (double) Distribution.AVG, 1000000d);
  }