incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rk...@apache.org
Subject git commit: Fixed issue with table properties not being persisted to zookeeper
Date Sat, 26 Oct 2013 06:39:07 GMT
Updated Branches:
  refs/heads/apache-blur-0.2 beff8bc72 -> 92f58cfae


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/92f58cfa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/92f58cfa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/92f58cfa

Branch: refs/heads/apache-blur-0.2
Commit: 92f58cfae256449ec7f337baba59e7964951bf6c
Parents: beff8bc
Author: Rahul Challapalli <challapallirahul@gmail.com>
Authored: Fri Oct 25 23:36:38 2013 -0700
Committer: Rahul Challapalli <challapallirahul@gmail.com>
Committed: Fri Oct 25 23:36:38 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/92f58cfa/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/92f58cfa/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