accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [1/2] accumulo git commit: ACCUMULO-3549 periodically clear the locator cache
Date Mon, 02 Feb 2015 22:53:02 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.6 a88299fbf -> c5d2bd54a


ACCUMULO-3549 periodically clear the locator cache


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/ed12e1f3
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/ed12e1f3
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/ed12e1f3

Branch: refs/heads/1.6
Commit: ed12e1f380736f3fcb897b95561ef94eba075aee
Parents: a88299f
Author: Eric C. Newton <eric.newton@gmail.com>
Authored: Fri Jan 30 18:01:05 2015 -0500
Committer: Eric C. Newton <eric.newton@gmail.com>
Committed: Fri Jan 30 19:31:49 2015 -0500

----------------------------------------------------------------------
 .../apache/accumulo/tserver/TabletServer.java   | 25 ++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/ed12e1f3/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
index dfec999..948d0f0 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
@@ -38,6 +38,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Random;
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.SortedSet;
@@ -64,11 +65,13 @@ import javax.management.StandardMBean;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.impl.CompressedIterators;
 import org.apache.accumulo.core.client.impl.CompressedIterators.IterConfig;
 import org.apache.accumulo.core.client.impl.ScannerImpl;
 import org.apache.accumulo.core.client.impl.Tables;
+import org.apache.accumulo.core.client.impl.TabletLocator;
 import org.apache.accumulo.core.client.impl.TabletType;
 import org.apache.accumulo.core.client.impl.Translator;
 import org.apache.accumulo.core.client.impl.Translator.TKeyExtentTranslator;
@@ -252,6 +255,7 @@ public class TabletServer extends AbstractMetricsImpl implements org.apache.accu
   private static final long MAX_TIME_TO_WAIT_FOR_SCAN_RESULT_MILLIS = 1000;
   private static final long RECENTLY_SPLIT_MILLIES = 60 * 1000;
   private static final long TIME_BETWEEN_GC_CHECKS = 5000;
+  private static final long TIME_BETWEEN_LOCATOR_CACHE_CLEARS = 60 * 60 * 1000;
 
   private TabletServerLogger logger;
 
@@ -280,6 +284,27 @@ public class TabletServer extends AbstractMetricsImpl implements org.apache.accu
         }
       }
     }, TIME_BETWEEN_GC_CHECKS, TIME_BETWEEN_GC_CHECKS);
+    SimpleTimer.getInstance().schedule(new Runnable() {
+      @Override
+      public void run() {
+        try {
+          SystemCredentials creds = SystemCredentials.get();
+          Connector connector = instance.getConnector(creds.getPrincipal(), creds.getToken());
+          for (String id : connector.tableOperations().tableIdMap().values()) {
+            TabletLocator locator = TabletLocator.getLocator(instance, new Text(id));
+            locator.invalidateCache();
+          }
+        } catch (Exception ex) {
+          log.error("Error clearing locator cache, ignoring", ex);
+        }
+      }
+    }, jitter(TIME_BETWEEN_LOCATOR_CACHE_CLEARS), jitter(TIME_BETWEEN_LOCATOR_CACHE_CLEARS));
+  }
+
+  private static long jitter(long ms) {
+    Random r = new Random();
+    // add a random 10% wait
+    return (long)(1. + (r.nextDouble() / 10) * ms);
   }
 
   private synchronized static void logGCInfo(AccumuloConfiguration conf) {


Mime
View raw message