private Timer timer(String name) {
   Timer timer = metricRegistry.getTimers().get(name);
   if (timer != null) {
     return timer;
   }
   try {
     return metricRegistry.register(
         name,
         new Timer(new SlidingTimeWindowReservoir(timerReservoirSeconds.get(), TimeUnit.SECONDS)));
   } catch (IllegalArgumentException e) {
     // timer already exists. this happens due to race condition. its fine.
     return metricRegistry.getTimers().get(name);
   }
 }
  protected ScanResult dbScanWithThroughputBackOff(ScanRequest scanRequest) {
    Long currentBackOffMs = minBackOffMs.get();
    Long retryCount = 0L;
    while (true) {
      try {
        return dbClient.scan(scanRequest);
      } catch (ProvisionedThroughputExceededException e) {
        currentBackOffMs = Math.min(currentBackOffMs * 2, maxBackOffMs.get());
        log.error(
            String.format(
                "Failed to poll Dynamo due to ProvisionedThroughputExceededException. Backing off for %d ms.",
                currentBackOffMs));
        if (retryCount > maxRetryCount.get()) {
          throw e;
        }
        retryCount++;

        try {
          Thread.sleep(currentBackOffMs);
        } catch (InterruptedException ex) {
        }
      }
    }
  }