Use Duration instead of int for HEARTBEAT_INTERVAL

The HEARTBEAT_INTERVAL was an int with the implicit unit of seconds.

Duration is an amount of time that can be accessed using any
time unit as needed by the caller.

Change-Id: I40efed491004cd2d2e275bf0fe5dc2443b7d3d3a
diff --git a/src/main/java/com/googlesource/gerrit/plugins/spannerrefdb/Lock.java b/src/main/java/com/googlesource/gerrit/plugins/spannerrefdb/Lock.java
index 94b908b..4f2ea21 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/spannerrefdb/Lock.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/spannerrefdb/Lock.java
@@ -31,6 +31,7 @@
 import com.google.gerrit.server.config.GerritInstanceId;
 import com.google.inject.Inject;
 import com.google.inject.assistedinject.Assisted;
+import java.time.Duration;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.concurrent.ScheduledExecutorService;
@@ -55,7 +56,7 @@
   }
 
   private static final Long SECONDS_FOR_STALE_HEARTBEAT = 30L;
-  private static final int HEARTBEAT_INTERVAL = 2;
+  private static final Duration HEARTBEAT_INTERVAL = Duration.ofSeconds(2);
   private static final String RECLAIM_LOCK_PREFIX = "RECLAIM";
   private final DatabaseClient dbClient;
   private final String gerritInstanceId;
@@ -101,7 +102,7 @@
       token = transactionRunner.getCommitTimestamp();
       heartbeatTask =
           heartbeatExecutor.scheduleAtFixedRate(
-              this::heartbeat, 0, HEARTBEAT_INTERVAL, TimeUnit.SECONDS);
+              this::heartbeat, 0, HEARTBEAT_INTERVAL.toSeconds(), TimeUnit.SECONDS);
       logger.atFine().log("Locked %s %s.", projectName, refName);
     } catch (Exception e) {
       Throwable cause = e.getCause();
@@ -168,7 +169,7 @@
     if (success) {
       token = transactionRunner.getCommitTimestamp();
       heartbeatExecutor.scheduleAtFixedRate(
-          this::heartbeat, 0, HEARTBEAT_INTERVAL, TimeUnit.SECONDS);
+          this::heartbeat, 0, HEARTBEAT_INTERVAL.toSeconds(), TimeUnit.SECONDS);
       logger.atFine().log("Reclaimed lock for %s %s.", projectName, refName);
     }
     return success;