karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject svn commit: r1439921 - in /karaf/cellar/branches/cellar-2.2.x: management/src/main/java/org/apache/karaf/cellar/management/internal/ shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ shell/src/main/java/org/apache/karaf/cellar/shell/handler/ ...
Date Tue, 29 Jan 2013 15:14:55 GMT
Author: jbonofre
Date: Tue Jan 29 15:14:55 2013
New Revision: 1439921

URL: http://svn.apache.org/viewvc?rev=1439921&view=rev
Log:
[KARAF-2141] cluster:producer/handler/consumer now display the local node

Modified:
    karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
    karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
    karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
    karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java

Modified: karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java?rev=1439921&r1=1439920&r2=1439921&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
(original)
+++ karaf/cellar/branches/cellar-2.2.x/management/src/main/java/org/apache/karaf/cellar/management/internal/CellarMBeanImpl.java
Tue Jan 29 15:14:55 2013
@@ -116,9 +116,9 @@ public class CellarMBeanImpl extends Sta
         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 Sta
                 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 Sta
         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 Sta
         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);
         }
 

Modified: karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java?rev=1439921&r1=1439920&r2=1439921&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
(original)
+++ karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
Tue Jan 29 15:14:55 2013
@@ -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 ex
         } 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;

Modified: karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java?rev=1439921&r1=1439920&r2=1439921&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
(original)
+++ karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
Tue Jan 29 15:14:55 2013
@@ -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 ex
             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));
                     }
                 }
             }

Modified: karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java?rev=1439921&r1=1439920&r2=1439921&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
(original)
+++ karaf/cellar/branches/cellar-2.2.x/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
Tue Jan 29 15:14:55 2013
@@ -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 ex
         } 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;



Mime
View raw message