You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/09/21 06:23:44 UTC

[GitHub] jvrao commented on a change in pull request #1683: Enhance Auditor

jvrao commented on a change in pull request #1683: Enhance Auditor
URL: https://github.com/apache/bookkeeper/pull/1683#discussion_r219393938
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
 ##########
 @@ -884,4 +885,39 @@ public String getReplicationWorkerIdRereplicatingLedger(long ledgerId)
         }
         return replicationWorkerId;
     }
+
+    @Override
+    public void setCheckAllLedgersCTime(long checkAllLedgersCTime) throws UnavailableException {
+        LOG.debug("setCheckAllLedgersCTime");
+        try {
+            if (zkc.exists(checkAllLedgersCtimeZnode, false) != null) {
+                zkc.setData(checkAllLedgersCtimeZnode, Long.toString(checkAllLedgersCTime).getBytes(UTF_8), -1);
+            } else {
+                zkc.create(checkAllLedgersCtimeZnode, Long.toString(checkAllLedgersCTime).getBytes(UTF_8),
+                        Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+            }
+        } catch (KeeperException ke) {
+            throw new ReplicationException.UnavailableException("Error contacting zookeeper", ke);
+        } catch (InterruptedException ie) {
+            Thread.currentThread().interrupt();
+            throw new ReplicationException.UnavailableException("Interrupted while contacting zookeeper", ie);
+        }
+    }
+
+    @Override
+    public long getCheckAllLedgersCTime() throws UnavailableException {
+        LOG.debug("getCheckAllLedgersCTime");
+        try {
+            byte[] data = zkc.getData(checkAllLedgersCtimeZnode, false, null);
+            return Long.parseLong(new String(data, UTF_8));
+        } catch (KeeperException.NoNodeException ne) {
+            LOG.warn("checkAllLedgersCtimeZnode is not yet available");
+            return -1;
 
 Review comment:
   Why not create the node on auditor startup with -1; So we can make sure the state is consistent.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services