camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/6] camel git commit: Camel commands show more details
Date Tue, 28 Jul 2015 07:11:38 GMT
Camel commands show more details


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

Branch: refs/heads/master
Commit: 75ef7eb214def5f98e003fe48ca405d468fee454
Parents: f78ae35
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Jul 27 19:04:37 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Jul 28 09:12:11 2015 +0200

----------------------------------------------------------------------
 .../camel/commands/ContextListCommand.java      | 38 +++++++++++++++++---
 .../commands/EndpointStatisticCommand.java      |  2 +-
 .../jolokia/DefaultJolokiaCamelController.java  |  5 ++-
 .../commands/internal/CamelControllerImpl.java  |  9 +++++
 4 files changed, 47 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/75ef7eb2/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/ContextListCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/ContextListCommand.java
b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/ContextListCommand.java
index 4ce3e37..41a4ec1 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/ContextListCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/ContextListCommand.java
@@ -28,6 +28,9 @@ public class ContextListCommand extends AbstractCamelCommand {
 
     private static final String CONTEXT_COLUMN_LABEL = "Context";
     private static final String STATUS_COLUMN_LABEL = "Status";
+    private static final String TOTAL_COLUMN_LABEL = "Total #";
+    private static final String FAILED_COLUMN_LABEL = "Failed #";
+    private static final String INFLIGHT_COLUMN_LABEL = "Inflight #";
     private static final String UPTIME_COLUMN_LABEL = "Uptime";
     private static final int DEFAULT_FORMAT_BUFFER_LENGTH = 24;
     private static final String DEFAULT_FIELD_PREAMBLE = " ";
@@ -47,10 +50,11 @@ public class ContextListCommand extends AbstractCamelCommand {
         final String rowFormat = buildFormatString(columnWidths, false);
 
         if (camelContexts.size() > 0) {
-            out.println(String.format(headerFormat, CONTEXT_COLUMN_LABEL, STATUS_COLUMN_LABEL,
UPTIME_COLUMN_LABEL));
-            out.println(String.format(headerFormat, "-------", "------", "------"));
+            out.println(String.format(headerFormat, CONTEXT_COLUMN_LABEL, STATUS_COLUMN_LABEL,
TOTAL_COLUMN_LABEL, FAILED_COLUMN_LABEL, INFLIGHT_COLUMN_LABEL, UPTIME_COLUMN_LABEL));
+            out.println(String.format(headerFormat, "-------", "------", "-------", "--------",
"----------", "------"));
             for (Map<String, String> row : camelContexts) {
-                out.println(String.format(rowFormat, row.get("name"), row.get("state"), row.get("uptime")));
+                out.println(String.format(rowFormat, row.get("name"), row.get("state"), row.get("exchangesTotal"),
+                        row.get("exchangesFailed"), row.get("exchangesInflight"), row.get("uptime")));
             }
         }
 
@@ -63,6 +67,9 @@ public class ContextListCommand extends AbstractCamelCommand {
         } else {
             int maxNameLen = 0;
             int maxStatusLen = 0;
+            int maxTotalLen = 0;
+            int maxFailedLen = 0;
+            int maxInflightLen = 0;
             int maxUptimeLen = 0;
 
             for (Map<String, String> row : camelContexts) {
@@ -72,13 +79,25 @@ public class ContextListCommand extends AbstractCamelCommand {
                 final String status = row.get("state");
                 maxStatusLen = java.lang.Math.max(maxStatusLen, status == null ? 0 : status.length());
 
+                final String total = row.get("exchangesTotal");
+                maxTotalLen = java.lang.Math.max(maxTotalLen, total == null ? 0 : total.length());
+
+                final String failed = row.get("exchangesFailed");
+                maxFailedLen = java.lang.Math.max(maxFailedLen, failed == null ? 0 : failed.length());
+
+                final String inflight = row.get("exchangesInflight");
+                maxInflightLen = java.lang.Math.max(maxInflightLen, inflight == null ? 0
: inflight.length());
+
                 final String uptime = row.get("uptime");
                 maxUptimeLen = java.lang.Math.max(maxUptimeLen, uptime == null ? 0 : uptime.length());
             }
 
-            final Map<String, Integer> retval = new Hashtable<String, Integer>(3);
+            final Map<String, Integer> retval = new Hashtable<String, Integer>();
             retval.put(CONTEXT_COLUMN_LABEL, maxNameLen);
             retval.put(STATUS_COLUMN_LABEL, maxStatusLen);
+            retval.put(TOTAL_COLUMN_LABEL, maxTotalLen);
+            retval.put(FAILED_COLUMN_LABEL, maxFailedLen);
+            retval.put(INFLIGHT_COLUMN_LABEL, maxInflightLen);
             retval.put(UPTIME_COLUMN_LABEL, maxUptimeLen);
 
             return retval;
@@ -101,14 +120,23 @@ public class ContextListCommand extends AbstractCamelCommand {
 
         int contextLen = java.lang.Math.min(columnWidths.get(CONTEXT_COLUMN_LABEL) + columnWidthIncrement,
MAX_COLUMN_WIDTH);
         int statusLen = java.lang.Math.min(columnWidths.get(STATUS_COLUMN_LABEL) + columnWidthIncrement,
MAX_COLUMN_WIDTH);
+        int totalLen = java.lang.Math.min(columnWidths.get(TOTAL_COLUMN_LABEL) + columnWidthIncrement,
MAX_COLUMN_WIDTH);
+        int failedlLen = java.lang.Math.min(columnWidths.get(FAILED_COLUMN_LABEL) + columnWidthIncrement,
MAX_COLUMN_WIDTH);
+        int inflightLen = java.lang.Math.min(columnWidths.get(INFLIGHT_COLUMN_LABEL) + columnWidthIncrement,
MAX_COLUMN_WIDTH);
         int uptimeLen = java.lang.Math.min(columnWidths.get(UPTIME_COLUMN_LABEL) + columnWidthIncrement,
MAX_COLUMN_WIDTH);
         contextLen = Math.max(MIN_COLUMN_WIDTH, contextLen);
         statusLen = Math.max(MIN_COLUMN_WIDTH, statusLen);
-        // last row does not have min width
+        totalLen = Math.max(MIN_COLUMN_WIDTH, totalLen);
+        failedlLen = Math.max(MIN_COLUMN_WIDTH, failedlLen);
+        inflightLen = Math.max(MIN_COLUMN_WIDTH, inflightLen);
+        uptimeLen = Math.max(MIN_COLUMN_WIDTH, uptimeLen);
 
         final StringBuilder retval = new StringBuilder(DEFAULT_FORMAT_BUFFER_LENGTH);
         retval.append(fieldPreamble).append("%-").append(contextLen).append('.').append(contextLen).append('s').append(fieldPostamble).append('
');
         retval.append(fieldPreamble).append("%-").append(statusLen).append('.').append(statusLen).append('s').append(fieldPostamble).append('
');
+        retval.append(fieldPreamble).append("%").append(totalLen).append('.').append(totalLen).append('s').append(fieldPostamble).append('
');
+        retval.append(fieldPreamble).append("%").append(failedlLen).append('.').append(failedlLen).append('s').append(fieldPostamble).append('
');
+        retval.append(fieldPreamble).append("%").append(inflightLen).append('.').append(inflightLen).append('s').append(fieldPostamble).append('
');
         retval.append(fieldPreamble).append("%-").append(uptimeLen).append('.').append(uptimeLen).append('s').append(fieldPostamble).append('
');
 
         return retval.toString();

http://git-wip-us.apache.org/repos/asf/camel/blob/75ef7eb2/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointStatisticCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointStatisticCommand.java
b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointStatisticCommand.java
index fb76655..f9427251 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointStatisticCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointStatisticCommand.java
@@ -194,7 +194,7 @@ public class EndpointStatisticCommand extends AbstractContextCommand {
         staticLen = Math.max(MIN_COLUMN_WIDTH, staticLen);
 
         int dynamicLen = Math.min(columnWidths.get(DYNAMIC_COLUMN_LABEL) + columnWidthIncrement,
getMaxColumnWidth());
-        dynamicLen = Math.max(MIN_COLUMN_WIDTH, staticLen);
+        dynamicLen = Math.max(MIN_COLUMN_WIDTH, dynamicLen);
 
         // last row does not have min width
 

http://git-wip-us.apache.org/repos/asf/camel/blob/75ef7eb2/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 454fbb0..bcf37e2 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
@@ -192,7 +192,7 @@ public class DefaultJolokiaCamelController extends AbstractCamelController
imple
 
         List<J4pReadRequest> list = new ArrayList<J4pReadRequest>();
         for (ObjectName on : sr.getObjectNames()) {
-            list.add(new J4pReadRequest(on, "CamelId", "State", "Uptime"));
+            list.add(new J4pReadRequest(on, "CamelId", "State", "Uptime", "ExchangesTotal",
"ExchangesInflight", "ExchangesFailed"));
         }
 
         List<J4pReadResponse> lrr = jolokia.execute(list);
@@ -201,6 +201,9 @@ public class DefaultJolokiaCamelController extends AbstractCamelController
imple
             row.put("name", rr.getValue("CamelId").toString());
             row.put("state", rr.getValue("State").toString());
             row.put("uptime", rr.getValue("Uptime").toString());
+            row.put("exchangesTotal", rr.getValue("ExchangesTotal").toString());
+            row.put("exchangesInflight", rr.getValue("ExchangesInflight").toString());
+            row.put("exchangesFailed", rr.getValue("ExchangesFailed").toString());
             answer.add(row);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/75ef7eb2/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/CamelControllerImpl.java
----------------------------------------------------------------------
diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/CamelControllerImpl.java
b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/CamelControllerImpl.java
index b026ff0..25d9ae9 100644
--- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/CamelControllerImpl.java
+++ b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/internal/CamelControllerImpl.java
@@ -83,6 +83,15 @@ public class CamelControllerImpl extends AbstractLocalCamelController {
             row.put("name", camelContext.getName());
             row.put("state", camelContext.getStatus().name());
             row.put("uptime", camelContext.getUptime());
+            if (camelContext.getManagedCamelContext() != null) {
+                row.put("exchangesTotal", "" + camelContext.getManagedCamelContext().getExchangesTotal());
+                row.put("exchangesInflight", "" + camelContext.getManagedCamelContext().getExchangesInflight());
+                row.put("exchangesFailed", "" + camelContext.getManagedCamelContext().getExchangesFailed());
+            } else {
+                row.put("exchangesTotal", "0");
+                row.put("exchangesInflight", "0");
+                row.put("exchangesFailed", "0");
+            }
             answer.add(row);
         }
 


Mime
View raw message