You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/07/26 20:33:50 UTC
[1/2] camel git commit: CAMEL-9014: More endpoint usage statitics on
the runtime endpoint mbean
Repository: camel
Updated Branches:
refs/heads/master a87299217 -> 1ceb5c70d
CAMEL-9014: More endpoint usage statitics on the runtime endpoint mbean
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/29cef6f2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/29cef6f2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/29cef6f2
Branch: refs/heads/master
Commit: 29cef6f2a37254e02916cb6c7968b74d24e5bdfd
Parents: a872992
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jul 26 20:33:15 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jul 26 20:33:15 2015 +0200
----------------------------------------------------------------------
.../management/mbean/CamelOpenMBeanTypes.java | 6 +--
.../ManagedRuntimeEndpointRegistryMBean.java | 23 +++++-----
.../impl/DefaultRuntimeEndpointRegistry.java | 44 ++++++++------------
.../mbean/ManagedRuntimeEndpointRegistry.java | 24 +++++------
.../camel/spi/RuntimeEndpointRegistry.java | 23 +++++-----
5 files changed, 51 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/29cef6f2/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java b/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
index c72d382..32de297 100644
--- a/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
+++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
@@ -72,9 +72,9 @@ public final class CamelOpenMBeanTypes {
}
public static CompositeType listRuntimeEndpointsCompositeType() throws OpenDataException {
- return new CompositeType("endpoints", "Endpoints", new String[]{"url", "routeId", "input", "output", "static", "dynamic"},
- new String[]{"Url", "Route Id", "Input", "Output", "Static", "Dynamic"},
- new OpenType[]{SimpleType.STRING, SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
+ return new CompositeType("endpoints", "Endpoints", new String[]{"url", "routeId", "direction", "static", "dynamic"},
+ new String[]{"Url", "Route Id", "Direction", "Static", "Dynamic"},
+ new OpenType[]{SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
}
public static TabularType explainComponentTabularType() throws OpenDataException {
http://git-wip-us.apache.org/repos/asf/camel/blob/29cef6f2/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedRuntimeEndpointRegistryMBean.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedRuntimeEndpointRegistryMBean.java b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedRuntimeEndpointRegistryMBean.java
index 2199c7d..3e00a6e 100644
--- a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedRuntimeEndpointRegistryMBean.java
+++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedRuntimeEndpointRegistryMBean.java
@@ -17,7 +17,6 @@
package org.apache.camel.api.management.mbean;
import java.util.List;
-
import javax.management.openmbean.TabularData;
import org.apache.camel.api.management.ManagedAttribute;
@@ -25,28 +24,28 @@ import org.apache.camel.api.management.ManagedOperation;
public interface ManagedRuntimeEndpointRegistryMBean extends ManagedServiceMBean {
- @ManagedOperation(description = "Resets the usage gathered")
- void reset();
+ @ManagedOperation(description = "Clears the registry")
+ void clear();
- @ManagedAttribute(description = "Whether gathering runtime usage is enabled or not.")
+ @ManagedAttribute(description = "Whether gathering runtime usage is enabled or not")
boolean isEnabled();
- @ManagedAttribute(description = "Whether gathering runtime usage is enabled or not.")
+ @ManagedAttribute(description = "Whether gathering runtime usage is enabled or not")
void setEnabled(boolean enabled);
- @ManagedAttribute(description = "Maximum number of endpoints to keep in the cache per route.")
+ @ManagedAttribute(description = "Maximum number of endpoints to keep in the cache per route")
int getLimit();
- @ManagedAttribute(description = "Number of endpoints currently in the cache.")
- int size();
+ @ManagedAttribute(description = "Number of endpoints currently in the registry")
+ int getSize();
- @ManagedOperation(description = " Gets all the endpoint uris captured during runtime that are in-use.")
+ @ManagedOperation(description = " Gets all the endpoint urls captured during runtime that are in-use")
List<String> getAllEndpoints(boolean includeInputs);
- @ManagedOperation(description = " Gets all the endpoint uris captured during runtime that are in-use for the given route.")
+ @ManagedOperation(description = " Gets all the endpoint urls captured during runtime that are in-use for the given route")
List<String> getEndpointsPerRoute(String routeId, boolean includeInputs);
- @ManagedOperation(description = "Lists all the endpoints in the registry (url)")
- TabularData listEndpoints();
+ @ManagedOperation(description = "Lists statistics about all the endpoints in the registry")
+ TabularData endpointStatistics();
}
http://git-wip-us.apache.org/repos/asf/camel/blob/29cef6f2/camel-core/src/main/java/org/apache/camel/impl/DefaultRuntimeEndpointRegistry.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultRuntimeEndpointRegistry.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultRuntimeEndpointRegistry.java
index 8faf4b8..bf8a276 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultRuntimeEndpointRegistry.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultRuntimeEndpointRegistry.java
@@ -21,7 +21,6 @@ import java.util.Collections;
import java.util.EventObject;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -84,14 +83,14 @@ public class DefaultRuntimeEndpointRegistry extends EventNotifierSupport impleme
}
@Override
- public Map<String, Statistic> getStatistics() {
- Map<String, Statistic> answer = new LinkedHashMap<String, Statistic>();
+ public List<Statistic> getEndpointStatistics() {
+ List<Statistic> answer = new ArrayList<Statistic>();
// inputs
for (Map.Entry<String, Set<String>> entry : inputs.entrySet()) {
String routeId = entry.getKey();
for (String uri : entry.getValue()) {
- answer.put(uri, new EndpointRuntimeStatistics(routeId, true, false, 0));
+ answer.add(new EndpointRuntimeStatistics(uri, routeId, "in", 0));
}
}
@@ -99,12 +98,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()) {
- if (answer.containsKey(uri)) {
- // both input and output
- answer.put(uri, new EndpointRuntimeStatistics(routeId, true, true, 0));
- } else {
- answer.put(uri, new EndpointRuntimeStatistics(routeId, false, true, 0));
- }
+ answer.add(new EndpointRuntimeStatistics(uri, routeId, "out", 0));
}
}
@@ -122,7 +116,7 @@ public class DefaultRuntimeEndpointRegistry extends EventNotifierSupport impleme
}
@Override
- public void reset() {
+ public void clear() {
inputs.clear();
outputs.clear();
}
@@ -146,7 +140,7 @@ public class DefaultRuntimeEndpointRegistry extends EventNotifierSupport impleme
@Override
protected void doStop() throws Exception {
- reset();
+ clear();
}
@Override
@@ -204,34 +198,30 @@ public class DefaultRuntimeEndpointRegistry extends EventNotifierSupport impleme
private static class EndpointRuntimeStatistics implements Statistic {
+ private final String uri;
private final String routeId;
- private final boolean input;
- private final boolean output;
+ private final String direction;
private final long hits;
- private EndpointRuntimeStatistics(String routeId, boolean input, boolean output, long hits) {
+ private EndpointRuntimeStatistics(String uri, String routeId, String direction, long hits) {
+ this.uri = uri;
this.routeId = routeId;
- this.input = input;
- this.output = output;
+ this.direction = direction;
this.hits = hits;
}
- @Override
- public String getRouteId() {
- return routeId;
+ public String getUri() {
+ return uri;
}
- @Override
- public boolean isInput() {
- return input;
+ public String getRouteId() {
+ return routeId;
}
- @Override
- public boolean isOutput() {
- return output;
+ public String getDirection() {
+ return direction;
}
- @Override
public long getHits() {
return hits;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/29cef6f2/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRuntimeEndpointRegistry.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRuntimeEndpointRegistry.java b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRuntimeEndpointRegistry.java
index c93d2c6..daafe91 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRuntimeEndpointRegistry.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRuntimeEndpointRegistry.java
@@ -17,7 +17,6 @@
package org.apache.camel.management.mbean;
import java.util.List;
-import java.util.Map;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.CompositeType;
@@ -51,8 +50,8 @@ public class ManagedRuntimeEndpointRegistry extends ManagedService implements Ma
}
@Override
- public void reset() {
- registry.reset();
+ public void clear() {
+ registry.clear();
}
@Override
@@ -71,7 +70,7 @@ public class ManagedRuntimeEndpointRegistry extends ManagedService implements Ma
}
@Override
- public int size() {
+ public int getSize() {
return registry.size();
}
@@ -86,29 +85,26 @@ public class ManagedRuntimeEndpointRegistry extends ManagedService implements Ma
}
@Override
- public TabularData listEndpoints() {
+ public TabularData endpointStatistics() {
try {
TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listRuntimeEndpointsTabularType());
EndpointRegistry staticRegistry = getContext().getEndpointRegistry();
- Map<String, RuntimeEndpointRegistry.Statistic> stats = registry.getStatistics();
- for (Map.Entry<String, RuntimeEndpointRegistry.Statistic> entry : stats.entrySet()) {
+ for (RuntimeEndpointRegistry.Statistic stat : registry.getEndpointStatistics()) {
CompositeType ct = CamelOpenMBeanTypes.listRuntimeEndpointsCompositeType();
- String url = entry.getKey();
-
+ String url = stat.getUri();
Boolean isStatic = staticRegistry.isStatic(url);
Boolean isDynamic = staticRegistry.isDynamic(url);
if (sanitize) {
url = URISupport.sanitizeUri(url);
}
- String routeId = entry.getValue().getRouteId();
- Boolean input = entry.getValue().isInput();
- Boolean output = entry.getValue().isOutput();
+ String routeId = stat.getRouteId();
+ String direction = stat.getDirection();
- CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "routeId", "input", "output", "static", "dynamic"},
- new Object[]{url, routeId, input, output, isStatic, isDynamic});
+ CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "routeId", "direction", "static", "dynamic"},
+ new Object[]{url, routeId, direction, isStatic, isDynamic});
answer.put(data);
}
return answer;
http://git-wip-us.apache.org/repos/asf/camel/blob/29cef6f2/camel-core/src/main/java/org/apache/camel/spi/RuntimeEndpointRegistry.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/spi/RuntimeEndpointRegistry.java b/camel-core/src/main/java/org/apache/camel/spi/RuntimeEndpointRegistry.java
index a56cc04..d09b5e5 100644
--- a/camel-core/src/main/java/org/apache/camel/spi/RuntimeEndpointRegistry.java
+++ b/camel-core/src/main/java/org/apache/camel/spi/RuntimeEndpointRegistry.java
@@ -17,7 +17,6 @@
package org.apache.camel.spi;
import java.util.List;
-import java.util.Map;
import org.apache.camel.StaticService;
@@ -32,23 +31,21 @@ public interface RuntimeEndpointRegistry extends StaticService {
public interface Statistic {
/**
- * The route id (if the endpoint is associated with a route)
+ * The endpoint uri
*/
- String getRouteId();
+ String getUri();
/**
- * Whether the endpoint is used as input
- * <p/>
- * Notice an endpoint can be used as both input and output, such as when its linking two routes
+ * The route id (if the endpoint is associated with a route)
*/
- boolean isInput();
+ String getRouteId();
/**
- * Whether the endpoint is used as output
+ * Whether the endpoint is used as input our output
* <p/>
- * Notice an endpoint can be used as both input and output, such as when its linking two routes
+ * The returned value can either be <tt>in</tt> or <tt>out</tt>
*/
- boolean isOutput();
+ String getDirection();
/**
* Usage of the endpoint, such as how many messages it has received / sent to
@@ -82,9 +79,9 @@ public interface RuntimeEndpointRegistry extends StaticService {
void setLimit(int limit);
/**
- * Clears the runtime usage gathered
+ * Clears the registry
*/
- void reset();
+ void clear();
/**
* Number of endpoints currently in the cache.
@@ -109,6 +106,6 @@ public interface RuntimeEndpointRegistry extends StaticService {
/**
* Gets details about all the endpoint captured from the given route during runtime routing that are in-use of the routes.
*/
- Map<String, Statistic> getStatistics();
+ List<Statistic> getEndpointStatistics();
}
[2/2] camel git commit: CAMEL-9014: More endpoint usage statitics on
the runtime endpoint mbean
Posted by da...@apache.org.
CAMEL-9014: More endpoint usage statitics on the runtime endpoint mbean
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1ceb5c70
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1ceb5c70
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1ceb5c70
Branch: refs/heads/master
Commit: 1ceb5c70d75bab2c16779376f8f6edf868705ed3
Parents: 29cef6f
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jul 26 20:38:50 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jul 26 20:38:50 2015 +0200
----------------------------------------------------------------------
.../camel/api/management/mbean/CamelOpenMBeanTypes.java | 8 ++++----
.../management/mbean/ManagedRuntimeEndpointRegistry.java | 8 ++++++--
2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/1ceb5c70/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java b/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
index 32de297..093d794 100644
--- a/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
+++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
@@ -68,13 +68,13 @@ public final class CamelOpenMBeanTypes {
public static TabularType listRuntimeEndpointsTabularType() throws OpenDataException {
CompositeType ct = listRuntimeEndpointsCompositeType();
- return new TabularType("listRuntimeEndpoints", "Lists all the input and output endpoints gathered during runtime", ct, new String[]{"url"});
+ return new TabularType("listRuntimeEndpoints", "Lists all the input and output endpoints gathered during runtime", ct, new String[]{"index"});
}
public static CompositeType listRuntimeEndpointsCompositeType() throws OpenDataException {
- return new CompositeType("endpoints", "Endpoints", new String[]{"url", "routeId", "direction", "static", "dynamic"},
- new String[]{"Url", "Route Id", "Direction", "Static", "Dynamic"},
- new OpenType[]{SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
+ return new CompositeType("endpoints", "Endpoints", new String[]{"index", "url", "routeId", "direction", "static", "dynamic"},
+ new String[]{"Index", "Url", "Route Id", "Direction", "Static", "Dynamic"},
+ new OpenType[]{SimpleType.INTEGER, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN});
}
public static TabularType explainComponentTabularType() throws OpenDataException {
http://git-wip-us.apache.org/repos/asf/camel/blob/1ceb5c70/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRuntimeEndpointRegistry.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRuntimeEndpointRegistry.java b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRuntimeEndpointRegistry.java
index daafe91..0679047 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRuntimeEndpointRegistry.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRuntimeEndpointRegistry.java
@@ -90,6 +90,7 @@ public class ManagedRuntimeEndpointRegistry extends ManagedService implements Ma
TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listRuntimeEndpointsTabularType());
EndpointRegistry staticRegistry = getContext().getEndpointRegistry();
+ int index = 0;
for (RuntimeEndpointRegistry.Statistic stat : registry.getEndpointStatistics()) {
CompositeType ct = CamelOpenMBeanTypes.listRuntimeEndpointsCompositeType();
@@ -103,9 +104,12 @@ public class ManagedRuntimeEndpointRegistry extends ManagedService implements Ma
String routeId = stat.getRouteId();
String direction = stat.getDirection();
- CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "routeId", "direction", "static", "dynamic"},
- new Object[]{url, routeId, direction, isStatic, isDynamic});
+ CompositeData data = new CompositeDataSupport(ct, new String[]{"index", "url", "routeId", "direction", "static", "dynamic"},
+ new Object[]{index, url, routeId, direction, isStatic, isDynamic});
answer.put(data);
+
+ // use a counter as the single index in the TabularData as we do not want a multi-value index
+ index++;
}
return answer;
} catch (Exception e) {