This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 513379364ca camel-jbang - top processors command.
513379364ca is described below

commit 513379364ca52bb33cae6f05c7ca15977454125b
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Sep 14 14:04:02 2022 +0200

    camel-jbang - top processors command.
---
 .../dsl/jbang/core/commands/CamelJBangMain.java    |  4 +-
 .../core/commands/process/CamelProcessorTop.java   | 43 ++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
index 59aeda0c45e..de95afa31b5 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
@@ -30,6 +30,7 @@ import 
org.apache.camel.dsl.jbang.core.commands.action.CamelThreadDump;
 import org.apache.camel.dsl.jbang.core.commands.process.CamelContextStatus;
 import org.apache.camel.dsl.jbang.core.commands.process.CamelContextTop;
 import org.apache.camel.dsl.jbang.core.commands.process.CamelProcessorStatus;
+import org.apache.camel.dsl.jbang.core.commands.process.CamelProcessorTop;
 import org.apache.camel.dsl.jbang.core.commands.process.CamelRouteStatus;
 import org.apache.camel.dsl.jbang.core.commands.process.CamelRouteTop;
 import org.apache.camel.dsl.jbang.core.commands.process.CamelStatus;
@@ -60,7 +61,8 @@ public class CamelJBangMain implements Callable<Integer> {
                         .addSubcommand("vault", new CommandLine(new 
ListVault(main))))
                 .addSubcommand("top", new CommandLine(new CamelTop(main))
                         .addSubcommand("context", new CommandLine(new 
CamelContextTop(main)))
-                        .addSubcommand("route", new CommandLine(new 
CamelRouteTop(main))))
+                        .addSubcommand("route", new CommandLine(new 
CamelRouteTop(main)))
+                        .addSubcommand("processor", new CommandLine(new 
CamelProcessorTop(main))))
                 .addSubcommand("cmd", new CommandLine(new CamelAction(main))
                         .addSubcommand("start-route", new CommandLine(new 
CamelRouteStartAction(main)))
                         .addSubcommand("stop-route", new CommandLine(new 
CamelRouteStopAction(main)))
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelProcessorTop.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelProcessorTop.java
new file mode 100644
index 00000000000..a55bfdda876
--- /dev/null
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelProcessorTop.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.process;
+
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import picocli.CommandLine.Command;
+
+@Command(name = "processor", aliases = { "processor", "processors" }, 
description = "Top performing processors")
+public class CamelProcessorTop extends CamelProcessorStatus {
+
+    public CamelProcessorTop(CamelJBangMain main) {
+        super(main);
+    }
+
+    @Override
+    protected int sortRow(Row o1, Row o2) {
+        // sort for highest mean value as we want the slowest in the top
+        long m1 = o1.mean != null ? Long.parseLong(o1.mean) : 0;
+        long m2 = o2.mean != null ? Long.parseLong(o2.mean) : 0;
+        if (m1 < m2) {
+            return 1;
+        } else if (m1 > m2) {
+            return -1;
+        } else {
+            return 0;
+        }
+    }
+
+}

Reply via email to