public static boolean shouldBackoff(long initialTimestamp, TimeUnit unitInitial, int failedAttempts,
                                        long defaultInterval, long maxBackoffInterval) {
        long initialTimestampInNano = unitInitial.toNanos(initialTimestamp);
        long currentTime = System.nanoTime();
        long interval = defaultInterval;
        for (int i = 1; i < failedAttempts; i++) {
            interval = interval * 2;
            if (interval > maxBackoffInterval) {
                interval = maxBackoffInterval;
                break;
            }
        }

        // if the current time is less than the time at which next retry should occur, we should backoff
        return currentTime < (initialTimestampInNano + interval);
    }
@Test
    public void shouldBackoffTest() {
        // gives false
        assertFalse(Backoff.shouldBackoff(0L, TimeUnit.NANOSECONDS, 0));
        long currentTimestamp = System.nanoTime();
        // gives true
        assertTrue(Backoff.shouldBackoff(currentTimestamp, TimeUnit.NANOSECONDS, 100));
    }