Author: bdekruijff at gmail.com
Date: Tue Jan 11 10:28:35 2011
New Revision: 583

Log:
[sandbox] allign with fabric r502

Modified:
   
sandbox/bdekruijff/fabrictest/src/main/java/org/amdatu/core/fabrictest/shell/FabricManagerCommand.java
   
sandbox/bdekruijff/fabrictest/src/main/java/org/amdatu/core/fabrictest/shell/FabricTestCommand.java

Modified: 
sandbox/bdekruijff/fabrictest/src/main/java/org/amdatu/core/fabrictest/shell/FabricManagerCommand.java
==============================================================================
--- 
sandbox/bdekruijff/fabrictest/src/main/java/org/amdatu/core/fabrictest/shell/FabricManagerCommand.java
      (original)
+++ 
sandbox/bdekruijff/fabrictest/src/main/java/org/amdatu/core/fabrictest/shell/FabricManagerCommand.java
      Tue Jan 11 10:28:35 2011
@@ -22,8 +22,6 @@
 import java.util.StringTokenizer;
 
 import org.amdatu.core.fabric.FabricManagerService;
-import org.amdatu.core.fabric.cluster.ClusterMemberService;
-import 
org.amdatu.core.fabric.cluster.service.tribes.TribesClusterMemberServiceImpl;
 import org.apache.felix.shell.Command;
 
 public final class FabricManagerCommand implements Command {
@@ -39,23 +37,20 @@
     }
 
     public String getUsage() {
-        return "Usage: fman <create|remove> 
<cluster|servicegroup|discovery|distribution|fabric> [...]\n";
+        return "Usage: fman <create|remove> 
<clusterchannel|servicegroup|discovery|distribution|fabric> [...]\n";
     }
 
     public void execute(String s, PrintStream out, PrintStream err) {
-
         if (m_fabricManagerService == null) {
             out.println("FabricManagerService unavailable");
             return;
         }
-
         StringTokenizer st = new StringTokenizer(s, " ");
         st.nextToken(); // ignore command itself
         if (st.countTokens() == 0) {
             out.print(getUsage());
             return;
         }
-
         String command = st.nextToken();
         if (command.equals("create")) {
             executeCreateCommand(rejoinRemainingTokens(st), out, err);
@@ -71,15 +66,18 @@
     private void executeCreateCommand(String s, PrintStream out, PrintStream 
err) {
         StringTokenizer st = new StringTokenizer(s, " ");
         if (st.countTokens() < 1) {
-            out.print("fman create <cluster|discovery|distribution> [...]\n");
+            out.print("fman create 
<clusterchannel|servicegroup|discovery|distribution|fabric> [...]\n");
             return;
         }
-
         String command = st.nextToken();
-        if (command.equals("cluster")) {
+        if (command.equals("clusterchannel")) {
             executeClusterMemberCreateCommand(rejoinRemainingTokens(st), out, 
err);
             return;
         }
+        if (command.equals("servicegroup")) {
+            executeServiceGroupCreateCommand(rejoinRemainingTokens(st), out, 
err);
+            return;
+        }
         if (command.equals("discovery")) {
             executeDiscoveryCreateCommand(rejoinRemainingTokens(st), out, err);
             return;
@@ -92,26 +90,25 @@
             executeFabricCreateCommand(rejoinRemainingTokens(st), out, err);
             return;
         }
-        if (command.equals("servicegroup")) {
-            executeServiceGroupCreateCommand(rejoinRemainingTokens(st), out, 
err);
-            return;
-        }
-        out.print("fman create <cluster|discovery|distribution> [...]\n");
+        out.print("fman create 
<clusterchannel|servicegroup|discovery|distribution|fabric> [...]\n");
         return;
     }
 
     private void executeRemoveCommand(String s, PrintStream out, PrintStream 
err) {
         StringTokenizer st = new StringTokenizer(s, " ");
         if (st.countTokens() < 2) {
-            out.print("fman remove <cluster|discovery|distribution> 
<fabricId>\n");
+            out.print("fman remove 
<clusterchannel|discovery|distribution|fabric> <clusterchannel>\n");
             return;
         }
-
         String command = st.nextToken();
-        if (command.equals("cluster")) {
+        if (command.equals("clusterchannel")) {
             executeClusterMemberRemoveCommand(rejoinRemainingTokens(st), out, 
err);
             return;
         }
+        if (command.equals("servicegroup")) {
+            executeServiceGroupRemoveCommand(rejoinRemainingTokens(st), out, 
err);
+            return;
+        }
         if (command.equals("discovery")) {
             executeDiscoveryRemoveCommand(rejoinRemainingTokens(st), out, err);
             return;
@@ -124,10 +121,6 @@
             executeFabricRemoveCommand(rejoinRemainingTokens(st), out, err);
             return;
         }
-        if (command.equals("servicegroup")) {
-            executeServiceGroupRemoveCommand(rejoinRemainingTokens(st), out, 
err);
-            return;
-        }
         out.print("fman remove <cluster|discovery|distribution>\n");
         return;
     }
@@ -135,198 +128,190 @@
     private void executeClusterMemberCreateCommand(String s, PrintStream out, 
PrintStream err) {
         StringTokenizer st = new StringTokenizer(s, " ");
         if (st.countTokens() < 1) {
-            out.print("fman create cluster <clusterGroup> <clusterMember> 
[options]\n");
+            out.print("fman create clusterchannel <clusterChannelName> 
[options]\n");
             return;
         }
-        String clusterGroupId = st.nextToken();
-        String clusterMemberId = st.nextToken();
-
-        int argc = st.countTokens();
-        String[] args = new String[argc];
-        int index = 0;
+        String clusterChannelName = st.nextToken();
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
         while (st.hasMoreTokens()) {
-            args[index++] = st.nextToken();
+            String val = st.nextToken();
+            if (!val.startsWith("-")) {
+                err.println("Error parsing args... should be of form 
-argument=value");
+                return;
+            }
+            val = val.substring(1);
+            String[] vals = val.split("=");
+            if (vals.length != 2) {
+                err.println("Error parsing args... should be of form 
-argument=value");
+                return;
+            }
+            props.put(vals[0], vals[1]);
         }
 
-        Dictionary<String, Object> props = new Hashtable<String, Object>();
-        props.put(ClusterMemberService.SERVICE_CLUSTERCHANNEL_PROPERTY, 
clusterGroupId);
-        props.put(ClusterMemberService.SERVICE_CLUSTERMEMBER_PROPERTY, 
clusterMemberId);
-        props.put(TribesClusterMemberServiceImpl.CLUSTER_TRIBES_ARGS_PROP, 
args);
-        if (m_fabricManagerService.createClusterMember(clusterGroupId, 
clusterMemberId, props)) {
-            out.println("New cluster created: " + clusterGroupId + "/" + 
clusterMemberId);
+        if (m_fabricManagerService.createClusterChannel(clusterChannelName, 
props)) {
+            out.println("New clusterchannel created: " + clusterChannelName);
             return;
         }
-        out.println("Failed to create cluster: " + clusterGroupId + "/" + 
clusterMemberId);
+        out.println("Failed to create clusterchannel: " + clusterChannelName);
     }
 
     private void executeClusterMemberRemoveCommand(String s, PrintStream out, 
PrintStream err) {
         StringTokenizer st = new StringTokenizer(s, " ");
         if (st.countTokens() != 1) {
-            out.print("fman remove cluster <clusterGroup> <clusterMember>\n");
+            out.print("fman remove clusterchannel <clusterChannelName>\n");
         }
-        String clusterGroupId = st.nextToken();
-        String clusterMemberId = st.nextToken();
-
-        if (m_fabricManagerService.removeClusterMember(clusterGroupId, 
clusterMemberId)) {
-            out.println("Cluster removed: " + clusterGroupId + "/" + 
clusterMemberId);
+        String clusterChannelName = st.nextToken();
+        if (m_fabricManagerService.removeClusterChannel(clusterChannelName)) {
+            out.println("Clusterchannel removed: " + clusterChannelName);
             return;
         }
-        out.println("Failed to remove cluster: " + clusterGroupId + "/" + 
clusterMemberId);
-
+        out.println("Failed to remove clusterchannel: " + clusterChannelName);
     }
 
     private void executeFabricCreateCommand(String s, PrintStream out, 
PrintStream err) {
         StringTokenizer st = new StringTokenizer(s, " ");
         if (st.countTokens() < 3) {
-            out.print("fman create fabric <clusterGroup> <clusterMember> 
<serviceGroup> [options]\n");
+            out.print("fman create fabric <clusterChannelName> 
<serviceGroupname> [clusterChannelOptions]\n");
             return;
         }
-        String clusterGroupId = st.nextToken();
-        String clusterMemberId = st.nextToken();
-        String serviceGroupId = st.nextToken();
-
-        int argc = st.countTokens();
-        String[] args = new String[argc];
-        int index = 0;
+        String clusterChannelName = st.nextToken();
+        String serviceGroupName = st.nextToken();
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
         while (st.hasMoreTokens()) {
-            args[index++] = st.nextToken();
+            String val = st.nextToken();
+            if (!val.startsWith("-")) {
+                err.println("Error parsing args... should be of form 
-argument=value");
+                return;
+            }
+            String[] vals = val.split("=");
+            if (vals.length != 2) {
+                err.println("Error parsing args... should be of form 
-argument=value");
+                return;
+            }
+            props.put(vals[0], vals[1]);
         }
-
-        Dictionary<String, Object> props = new Hashtable<String, Object>();
-        props.put(ClusterMemberService.SERVICE_CLUSTERCHANNEL_PROPERTY, 
clusterGroupId);
-        props.put(ClusterMemberService.SERVICE_CLUSTERMEMBER_PROPERTY, 
clusterMemberId);
-        props.put(TribesClusterMemberServiceImpl.CLUSTER_TRIBES_ARGS_PROP, 
args);
-        if (m_fabricManagerService.createClusterMember(clusterGroupId, 
clusterMemberId, props)
-                        && 
m_fabricManagerService.createDistribution(clusterGroupId, serviceGroupId)
-                        && 
m_fabricManagerService.createDiscovery(clusterGroupId, serviceGroupId)) {
-            out.println("New fabric created: " + clusterGroupId + "/" + 
clusterMemberId + "/" + serviceGroupId);
+        if (m_fabricManagerService.createClusterChannel(clusterChannelName, 
null)
+                        && 
m_fabricManagerService.createDistribution(clusterChannelName, serviceGroupName)
+                        && 
m_fabricManagerService.createDiscovery(clusterChannelName, serviceGroupName)) {
+            out.println("New fabric created: " + clusterChannelName + "/" + 
serviceGroupName);
             return;
         }
-        m_fabricManagerService.removeDiscovery(clusterGroupId, serviceGroupId);
-        m_fabricManagerService.removeDistribution(clusterGroupId, 
serviceGroupId);
-        m_fabricManagerService.removeClusterMember(clusterGroupId, 
clusterMemberId);
-        out.println("Failed to create fabric: " + clusterGroupId + "/" + 
clusterMemberId + "/" + serviceGroupId);
+        m_fabricManagerService.removeDiscovery(clusterChannelName, 
serviceGroupName);
+        m_fabricManagerService.removeDistribution(clusterChannelName, 
serviceGroupName);
+        m_fabricManagerService.removeClusterChannel(clusterChannelName);
+        out.println("Failed to create fabric: " + clusterChannelName + "/" + 
serviceGroupName);
     }
 
     private void executeFabricRemoveCommand(String s, PrintStream out, 
PrintStream err) {
         StringTokenizer st = new StringTokenizer(s, " ");
         if (st.countTokens() != 3) {
-            out.print("fman remove fabric <clusterGroup> <clusterMember> 
<serviceGroup>\n");
+            out.print("fman remove fabric <clusterChannelname> 
<serviceGroupName> \n");
             return;
         }
-        String clusterGroupId = st.nextToken();
-        String clusterMemberId = st.nextToken();
-        String serviceGroupId = st.nextToken();
-
-        if (m_fabricManagerService.removeDiscovery(clusterGroupId, 
serviceGroupId)
-                        && 
m_fabricManagerService.removeDistribution(clusterGroupId, serviceGroupId)
-                        && 
m_fabricManagerService.removeClusterMember(clusterGroupId, clusterMemberId)) {
-            out.println("Fabric removed: " + clusterGroupId + "/" + 
clusterMemberId + "/" + serviceGroupId);
+        String clusterChannelName = st.nextToken();
+        String serviceGroupName = st.nextToken();
+        if (m_fabricManagerService.removeDiscovery(clusterChannelName, 
serviceGroupName)
+                        && 
m_fabricManagerService.removeDistribution(clusterChannelName, serviceGroupName)
+                        && 
m_fabricManagerService.removeClusterChannel(clusterChannelName)) {
+            out.println("Fabric removed: " + clusterChannelName + "/" + 
serviceGroupName);
             return;
         }
-        m_fabricManagerService.removeDiscovery(clusterGroupId, serviceGroupId);
-        m_fabricManagerService.removeDistribution(clusterGroupId, 
serviceGroupId);
-        m_fabricManagerService.removeClusterMember(clusterGroupId, 
clusterMemberId);
+        m_fabricManagerService.removeDiscovery(clusterChannelName, 
serviceGroupName);
+        m_fabricManagerService.removeDistribution(clusterChannelName, 
serviceGroupName);
+        m_fabricManagerService.removeClusterChannel(clusterChannelName);
     }
 
     private void executeServiceGroupCreateCommand(String s, PrintStream out, 
PrintStream err) {
         StringTokenizer st = new StringTokenizer(s, " ");
         if (st.countTokens() != 2) {
-            out.print("fman create servicegroup <clusterGroup> 
<serviceGroup>\n");
+            out.print("fman create servicegroup <clusterChannelName> 
<serviceGroupName>\n");
             return;
         }
-        String clusterGroupId = st.nextToken();
-        String serviceGroupId = st.nextToken();
-
-        if (m_fabricManagerService.createDistribution(clusterGroupId, 
serviceGroupId)
-                        && 
m_fabricManagerService.createDiscovery(clusterGroupId, serviceGroupId)) {
-            out.println("Servicegroup created: " + clusterGroupId + "/" + 
serviceGroupId);
+        String clusterChannelName = st.nextToken();
+        String serviceGroupName = st.nextToken();
+        if (m_fabricManagerService.createDistribution(clusterChannelName, 
serviceGroupName)
+                        && 
m_fabricManagerService.createDiscovery(clusterChannelName, serviceGroupName)) {
+            out.println("Servicegroup created: " + clusterChannelName + "/" + 
serviceGroupName);
             return;
         }
-        m_fabricManagerService.removeDiscovery(clusterGroupId, serviceGroupId);
-        m_fabricManagerService.removeDistribution(clusterGroupId, 
serviceGroupId);
-        out.println("Failed to create servicegroup: " + clusterGroupId + "/" + 
serviceGroupId);
+        m_fabricManagerService.removeDiscovery(clusterChannelName, 
serviceGroupName);
+        m_fabricManagerService.removeDistribution(clusterChannelName, 
serviceGroupName);
+        out.println("Failed to create servicegroup: " + clusterChannelName + 
"/" + serviceGroupName);
     }
 
     private void executeServiceGroupRemoveCommand(String s, PrintStream out, 
PrintStream err) {
         StringTokenizer st = new StringTokenizer(s, " ");
         if (st.countTokens() != 2) {
-            out.print("fman remove servicegroup <clusterGroup> 
<serviceGroup>\n");
+            out.print("fman remove servicegroup <clusterChannelName> 
<serviceGroupName>\n");
             return;
         }
-        String clusterGroupId = st.nextToken();
-        String serviceGroupId = st.nextToken();
-
-        if (m_fabricManagerService.removeDiscovery(clusterGroupId, 
serviceGroupId)
-                        && 
m_fabricManagerService.removeDistribution(clusterGroupId, serviceGroupId)) {
-            out.println("Servicegroup removed: " + clusterGroupId + "/" + 
serviceGroupId);
+        String clusterChannelName = st.nextToken();
+        String serviceGroupName = st.nextToken();
+        if (m_fabricManagerService.removeDiscovery(clusterChannelName, 
serviceGroupName)
+                        && 
m_fabricManagerService.removeDistribution(clusterChannelName, 
serviceGroupName)) {
+            out.println("Servicegroup removed: " + clusterChannelName + "/" + 
serviceGroupName);
             return;
         }
-        m_fabricManagerService.removeDiscovery(clusterGroupId, serviceGroupId);
-        m_fabricManagerService.removeDistribution(clusterGroupId, 
serviceGroupId);
+        m_fabricManagerService.removeDiscovery(clusterChannelName, 
serviceGroupName);
+        m_fabricManagerService.removeDistribution(clusterChannelName, 
serviceGroupName);
     }
 
     private void executeDiscoveryCreateCommand(String s, PrintStream out, 
PrintStream err) {
         StringTokenizer st = new StringTokenizer(s, " ");
         if (st.countTokens() != 2) {
-            out.print("fman create discovery <clusterGroup> <serviceGroup>");
+            out.print("fman create discovery <clusterChannelName> 
<serviceGroupName>");
             return;
         }
-        String clusterGroupId = st.nextToken();
-        String serviceGroupId = st.nextToken();
-
-        if (m_fabricManagerService.createDiscovery(clusterGroupId, 
serviceGroupId)) {
-            out.println("New discovery created: " + clusterGroupId + "/" + 
serviceGroupId);
+        String clusterChannelName = st.nextToken();
+        String serviceGroupName = st.nextToken();
+        if (m_fabricManagerService.createDiscovery(clusterChannelName, 
serviceGroupName)) {
+            out.println("New discovery created: " + clusterChannelName + "/" + 
serviceGroupName);
             return;
         }
-        out.println("Failed to create discovery: " + clusterGroupId + "/" + 
serviceGroupId);
+        out.println("Failed to create discovery: " + clusterChannelName + "/" 
+ serviceGroupName);
     }
 
     private void executeDiscoveryRemoveCommand(String s, PrintStream out, 
PrintStream err) {
         StringTokenizer st = new StringTokenizer(s, " ");
         if (st.countTokens() != 3) {
-            out.print("fman remove discovery <clusterGroup> <serviceGroup>");
+            out.print("fman remove discovery <clusterChannelName> 
<serviceGroupName>");
         }
-        String clusterGroupId = st.nextToken();
-        String serviceGroupId = st.nextToken();
-
-        if (m_fabricManagerService.removeDiscovery(clusterGroupId, 
serviceGroupId)) {
-            out.println("Discovery removed: " + clusterGroupId + "/" + 
serviceGroupId);
+        String clusterChannelName = st.nextToken();
+        String serviceGroupName = st.nextToken();
+        if (m_fabricManagerService.removeDiscovery(clusterChannelName, 
serviceGroupName)) {
+            out.println("Discovery removed: " + clusterChannelName + "/" + 
serviceGroupName);
             return;
         }
-        out.println("Failed to remove discovery: " + clusterGroupId + "/" + 
serviceGroupId);
-
+        out.println("Failed to remove discovery: " + clusterChannelName + "/" 
+ serviceGroupName);
     }
 
     private void executeDistributionCreateCommand(String s, PrintStream out, 
PrintStream err) {
         StringTokenizer st = new StringTokenizer(s, " ");
         if (st.countTokens() != 3) {
-            out.print("fman create distribution <clusterGroup> 
<serviceGroup>");
+            out.print("fman create distribution <clusterChannelName> 
<serviceGroupName>");
             return;
         }
-        String clusterGroupId = st.nextToken();
-        String serviceGroupId = st.nextToken();
-
-        if (m_fabricManagerService.createDistribution(clusterGroupId, 
serviceGroupId)) {
-            out.println("New distribution created: " + clusterGroupId + "/" + 
serviceGroupId);
+        String clusterChannelName = st.nextToken();
+        String serviceGroupName = st.nextToken();
+        if (m_fabricManagerService.createDistribution(clusterChannelName, 
serviceGroupName)) {
+            out.println("New distribution created: " + clusterChannelName + 
"/" + serviceGroupName);
             return;
         }
-        out.println("Failed to create distribution: " + clusterGroupId + "/" + 
serviceGroupId);
+        out.println("Failed to create distribution: " + clusterChannelName + 
"/" + serviceGroupName);
     }
 
     private void executeDistributionRemoveCommand(String s, PrintStream out, 
PrintStream err) {
         StringTokenizer st = new StringTokenizer(s, " ");
         if (st.countTokens() != 3) {
-            out.print("fman remove distribution <clusterGroup> 
<serviceGroup>");
+            out.print("fman remove distribution <clusterChannelName> 
<serviceGroupName>");
         }
-        String clusterGroupId = st.nextToken();
-        String serviceGroupId = st.nextToken();
-
-        if (m_fabricManagerService.removeDiscovery(clusterGroupId, 
serviceGroupId)) {
-            out.println("Distribution removed: " + clusterGroupId + "/" + 
serviceGroupId);
+        String clusterChannelName = st.nextToken();
+        String serviceGroupName = st.nextToken();
+        if (m_fabricManagerService.removeDiscovery(clusterChannelName, 
serviceGroupName)) {
+            out.println("Distribution removed: " + clusterChannelName + "/" + 
serviceGroupName);
             return;
         }
-        out.println("Failed to remove distribution: " + clusterGroupId + "/" + 
serviceGroupId);
+        out.println("Failed to remove distribution: " + clusterChannelName + 
"/" + serviceGroupName);
     }
 
     private static String rejoinRemainingTokens(StringTokenizer st) {

Modified: 
sandbox/bdekruijff/fabrictest/src/main/java/org/amdatu/core/fabrictest/shell/FabricTestCommand.java
==============================================================================
--- 
sandbox/bdekruijff/fabrictest/src/main/java/org/amdatu/core/fabrictest/shell/FabricTestCommand.java
 (original)
+++ 
sandbox/bdekruijff/fabrictest/src/main/java/org/amdatu/core/fabrictest/shell/FabricTestCommand.java
 Tue Jan 11 10:28:35 2011
@@ -100,11 +100,30 @@
             return;
         }
 
+        if (command.equals("benchmark0")) {
+            long startTime = System.currentTimeMillis();
+
+            Random r = new Random();
+            m_remotableServicesLock.readLock().lock();
+            try {
+                if (m_remotableServices.size() > 0) {
+                    int q = r.nextInt(m_remotableServices.size());
+                    m_remotableServices.get(q).hello("Bram");
+                }
+            }
+            finally {
+                m_remotableServicesLock.readLock().unlock();
+            }
+            out.println("Benchmark 0: " + (System.currentTimeMillis() - 
startTime) + " ms");
+            return;
+        }
+
         if (command.equals("benchmark1")) {
             long startTime = System.currentTimeMillis();
 
             Random r = new Random();
-            String[] names = new String[] { "Bram", "Ivo", "Mark", "Marcel", 
"Angelo", "Martijn", "Hans" };
+// String[] names = new String[] { "Bram", "Ivo", "Mark", "Marcel", "Angelo", 
"Martijn", "Hans" };
+            String[] names = new String[] { "Bram", "Ivo" };
             for (int i = 0; i < 100; i++) {
                 for (String name : names) {
                     m_remotableServicesLock.readLock().lock();

Reply via email to