You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2013/12/18 13:29:55 UTC

[04/50] git commit: [KARAF-2141] cluster:producer/handler/consumer now display the local node

[KARAF-2141] cluster:producer/handler/consumer now display the local node

git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/branches/cellar-2.2.x@1439921 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/c2c1458f
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/c2c1458f
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/c2c1458f

Branch: refs/heads/cellar-2.2.x
Commit: c2c1458f7748160b2be872789fa63cd18b975c97
Parents: d4261cb
Author: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Tue Jan 29 15:14:55 2013 +0000
Committer: jbonofre <jb...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Tue Jan 29 15:14:55 2013 +0000

----------------------------------------------------------------------
 .../management/internal/CellarMBeanImpl.java    | 33 +++++++++++---------
 .../cellar/shell/consumer/ConsumerSupport.java  | 10 ++++--
 .../cellar/shell/handler/HandlersSupport.java   | 10 ++++--
 .../cellar/shell/producer/ProducerSupport.java  | 10 ++++--
 4 files changed, 39 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/c2c1458f/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
----------------------------------------------------------------------
diff --git a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
index a721831..3e5f370 100644
--- a/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
+++ b/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
@@ -116,9 +116,9 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
         Map<Node, ManageHandlersResult> results = executionContext.execute(command);
 
         CompositeType compositeType = new CompositeType("Event Handler", "Karaf Cellar cluster event handler",
-                new String[]{ "node", "handler", "status" },
-                new String[]{ "Node hosting event handler", "Name of the event handler", "Current status of the event handler" },
-                new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING });
+                new String[]{ "node", "handler", "status", "local" },
+                new String[]{ "Node hosting event handler", "Name of the event handler", "Current status of the event handler", "True if the node is local" },
+                new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.BOOLEAN });
         TabularType tableType = new TabularType("Event Handlers", "Table of Karaf Cellar cluster event handlers",
                 compositeType, new String[]{ "node", "handler" });
         TabularDataSupport table = new TabularDataSupport(tableType);
@@ -130,9 +130,10 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
                 for (Map.Entry<String, String> handlerEntry : result.getHandlers().entrySet()) {
                     String handler = handlerEntry.getKey();
                     String status = handlerEntry.getValue();
+                    boolean local = (node.equals(clusterManager.getNode()));
                     CompositeDataSupport data = new CompositeDataSupport(compositeType,
-                            new String[]{ "node", "handler", "status" },
-                            new Object[]{ node.getId(), handler, status });
+                            new String[]{ "node", "handler", "status", "local" },
+                            new Object[]{ node.getId(), handler, status, local });
                     table.put(data);
                 }
             }
@@ -180,18 +181,19 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
         Map<Node, ConsumerSwitchResult> results = executionContext.execute(command);
 
         CompositeType compositeType = new CompositeType("Event Consumer", "Karaf Cellar cluster event consumer",
-                new String[]{ "node", "status" },
-                new String[]{ "Node hosting event consumer", "Current status of the event consumer" },
-                new OpenType[]{ SimpleType.STRING, SimpleType.BOOLEAN });
+                new String[]{ "node", "status", "local" },
+                new String[]{ "Node hosting event consumer", "Current status of the event consumer", "True if the node is local" },
+                new OpenType[]{ SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN });
         TabularType tableType = new TabularType("Event Consumers", "Table of Karaf Cellar cluster event consumers",
                 compositeType, new String[]{ "node" });
         TabularDataSupport table = new TabularDataSupport(tableType);
 
         for (Node node : results.keySet()) {
+            boolean local = (node.equals(clusterManager.getNode()));
             ConsumerSwitchResult consumerSwitchResult = results.get(node);
             CompositeDataSupport data = new CompositeDataSupport(compositeType,
-                    new String[]{ "node", "status" },
-                    new Object[]{ node.getId(), consumerSwitchResult.getStatus() });
+                    new String[]{ "node", "status", "local" },
+                    new Object[]{ node.getId(), consumerSwitchResult.getStatus(), local });
             table.put(data);
         }
 
