incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject git commit: BLU:168 added validation on setting cluster name from shell
Date Mon, 22 Jul 2013 10:54:31 GMT
Updated Branches:
  refs/heads/master 823b0d832 -> c7bb4ce6e


BLU:168 added validation on setting cluster name from shell


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

Branch: refs/heads/master
Commit: c7bb4ce6e245d753df013279d79508574bf09f0d
Parents: 823b0d8
Author: Gagan <gagandeepjuneja@gmail.com>
Authored: Mon Jul 22 16:24:09 2013 +0530
Committer: Gagan <gagandeepjuneja@gmail.com>
Committed: Mon Jul 22 16:24:09 2013 +0530

----------------------------------------------------------------------
 .../main/java/org/apache/blur/shell/Main.java   | 21 +++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c7bb4ce6/blur-shell/src/main/java/org/apache/blur/shell/Main.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/Main.java b/blur-shell/src/main/java/org/apache/blur/shell/Main.java
index 7b53552..16c887e 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/Main.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/Main.java
@@ -133,11 +133,26 @@ public class Main {
       if (args.length != 2) {
         throw new CommandException("Invalid args: " + help());
       }
-      cluster = args[1];
-      out.println("cluster is now " + cluster);
+      String clusterNamePassed = args[1];
+      if(validateClusterName(client, clusterNamePassed)) {
+    	  cluster = clusterNamePassed;
+    	  out.println("cluster is now " + cluster);
+      }else{
+    	  out.println("[ " + clusterNamePassed + " ]"+" is not a valid cluster name.");
+      }
     }
 
-    @Override
+    private boolean validateClusterName(Iface client, String clusterName) throws BlurException,
TException {
+    	List<String> clusterNamesList = client.shardClusterList();
+    	if(clusterNamesList != null && !clusterNamesList.isEmpty()){
+    		if(clusterNamesList.contains(clusterName)){
+    			return true;
+    		}
+    	}
+    	return false;
+	}
+
+	@Override
     public String help() {
       return "set the cluster in use, args; clustername";
     }


Mime
View raw message