You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by gi...@git.apache.org on 2017/10/11 16:07:38 UTC

[GitHub] joshelser commented on a change in pull request #305: [ACCUMULO-4591] Add replication latency metrics

joshelser commented on a change in pull request #305: [ACCUMULO-4591] Add replication latency metrics
URL: https://github.com/apache/accumulo/pull/305#discussion_r144057720
 
 

 ##########
 File path: server/master/src/main/java/org/apache/accumulo/master/metrics/Metrics2ReplicationMetrics.java
 ##########
 @@ -124,4 +142,55 @@ protected int getNumConfiguredPeers() {
   protected int getMaxReplicationThreads() {
     return replicationUtil.getMaxReplicationThreads(master.getMasterMonitorInfo());
   }
+
+  protected void addReplicationQueueTimeMetrics() {
+    // Exit early if replication table is offline
+    if (TableState.ONLINE != Tables.getTableState(master.getInstance(), ReplicationTable.ID)) {
+      return;
+    }
+
+    // Exit early if we have no replication peers configured
+    if (replicationUtil.getPeers().isEmpty()) {
+      return;
+    }
+
+    Set<Path> paths = replicationUtil.getPendingReplicationPaths();
+
+    // We'll take a snap of the current time and use this as a diff between any deleted
+    // file's modification time and now. The reported latency will be off by at most a
+    // number of seconds equal to the metric polling period
+    long currentTime = System.currentTimeMillis();
+
+    // Iterate through all the pending paths and update the mod time if we don't know it yet
+    for (Path path : paths) {
+      if (!pathModTimes.containsKey(path)) {
+        try {
+          pathModTimes.put(path, master.getFileSystem().getFileStatus(path).getModificationTime());
+        } catch (IOException e) {
+          // Ignore all IOExceptions
+          // Either the system is unavailable or the file was deleted
+          // since the initial scan and this check
 
 Review comment:
   Add a `log.trace` in case you/someone ever runs into troubles and wants to try to debug this.
 
----------------------------------------------------------------
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