incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [8/8] git commit: Creating a better error message when there are no online servers found.
Date Tue, 05 Nov 2013 02:07:20 GMT
Creating a better error message when there are no online servers found.


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

Branch: refs/heads/master
Commit: f25c729b2fb21c17a4b945b60c1fa91483c9500d
Parents: e0b8264
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Nov 4 16:27:06 2013 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Nov 4 16:27:19 2013 -0500

----------------------------------------------------------------------
 .../indexserver/MasterBasedDistributedLayoutFactory.java | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f25c729b/blur-core/src/main/java/org/apache/blur/manager/indexserver/MasterBasedDistributedLayoutFactory.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/indexserver/MasterBasedDistributedLayoutFactory.java
b/blur-core/src/main/java/org/apache/blur/manager/indexserver/MasterBasedDistributedLayoutFactory.java
index 477619c..ee51ee5 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/indexserver/MasterBasedDistributedLayoutFactory.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/indexserver/MasterBasedDistributedLayoutFactory.java
@@ -138,14 +138,17 @@ public class MasterBasedDistributedLayoutFactory implements DistributedLayoutFac
   private Map<String, String> calculateNewLayout(String table, MasterBasedDistributedLayout
existingLayout,
       List<String> shardList, List<String> onlineShardServerList) {
     Set<String> shardServerSet = new TreeSet<String>(onlineShardServerList);
+    if (shardServerSet.isEmpty()) {
+      throw new RuntimeException("No online servers.");
+    }
     if (existingLayout == null) {
       // blind setup, basic round robin
       LOG.info("Blind shard layout.");
       Map<String, String> newLayoutMap = new TreeMap<String, String>();
-      Iterator<String> iterator = onlineShardServerList.iterator();
+      Iterator<String> iterator = shardServerSet.iterator();
       for (String shard : shardList) {
         if (!iterator.hasNext()) {
-          iterator = onlineShardServerList.iterator();
+          iterator = shardServerSet.iterator();
         }
         String server = iterator.next();
         newLayoutMap.put(shard, server);
@@ -168,7 +171,7 @@ public class MasterBasedDistributedLayoutFactory implements DistributedLayoutFac
 
       LOG.info("Adding in new shard servers for table [{0}]", table);
       // Add counts for new shard servers
-      for (String server : onlineShardServerList) {
+      for (String server : shardServerSet) {
         if (!onlineServerShardCount.containsKey(server)) {
           LOG.info("New shard server [{0}]", server);
           onlineServerShardCount.put(server, 0);
@@ -188,7 +191,7 @@ public class MasterBasedDistributedLayoutFactory implements DistributedLayoutFac
 
       LOG.info("Leveling any shard hotspots for table [{0}]", table);
       // Level shards
-      MasterBasedLeveler.level(shardList.size(), onlineShardServerList.size(), onlineServerShardCount,
newLayoutMap);
+      MasterBasedLeveler.level(shardList.size(), shardServerSet.size(), onlineServerShardCount,
newLayoutMap);
       return newLayoutMap;
     }
   }


Mime
View raw message