@@ -237,18 +239,19 @@ public class CellarMBeanImpl extends StandardMBean implements CellarMBean {
         Map<Node, ProducerSwitchResult> results = executionContext.execute(command);
 
         CompositeType compositeType = new CompositeType("Event Producer", "Karaf Cellar cluster event producer",
-                new String[]{ "node", "status" },
-                new String[]{ "Node hosting event producer", "Current status of the event producer" },
-                new OpenType[]{ SimpleType.STRING, SimpleType.BOOLEAN });
+                new String[]{ "node", "status", "local" },
+                new String[]{ "Node hosting event producer", "Current status of the event producer", "True if the node is local" },
+                new OpenType[]{ SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN });
         TabularType tableType = new TabularType("Event Producers", "Table of Karaf Cellar cluster event producers",
                 compositeType, new String[]{ "node" });
         TabularDataSupport table = new TabularDataSupport(tableType);
 
         for (Node node : results.keySet()) {
+            boolean local = (node.equals(clusterManager.getNode()));
             ProducerSwitchResult producerSwitchResult = results.get(node);
             CompositeDataSupport data = new CompositeDataSupport(compositeType,
-                    new String[]{ "node", "status" },
-                    new Object[]{ node.getId(), producerSwitchResult.getStatus() });
+                    new String[]{ "node", "status", "local" },
+                    new Object[]{ node.getId(), producerSwitchResult.getStatus(), local });
             table.put(data);
         }
 

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/c2c1458f/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
index cf85d8a..267be4b 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
@@ -26,8 +26,8 @@ import java.util.Set;
 
 public abstract class ConsumerSupport extends ClusterCommandSupport {
 
-    protected static final String HEADER_FORMAT = " %-30s   %-5s";
-    protected static final String OUTPUT_FORMAT = "[%-30s] [%-5s]";
+    protected static final String HEADER_FORMAT = "   %-30s   %-5s";
+    protected static final String OUTPUT_FORMAT = "%1s [%-30s] [%-5s]";
 
     protected Object doExecute(List<String> nodeIds, SwitchStatus status) throws Exception {
 
@@ -62,12 +62,16 @@ public abstract class ConsumerSupport extends ClusterCommandSupport {
         } else {
             System.out.println(String.format(HEADER_FORMAT, "Node", "Status"));
             for (Node node : results.keySet()) {
+                String local = " ";
+                if (node.equals(clusterManager.getNode())) {
+                    local = "*";
+                }
                 ConsumerSwitchResult result = results.get(node);
                 String statusString = "OFF";
                 if (result.getStatus()) {
                     statusString = "ON";
                 }
-                System.out.println(String.format(OUTPUT_FORMAT, node.getId(), statusString));
+                System.out.println(String.format(OUTPUT_FORMAT, local, node.getId(), statusString));
             }
         }
         return null;

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/c2c1458f/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
index 78c082c..d632d27 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
@@ -25,8 +25,8 @@ import java.util.Set;
 
 public abstract class HandlersSupport extends ClusterCommandSupport {
 
-    protected static final String HEADER_FORMAT = " %-30s   %-5s  %s";
-    protected static final String OUTPUT_FORMAT = "[%-30s] [%-5s]  %s";
+    protected static final String HEADER_FORMAT = "   %-30s   %-5s  %s";
+    protected static final String OUTPUT_FORMAT = "%1s [%-30s] [%-5s] %s";
 
     protected Object doExecute(String handlerName, List<String> nodeIds, Boolean status) throws Exception {
 
@@ -63,13 +63,17 @@ public abstract class HandlersSupport extends ClusterCommandSupport {
             System.out.println(String.format(HEADER_FORMAT, "Node", "Status", "Event Handler"));
             for (Map.Entry<Node,ManageHandlersResult> handlersResultEntry : results.entrySet()) {
                 Node node = handlersResultEntry.getKey();
+                String local = " ";
+                if (node.equals(clusterManager.getNode())) {
+                    local = "*";
+                }
                 ManageHandlersResult result = handlersResultEntry.getValue();
                 if (result != null && result.getHandlers() != null) {
 
                     for (Map.Entry<String,String>  handlerEntry: result.getHandlers().entrySet()) {
                         String handler =  handlerEntry.getKey();
                         String s = handlerEntry.getValue();
-                        System.out.println(String.format(OUTPUT_FORMAT, node.getId(), s, handler));
+                        System.out.println(String.format(OUTPUT_FORMAT, local, node.getId(), s, handler));
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/c2c1458f/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
index 58562dc..fee1ad8 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
@@ -26,8 +26,8 @@ import java.util.Set;
 
 public abstract class ProducerSupport extends ClusterCommandSupport {
 
-    protected static final String HEADER_FORMAT = " %-30s   %-5s";
-    protected static final String OUTPUT_FORMAT = "[%-30s] [%-5s]";
+    protected static final String HEADER_FORMAT = "   %-30s   %-5s";
+    protected static final String OUTPUT_FORMAT = "%1s [%-30s] [%-5s]";
 
     protected Object doExecute(List<String> nodeIds, SwitchStatus status) throws Exception {
 
@@ -62,12 +62,16 @@ public abstract class ProducerSupport extends ClusterCommandSupport {
         } else {
             System.out.println(String.format(HEADER_FORMAT, "Node", "Status"));
             for (Node node : results.keySet()) {
+                String local = " ";
+                if (node.equals(clusterManager.getNode())) {
+                    local = "*";
+                }
                 ProducerSwitchResult result = results.get(node);
                 String statusString = "OFF";
                 if (result.getStatus()) {
                     statusString = "ON";
                 }
-                System.out.println(String.format(OUTPUT_FORMAT, node.getId(), statusString));
+                System.out.println(String.format(OUTPUT_FORMAT, local, node.getId(), statusString));
             }
         }
         return null;