Updated Branches:
  refs/heads/apache-blur-0.2 827036f94 -> 46ded8a75

Fixed BLUR-252


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

Branch: refs/heads/apache-blur-0.2
Commit: 46ded8a75c4331069a8e48091410478386fff19a
Parents: 827036f
Author: Aaron McCurry <[email protected]>
Authored: Fri Oct 4 16:38:04 2013 -0400
Committer: Aaron McCurry <[email protected]>
Committed: Fri Oct 4 16:38:04 2013 -0400

----------------------------------------------------------------------
 .../main/java/org/apache/blur/thrift/TableAdmin.java    | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/46ded8a7/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java 
b/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
index 271ad62..4bb826e 100644
--- a/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
+++ b/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
@@ -98,6 +98,7 @@ public abstract class TableAdmin implements Iface {
     try {
       TableContext.clear();
       BlurUtil.validateTableName(tableDescriptor.getName());
+      assignClusterIfNull(tableDescriptor);
       _clusterStatus.createTable(tableDescriptor);
     } catch (Exception e) {
       LOG.error("Unknown error during create of [table={0}, 
tableDescriptor={1}]", e, tableDescriptor.name,
@@ -109,6 +110,17 @@ public abstract class TableAdmin implements Iface {
     }
   }
 
+  private void assignClusterIfNull(TableDescriptor tableDescriptor) throws 
BlurException, TException {
+    if (tableDescriptor.getCluster() == null) {
+      List<String> shardClusterList = shardClusterList();
+      if (shardClusterList != null && shardClusterList.size() == 1) {
+        String cluster = shardClusterList.get(0);
+        tableDescriptor.setCluster(cluster);
+        LOG.info("Assigning table [{0}] to the single default cluster [{1}]", 
tableDescriptor.getName(), cluster);
+      }
+    }
+  }
+
   @Override
   public final void disableTable(String table) throws BlurException, 
TException {
     try {

Reply via email to