incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/2] git commit: BLUR-ID:54 Error handling for bad Shard Id
Date Fri, 08 Mar 2013 03:01:45 GMT
BLUR-ID:54 Error handling for bad Shard Id

Signed-off-by: Aaron McCurry <amccurry@gmail.com>


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

Branch: refs/heads/0.2-dev
Commit: adeeabd7f615d2ecb99aea93316359b5aede1cd5
Parents: de4fece
Author: Gagan <gagandeepjuneja@gmail.com>
Authored: Wed Mar 6 16:51:16 2013 +0530
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Thu Mar 7 22:00:32 2013 -0500

----------------------------------------------------------------------
 .../java/org/apache/blur/server/BlurServer.java    |    2 +-
 .../java/org/apache/blur/server/TableLayout.java   |    4 +++-
 .../org/apache/blur/thrift/ThriftBlurServer.java   |    6 +++++-
 3 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/adeeabd7/src/blur-core/src/main/java/org/apache/blur/server/BlurServer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/server/BlurServer.java b/src/blur-core/src/main/java/org/apache/blur/server/BlurServer.java
index 9297e44..c8decba 100644
--- a/src/blur-core/src/main/java/org/apache/blur/server/BlurServer.java
+++ b/src/blur-core/src/main/java/org/apache/blur/server/BlurServer.java
@@ -656,7 +656,7 @@ public class BlurServer extends TableAdmin implements Iface {
     return client.deleteDocuments(options, terms);
   }
 
-  private Connection getConnection(String table, int shardIndex) {
+  private Connection getConnection(String table, int shardIndex) throws BlurException {
     String server = _layout.findServer(table, shardIndex, TYPE.WRITABLE);
     return new Connection(server);
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/adeeabd7/src/blur-core/src/main/java/org/apache/blur/server/TableLayout.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/server/TableLayout.java b/src/blur-core/src/main/java/org/apache/blur/server/TableLayout.java
index 88ee8c3..d7b6ea3 100644
--- a/src/blur-core/src/main/java/org/apache/blur/server/TableLayout.java
+++ b/src/blur-core/src/main/java/org/apache/blur/server/TableLayout.java
@@ -1,5 +1,7 @@
 package org.apache.blur.server;
 
+import org.apache.blur.thrift.generated.BlurException;
+
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements. See the NOTICE file distributed with this
@@ -22,6 +24,6 @@ public abstract class TableLayout {
     WRITABLE, ONLINE, BACKUP
   }
 
-  public abstract String findServer(String table, int shard, TYPE type);
+  public abstract String findServer(String table, int shard, TYPE type) throws BlurException;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/adeeabd7/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurServer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurServer.java b/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurServer.java
index 13a37a9..03087f2 100644
--- a/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurServer.java
+++ b/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurServer.java
@@ -66,6 +66,7 @@ import org.apache.blur.store.blockcache.Cache;
 import org.apache.blur.store.buffer.BufferStore;
 import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.Blur.Processor;
+import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.utils.BlurConstants;
 import org.apache.blur.utils.BlurUtil;
 import org.apache.blur.zookeeper.ZkUtils;
@@ -212,7 +213,7 @@ public class ThriftBlurServer extends AbstractThriftServer {
 
     TableLayout layout = new TableLayout() {
       @Override
-      public String findServer(String table, int shard, TYPE type) {
+      public String findServer(String table, int shard, TYPE type) throws BlurException {

         DistributedLayoutManager manager = new DistributedLayoutManager();
         List<String> onlineServers = clusterStatus.getOnlineServers(true);
         List<String> offlineServers = clusterStatus.getOfflineServers(true);
@@ -223,6 +224,9 @@ public class ThriftBlurServer extends AbstractThriftServer {
 
         Map<String, String> map = manager.getLayout();
         String server = map.get(BlurUtil.getShardName(BlurConstants.SHARD_PREFIX, shard));
+        if(server == null){
+          throw new BlurException("Invalid Shard [ " + shard + " ]","");
+        }
         return server;
       }
 


Mime
View raw message