incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Fixing a bug where the table context caches the wrong version of the table descriptor.
Date Wed, 15 Oct 2014 00:41:07 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master 239cdb795 -> 72dccb812


Fixing a bug where the table context caches the wrong version of the table descriptor.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/72dccb81
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/72dccb81
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/72dccb81

Branch: refs/heads/master
Commit: 72dccb812d36ccfa73d094afdd62f10018b14c0b
Parents: 239cdb7
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Oct 14 20:41:07 2014 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Oct 14 20:41:07 2014 -0400

----------------------------------------------------------------------
 .../clusterstatus/ZookeeperClusterStatus.java     |  4 ++--
 .../java/org/apache/blur/server/TableContext.java | 18 +++++++++++++++---
 2 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/72dccb81/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java
b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java
index 0b2e3fe..01d7892 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java
@@ -155,14 +155,14 @@ public class ZookeeperClusterStatus extends ClusterStatus {
         }
         _tableDescriptorCache.remove(table);
       }
-      for (String table : newTables) {
+      for (final String table : newTables) {
         final String clusterTableKey = getClusterTableKey(_cluster, table);
         WatchNodeData enabledWatcher = new WatchNodeData(_zk, ZookeeperPathConstants.getTablePath(_cluster,
table));
         enabledWatcher.watch(new WatchNodeData.OnChange() {
           @Override
           public void action(byte[] data) {
             runActions();
-            _tableDescriptorCache.clear();
+            _tableDescriptorCache.remove(table);
           }
         });
         if (_enabledWatchNodeExistance.putIfAbsent(clusterTableKey, enabledWatcher) != null)
{

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/72dccb81/blur-core/src/main/java/org/apache/blur/server/TableContext.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/server/TableContext.java b/blur-core/src/main/java/org/apache/blur/server/TableContext.java
index 372b5b9..2eb8631 100644
--- a/blur-core/src/main/java/org/apache/blur/server/TableContext.java
+++ b/blur-core/src/main/java/org/apache/blur/server/TableContext.java
@@ -63,7 +63,7 @@ import org.apache.lucene.search.Filter;
 import org.apache.lucene.search.similarities.Similarity;
 import org.apache.lucene.store.Directory;
 
-public class TableContext {
+public class TableContext implements Cloneable {
 
   private static final Log LOG = LogFactory.getLog(TableContext.class);
 
@@ -123,7 +123,10 @@ public class TableContext {
     }
     TableContext tableContext = _cache.get(name);
     if (tableContext != null) {
-      return tableContext;
+      TableDescriptor newTd = new TableDescriptor(tableDescriptor);
+      TableContext clone = tableContext.clone();
+      clone._descriptor = newTd;
+      return clone;
     }
     LOG.info("Creating table context for table [{0}]", name);
     Configuration configuration = getSystemConfiguration();
@@ -191,7 +194,7 @@ public class TableContext {
     // DEFAULT_INTERCEPTOR
 
     _cache.put(name, tableContext);
-    return tableContext;
+    return tableContext.clone();
   }
 
   @SuppressWarnings("unchecked")
@@ -363,4 +366,13 @@ public class TableContext {
     return _readInterceptor;
   }
 
+  @Override
+  public TableContext clone() {
+    try {
+      return (TableContext) super.clone();
+    } catch (CloneNotSupportedException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
 }


Mime
View raw message