You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/06/12 20:40:33 UTC
[camel] 05/05: (chores) camel-base-engine: cleanup duplicated code in the endpoint registry
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit cde7bbbb31ac0653a742b5e7e301f1e7d7f12d8c
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Jun 12 14:24:48 2023 +0200
(chores) camel-base-engine: cleanup duplicated code in the endpoint registry
---
.../engine/DefaultRuntimeEndpointRegistry.java | 36 ++++++++++------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRuntimeEndpointRegistry.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRuntimeEndpointRegistry.java
index 516b9c7b9ea..537c0afa243 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRuntimeEndpointRegistry.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRuntimeEndpointRegistry.java
@@ -102,16 +102,7 @@ public class DefaultRuntimeEndpointRegistry extends EventNotifierSupport impleme
for (Map.Entry<String, Set<String>> entry : inputs.entrySet()) {
String routeId = entry.getKey();
for (String uri : entry.getValue()) {
- Long hits = 0L;
- if (extended) {
- String key = asUtilizationKey(routeId, uri);
- if (key != null) {
- hits = inputUtilization.getStatistics().get(key);
- if (hits == null) {
- hits = 0L;
- }
- }
- }
+ Long hits = getHits(routeId, uri, inputUtilization);
answer.add(new EndpointRuntimeStatistics(uri, routeId, "in", hits));
}
}
@@ -120,16 +111,7 @@ public class DefaultRuntimeEndpointRegistry extends EventNotifierSupport impleme
for (Map.Entry<String, Map<String, String>> entry : outputs.entrySet()) {
String routeId = entry.getKey();
for (String uri : entry.getValue().keySet()) {
- Long hits = 0L;
- if (extended) {
- String key = asUtilizationKey(routeId, uri);
- if (key != null) {
- hits = outputUtilization.getStatistics().get(key);
- if (hits == null) {
- hits = 0L;
- }
- }
- }
+ Long hits = getHits(routeId, uri, outputUtilization);
answer.add(new EndpointRuntimeStatistics(uri, routeId, "out", hits));
}
}
@@ -137,6 +119,20 @@ public class DefaultRuntimeEndpointRegistry extends EventNotifierSupport impleme
return answer;
}
+ private Long getHits(String routeId, String uri, EndpointUtilizationStatistics statistics) {
+ Long hits = 0L;
+ if (extended) {
+ String key = asUtilizationKey(routeId, uri);
+ if (key != null) {
+ hits = statistics.getStatistics().get(key);
+ if (hits == null) {
+ hits = 0L;
+ }
+ }
+ }
+ return hits;
+ }
+
@Override
public int getLimit() {
return limit;