ACCUMULO-2331 Actually invalidate the cache in TableConfiguration when 
requested.

TableConfiguration previously didn't override invalidateCache, which means that
the implementations that used it and the invalidateCache method, were not 
providing
the semantics that were intended. Fix the case in SimpleTest that outlined this 
issue,
removing the additional poll/check loop as it was both broken and unnecessary 
with
proper API implementation.


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

Branch: refs/heads/master
Commit: 510140ad0cae2d54bc4c097c94cf4b024f3655bf
Parents: 2c4b38c
Author: Josh Elser <els...@apache.org>
Authored: Fri Feb 7 10:30:45 2014 -0500
Committer: Josh Elser <els...@apache.org>
Committed: Fri Feb 7 10:30:45 2014 -0500

----------------------------------------------------------------------
 .../java/org/apache/accumulo/proxy/SimpleTest.java    |  5 -----
 .../accumulo/server/conf/TableConfiguration.java      | 14 +++++++++++++-
 2 files changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/510140ad/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
----------------------------------------------------------------------
diff --git a/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java 
b/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
index 6e591af..9dab290 100644
--- a/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
+++ b/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
@@ -1075,11 +1075,6 @@ public class SimpleTest {
     Map<String,String> orig = client.getTableProperties(creds, "test");
     client.setTableProperty(creds, "test", "table.split.threshold", "500M");
     Map<String,String> update = client.getTableProperties(creds, "test");
-    for (int i = 0; i < 5; i++) {
-      if (update.get("table.split.threshold").equals("500M"))
-        break;
-      UtilWaitThread.sleep(200);
-    }
     assertEquals(update.get("table.split.threshold"), "500M");
     client.removeTableProperty(creds, "test", "table.split.threshold");
     update = client.getTableProperties(creds, "test");

http://git-wip-us.apache.org/repos/asf/accumulo/blob/510140ad/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
----------------------------------------------------------------------
diff --git 
a/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java 
b/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
index c5b6c18..59ff1f7 100644
--- 
a/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
+++ 
b/server/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
@@ -38,7 +38,8 @@ import org.apache.log4j.Logger;
 public class TableConfiguration extends AccumuloConfiguration {
   private static final Logger log = Logger.getLogger(TableConfiguration.class);
   
-  private static ZooCache tablePropCache = null;
+  // Need volatile keyword to ensure double-checked locking works as intended
+  private static volatile ZooCache tablePropCache = null;
   private final String instanceId;
   private final AccumuloConfiguration parent;
   
@@ -147,4 +148,15 @@ public class TableConfiguration extends 
AccumuloConfiguration {
   public String getTableId() {
     return table;
   }
+
+  @Override
+  public void invalidateCache() {
+    if (null != tablePropCache) {
+      synchronized (TableConfiguration.class) {
+        if (null != tablePropCache) {
+          tablePropCache = null;
+        }
+      }
+    }
+  }
 }

Reply via email to