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:12:52 UTC

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

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

 ##########
 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
+        }
+      }
+    }
+
+    // Remove all currently pending files
+    Set<Path> deletedPaths = new HashSet<>(pathModTimes.keySet());
+    deletedPaths.removeAll(paths);
+
+    // Exit early if we have no replicated files to report on
+    if (deletedPaths.isEmpty()) {
+      return;
+    }
+
+    replicationQueueTimeStat.resetMinMax();
+
+    for (Path path : deletedPaths) {
+      // Remove this path and add the latency
+      long modTime = pathModTimes.remove(path);
 
 Review comment:
   I was actually thinking how best to handle this.  It'd be an implementation error if the path to be removed wasn't in `pathModTimes`, since `deletedPaths` is a subset of `pathModTimes`.  Maybe check for existence and log an error if it doesn't exist?
 
----------------------------------------------------------------
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