You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whirr.apache.org by as...@apache.org on 2011/01/30 04:58:32 UTC

svn commit: r1065176 - in /incubator/whirr/trunk: CHANGES.txt cli/src/main/java/org/apache/whirr/cli/Main.java

Author: asavu
Date: Sun Jan 30 03:58:32 2011
New Revision: 1065176

URL: http://svn.apache.org/viewvc?rev=1065176&view=rev
Log:
WHIRR-195. Display available roles instead of service names when running ./bin/whirr

Modified:
    incubator/whirr/trunk/CHANGES.txt
    incubator/whirr/trunk/cli/src/main/java/org/apache/whirr/cli/Main.java

Modified: incubator/whirr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/CHANGES.txt?rev=1065176&r1=1065175&r2=1065176&view=diff
==============================================================================
--- incubator/whirr/trunk/CHANGES.txt (original)
+++ incubator/whirr/trunk/CHANGES.txt Sun Jan 30 03:58:32 2011
@@ -13,6 +13,9 @@ Trunk (unreleased changes)
 
     WHIRR-219. Support dynamic addition of services to CLI. (tomwhite)
 
+    WHIRR-195. Display available roles instead of service names 
+    when running ./bin/whirr (asavu)
+
   BUG FIXES
 
     WHIRR-170. Instances should be started in the order specified in 

Modified: incubator/whirr/trunk/cli/src/main/java/org/apache/whirr/cli/Main.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/cli/src/main/java/org/apache/whirr/cli/Main.java?rev=1065176&r1=1065175&r2=1065176&view=diff
==============================================================================
--- incubator/whirr/trunk/cli/src/main/java/org/apache/whirr/cli/Main.java (original)
+++ incubator/whirr/trunk/cli/src/main/java/org/apache/whirr/cli/Main.java Sun Jan 30 03:58:32 2011
@@ -19,6 +19,12 @@
 package org.apache.whirr.cli;
 
 import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import org.apache.whirr.cli.command.DestroyClusterCommand;
+import org.apache.whirr.cli.command.LaunchClusterCommand;
+import org.apache.whirr.cli.command.ListClusterCommand;
+import org.apache.whirr.cli.command.VersionCommand;
+import org.apache.whirr.service.ClusterActionHandler;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -26,13 +32,8 @@ import java.io.PrintStream;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
-import java.util.TreeSet;
-
-import org.apache.whirr.cli.command.DestroyClusterCommand;
-import org.apache.whirr.cli.command.LaunchClusterCommand;
-import org.apache.whirr.cli.command.ListClusterCommand;
-import org.apache.whirr.cli.command.VersionCommand;
-import org.apache.whirr.service.ServiceFactory;
+import java.util.ServiceLoader;
+import java.util.SortedSet;
 
 /**
  * The entry point for the Whirr CLI.
@@ -74,13 +75,23 @@ public class Main {
           command.getDescription());
     }
     stream.println();
-    stream.println("Available services:");
-    ServiceFactory serviceFactory = new ServiceFactory();
-    for (String serviceName : new TreeSet<String>(
-        serviceFactory.availableServices())) {
-      stream.println("  " + serviceName);
+    stream.println("Available roles for instances:");
+    for(String roleName : getSortedRoleNames()) {
+      stream.println("  " + roleName);
     }
   }
+
+  private static SortedSet<String> getSortedRoleNames() {
+    ServiceLoader<ClusterActionHandler> loader =
+     ServiceLoader.load(ClusterActionHandler.class);
+
+    SortedSet<String> roles = Sets.newTreeSet();
+    for(ClusterActionHandler handler : loader) {
+      roles.add(handler.getRole());
+    }
+    return roles;
+  }
+
   public static void main(String... args) throws Exception {
     Main main = new Main(
         new VersionCommand(),