camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-8044: Camel commands useable for remote JVMs using jolokia
Date Wed, 17 Dec 2014 08:47:22 GMT
Repository: camel
Updated Branches:
  refs/heads/master 23688d3d8 -> 83c65ef9d


CAMEL-8044: Camel commands useable for remote JVMs using jolokia


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/83c65ef9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/83c65ef9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/83c65ef9

Branch: refs/heads/master
Commit: 83c65ef9d13762b112cdced43c8ecaf88c99cde2
Parents: 23688d3
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Dec 17 09:46:48 2014 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Dec 17 09:46:48 2014 +0100

----------------------------------------------------------------------
 .../camel/commands/EndpointExplainCommand.java  | 18 ++++++-------
 .../camel/commands/EndpointListCommand.java     | 10 +++----
 .../jolokia/DefaultJolokiaCamelController.java  |  3 ++-
 .../commands/jolokia/JolokiaCommandsTest.java   | 28 ++++++++++++++++++++
 4 files changed, 43 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/83c65ef9/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointExplainCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointExplainCommand.java
b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointExplainCommand.java
index 2713b2a..338af0d 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointExplainCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointExplainCommand.java
@@ -66,11 +66,11 @@ public class EndpointExplainCommand extends AbstractContextCommand {
                 continue;
             }
 
-            out.println("Context:\t" + context);
+            out.println("Context:       " + context);
 
             // sanitize and mask uri so we dont see passwords
             String uri = URISupport.sanitizeUri(row.get("uri"));
-            String header = "Uri:            " + uri;
+            String header = "Uri:           " + uri;
             out.println(header);
             for (int i = 0; i < header.length(); i++) {
                 out.print('-');
@@ -94,33 +94,33 @@ public class EndpointExplainCommand extends AbstractContextCommand {
             });
 
             for (Map<String, String> option : options) {
-                out.print("Option:\t\t");
+                out.print("Option:        ");
                 out.println(option.get("name"));
-                out.print("Kind:\t\t");
+                out.print("Kind:          ");
                 out.println(option.get("kind"));
                 String type = option.get("type");
                 if (type != null) {
-                    out.print("Type:\t\t");
+                    out.print("Type:          ");
                     out.println(type);
                 }
                 String javaType = option.get("javaType");
                 if (javaType != null) {
-                    out.print("Java Type:\t");
+                    out.print("Java Type:     ");
                     out.println(javaType);
                 }
                 String value = option.get("value");
                 if (value != null) {
-                    out.print("Value:\t\t");
+                    out.print("Value:         ");
                     out.println(value);
                 }
                 String defaultValue = option.get("defaultValue");
                 if (defaultValue != null) {
-                    out.print("Default Value:\t");
+                    out.print("Default Value: ");
                     out.println(defaultValue);
                 }
                 String description = option.get("description");
                 if (description != null) {
-                    out.print("Description:\t");
+                    out.print("Description:   ");
                     out.println(description);
                 }
                 out.println();

http://git-wip-us.apache.org/repos/asf/camel/blob/83c65ef9/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointListCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointListCommand.java
b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointListCommand.java
index e8521ad..6d15ffb 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointListCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointListCommand.java
@@ -119,18 +119,17 @@ public class EndpointListCommand extends AbstractContextCommand {
                             } else {
                                 line = "\t" + key + " = " + value;
                             }
-                            out.println(String.format(rowFormat, "", line, ""));
+                            out.println(line);
 
                             if (type != null) {
                                 String displayType = type;
                                 if (javaType != null && !displayType.equals(javaType))
{
                                     displayType = type + " (" + javaType + ")";
                                 }
-                                out.println(String.format(rowFormat, "", "\t" + displayType,
""));
+                                out.println("\t" + displayType);
                             }
                             if (desc != null) {
-                                // TODO: split desc in multi lines so it does not overflow
-                                out.println(String.format(rowFormat, "", "\t" + desc, ""));
+                                out.println("\t" + desc);
                             }
                             out.println();
                         }
@@ -189,13 +188,12 @@ public class EndpointListCommand extends AbstractContextCommand {
         columnWidthIncrement = DEFAULT_COLUMN_WIDTH_INCREMENT;
 
         int uriLen = java.lang.Math.min(columnWidths.get(URI_COLUMN_LABEL) + columnWidthIncrement,
getMaxColumnWidth());
-        int statusLen = java.lang.Math.min(columnWidths.get(STATUS_COLUMN_LABEL) + columnWidthIncrement,
getMaxColumnWidth());
         uriLen = Math.max(MIN_COLUMN_WIDTH, uriLen);
         // last row does not have min width
 
         final StringBuilder retval = new StringBuilder(DEFAULT_FORMAT_BUFFER_LENGTH);
         retval.append(fieldPreamble).append("%-").append(uriLen).append('.').append(uriLen).append('s').append(fieldPostamble).append('
');
-        retval.append(fieldPreamble).append("%-").append(statusLen).append('.').append(statusLen).append('s').append(fieldPostamble).append('
');
+        retval.append(fieldPreamble).append("%s").append(fieldPostamble).append(' ');
 
         return retval.toString();
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/83c65ef9/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
index b07fd29..998418e 100644
--- a/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
+++ b/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java
@@ -469,7 +469,8 @@ public class DefaultJolokiaCamelController extends AbstractCamelController
imple
 
         ObjectName found = lookupCamelContext(camelContextName);
         if (found != null) {
-            J4pSearchResponse sr = jolokia.execute(new J4pSearchRequest("*:type=endpoints,*"));
+            String pattern = String.format("%s:context=%s,type=endpoints,*", found.getDomain(),
found.getKeyProperty("context"));
+            J4pSearchResponse sr = jolokia.execute(new J4pSearchRequest(pattern));
 
             List<J4pReadRequest> list = new ArrayList<J4pReadRequest>();
             for (ObjectName on : sr.getObjectNames()) {

http://git-wip-us.apache.org/repos/asf/camel/blob/83c65ef9/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaCommandsTest.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaCommandsTest.java
b/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaCommandsTest.java
index c7d3710..42b8630 100644
--- a/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaCommandsTest.java
+++ b/platforms/commands/commands-jolokia/src/test/java/org/apache/camel/commands/jolokia/JolokiaCommandsTest.java
@@ -18,6 +18,8 @@ package org.apache.camel.commands.jolokia;
 
 import org.apache.camel.commands.ContextInfoCommand;
 import org.apache.camel.commands.ContextListCommand;
+import org.apache.camel.commands.EndpointExplainCommand;
+import org.apache.camel.commands.EndpointListCommand;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -55,4 +57,30 @@ public class JolokiaCommandsTest {
         cmd.execute(controller, System.out, System.err);
     }
 
+    @Test
+    public void testEndpointList() throws Exception {
+        controller = new DefaultJolokiaCamelController();
+        controller.connect(url, null, null);
+
+        if (!controller.ping()) {
+            throw new IllegalArgumentException("Error connecting to " + url);
+        }
+
+        EndpointListCommand cmd = new EndpointListCommand("camel-1", true, true, true);
+        cmd.execute(controller, System.out, System.err);
+    }
+
+    @Test
+    public void testEndpointExplain() throws Exception {
+        controller = new DefaultJolokiaCamelController();
+        controller.connect(url, null, null);
+
+        if (!controller.ping()) {
+            throw new IllegalArgumentException("Error connecting to " + url);
+        }
+
+        EndpointExplainCommand cmd = new EndpointExplainCommand("camel-1", true, null);
+        cmd.execute(controller, System.out, System.err);
+    }
+
 }


Mime
View raw message