incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rk...@apache.org
Subject [1/2] git commit: Fixed issue with table properties not being persisted to zookeeper
Date Sun, 27 Oct 2013 06:30:52 GMT
Updated Branches:
  refs/heads/master 609763bf7 -> 448ff877c


Fixed issue with table properties not being persisted to
 zookeeper


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

Branch: refs/heads/master
Commit: 15320a48c2521c5bbd85f4689b97c43d5fe41754
Parents: 294294b
Author: Rahul Challapalli <challapallirahul@gmail.com>
Authored: Fri Oct 25 23:36:38 2013 -0700
Committer: Rahul Challapalli <challapallirahul@gmail.com>
Committed: Sat Oct 26 23:30:16 2013 -0700

----------------------------------------------------------------------
 .../clusterstatus/ZookeeperClusterStatus.java   | 35 ++++++++++++++++++++
 .../clusterstatus/ZookeeperPathConstants.java   |  4 +++
 2 files changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/15320a48/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 6615f91..9a0f420 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
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -421,6 +422,7 @@ public class ZookeeperClusterStatus extends ClusterStatus {
           tableDescriptor.readOnly = internalGetReadOnly(ZookeeperPathConstants.getTableReadOnlyPath(cluster,
table));
           tableDescriptor.preCacheCols = toList(getData(ZookeeperPathConstants
               .getTableColumnsToPreCache(cluster, table)));
+          tableDescriptor.tableProperties = toMap(getData(ZookeeperPathConstants.getTablePropertiesPath(cluster,
table)));
           byte[] data = getData(ZookeeperPathConstants.getTableSimilarityPath(cluster, table));
           if (data != null) {
             tableDescriptor.similarityClass = new String(data);
@@ -743,6 +745,7 @@ public class ZookeeperClusterStatus extends ClusterStatus {
       }
       BlurUtil.createPath(_zk, ZookeeperPathConstants.getTableBlockCachingFileTypesPath(cluster,
table),
           toBytes(blockCachingFileTypes));
+      BlurUtil.createPath(_zk, ZookeeperPathConstants.getTablePropertiesPath(cluster, table),
toBytes(tableDescriptor.getTableProperties()));
     } catch (IOException e) {
       throw new RuntimeException(e);
     } catch (KeeperException e) {
@@ -860,6 +863,38 @@ public class ZookeeperClusterStatus extends ClusterStatus {
     }
     return builder.substring(0, builder.length() - 1).getBytes();
   }
+  
+  private static byte[] toBytes(Map<String,String> properties) {
+    if (properties == null || properties.isEmpty()) {
+      return null;
+    }
+    StringBuilder builder = new StringBuilder();
+    Set<Entry<String, String>> entrySet = properties.entrySet();
+    for (Entry<String, String> entry : entrySet) {
+      String key = entry.getKey();
+      String value = entry.getValue();
+      String keyValue = key+"->"+value;
+      builder.append(keyValue).append(',');
+    }
+    
+    return builder.substring(0, builder.length() - 1).getBytes();
+  }
+  
+  private static Map<String,String> toMap(byte[] mapBytes) {
+    Map<String,String> properties = new HashMap<String, String>();
+    
+    if (mapBytes == null) {
+      return null;
+    }
+    String str = new String(mapBytes);
+    String[] keyValuePairs = str.split(",");
+    for (String keyValue : keyValuePairs) {
+      String[] split = keyValue.split("->");
+      properties.put(split[0].trim(), split[1].trim());
+    }
+    
+    return properties;
+  }
 
   @Override
   public boolean isOpen() {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/15320a48/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperPathConstants.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperPathConstants.java
b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperPathConstants.java
index 5278aca..11ab6e5 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperPathConstants.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperPathConstants.java
@@ -107,4 +107,8 @@ public class ZookeeperPathConstants {
     return getClusterPath(cluster) + "/layout";
   }
 
+  public static String getTablePropertiesPath(String cluster, String table) {
+    return getTablePath(cluster, table) + "/tableproperties";
+  }
+
 }


Mime
View raw message