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 2017/08/07 05:16:41 UTC
camel git commit: CAMEL-11585: Added JMX Reset counter via actuator
Repository: camel
Updated Branches:
refs/heads/master 83b359090 -> ffcad28f3
CAMEL-11585: Added JMX Reset counter via actuator
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ffcad28f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ffcad28f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ffcad28f
Branch: refs/heads/master
Commit: ffcad28f376e847e62f0d3a45a72504b8013951f
Parents: 83b3590
Author: Viral Gohel <vr...@gmail.com>
Authored: Thu Aug 3 11:44:26 2017 +0530
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Aug 7 07:13:24 2017 +0200
----------------------------------------------------------------------
.../actuate/endpoint/CamelRoutesEndpoint.java | 13 ++-
.../endpoint/CamelRoutesMvcEndpoint.java | 94 ++++++++++++--------
2 files changed, 65 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/ffcad28f/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java
index eec11ad..af867ae 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesEndpoint.java
@@ -56,7 +56,7 @@ public class CamelRoutesEndpoint extends AbstractEndpoint<List<RouteEndpointInfo
public List<RouteEndpointInfo> invoke() {
return getRoutesInfo();
}
-
+
public RouteEndpointInfo getRouteInfo(String id) {
Route route = camelContext.getRoute(id);
if (route != null) {
@@ -68,8 +68,8 @@ public class CamelRoutesEndpoint extends AbstractEndpoint<List<RouteEndpointInfo
public List<RouteEndpointInfo> getRoutesInfo() {
return camelContext.getRoutes().stream()
- .map(RouteEndpointInfo::new)
- .collect(Collectors.toList());
+ .map(RouteEndpointInfo::new)
+ .collect(Collectors.toList());
}
public RouteDetailsEndpointInfo getRouteDetailsInfo(String id) {
@@ -85,6 +85,13 @@ public class CamelRoutesEndpoint extends AbstractEndpoint<List<RouteEndpointInfo
camelContext.getRouteController().startRoute(id);
}
+ public void resetRoute(String id) throws Exception {
+ ManagedRouteMBean managedRouteMBean = camelContext.getManagedRoute(id, ManagedRouteMBean.class);
+ if (managedRouteMBean != null) {
+ managedRouteMBean.reset(true);
+ }
+ }
+
public void stopRoute(String id, Optional<Long> timeout, Optional<TimeUnit> timeUnit, Optional<Boolean> abortAfterTimeout) throws Exception {
if (timeout.isPresent()) {
camelContext.getRouteController().stopRoute(id, timeout.get(), timeUnit.orElse(TimeUnit.SECONDS), abortAfterTimeout.orElse(Boolean.TRUE));
http://git-wip-us.apache.org/repos/asf/camel/blob/ffcad28f/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpoint.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpoint.java
index 04a0c37..cf4836e 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpoint.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/endpoint/CamelRoutesMvcEndpoint.java
@@ -44,7 +44,7 @@ public class CamelRoutesMvcEndpoint extends EndpointMvcAdapter {
* Default path
*/
public static final String PATH = "/camel/routes";
-
+
private final CamelRoutesEndpoint delegate;
public CamelRoutesMvcEndpoint(CamelRoutesEndpoint delegate) {
@@ -57,14 +57,14 @@ public class CamelRoutesMvcEndpoint extends EndpointMvcAdapter {
// ********************************************
// Endpoints
// ********************************************
-
+
@ResponseBody
@GetMapping(
- value = "/{id}/detail",
- produces = {
- ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
- MediaType.APPLICATION_JSON_VALUE
- }
+ value = "/{id}/detail",
+ produces = {
+ ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
+ MediaType.APPLICATION_JSON_VALUE
+ }
)
public Object detail(
@PathVariable String id) {
@@ -81,11 +81,11 @@ public class CamelRoutesMvcEndpoint extends EndpointMvcAdapter {
@ResponseBody
@GetMapping(
- value = "/{id}/info",
- produces = {
- ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
- MediaType.APPLICATION_JSON_VALUE
- }
+ value = "/{id}/info",
+ produces = {
+ ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
+ MediaType.APPLICATION_JSON_VALUE
+ }
)
public Object info(
@PathVariable String id) {
@@ -102,11 +102,11 @@ public class CamelRoutesMvcEndpoint extends EndpointMvcAdapter {
@ResponseBody
@PostMapping(
- value = "/{id}/stop",
- produces = {
- ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
- MediaType.APPLICATION_JSON_VALUE
- }
+ value = "/{id}/stop",
+ produces = {
+ ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
+ MediaType.APPLICATION_JSON_VALUE
+ }
)
public Object stop(
@PathVariable String id,
@@ -116,10 +116,10 @@ public class CamelRoutesMvcEndpoint extends EndpointMvcAdapter {
return doIfEnabled(() -> {
try {
delegate.stopRoute(
- id,
- Optional.ofNullable(timeout),
- Optional.of(TimeUnit.SECONDS),
- Optional.ofNullable(abortAfterTimeout)
+ id,
+ Optional.ofNullable(timeout),
+ Optional.of(TimeUnit.SECONDS),
+ Optional.ofNullable(abortAfterTimeout)
);
} catch (Exception e) {
throw new GenericException("Error stopping route " + id, e);
@@ -131,11 +131,11 @@ public class CamelRoutesMvcEndpoint extends EndpointMvcAdapter {
@ResponseBody
@PostMapping(
- value = "/{id}/start",
- produces = {
- ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
- MediaType.APPLICATION_JSON_VALUE
- }
+ value = "/{id}/start",
+ produces = {
+ ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
+ MediaType.APPLICATION_JSON_VALUE
+ }
)
public Object start(
@PathVariable String id) {
@@ -152,12 +152,28 @@ public class CamelRoutesMvcEndpoint extends EndpointMvcAdapter {
}
@ResponseBody
+ @PostMapping(value = "/{id}/reset", produces = {ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE})
+ public Object reset(@PathVariable String id) {
+
+ return doIfEnabled(() -> {
+ try {
+ delegate.resetRoute(id);
+ } catch (Exception e) {
+ throw new GenericException("Error resetting route stats " + id, e);
+ }
+
+ return ResponseEntity.ok().build();
+ });
+ }
+
+
+ @ResponseBody
@PostMapping(
- value = "/{id}/suspend",
- produces = {
- ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
- MediaType.APPLICATION_JSON_VALUE
- }
+ value = "/{id}/suspend",
+ produces = {
+ ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
+ MediaType.APPLICATION_JSON_VALUE
+ }
)
public Object suspend(
@PathVariable String id,
@@ -166,9 +182,9 @@ public class CamelRoutesMvcEndpoint extends EndpointMvcAdapter {
return doIfEnabled(() -> {
try {
delegate.suspendRoute(
- id,
- Optional.ofNullable(timeout),
- Optional.of(TimeUnit.SECONDS)
+ id,
+ Optional.ofNullable(timeout),
+ Optional.of(TimeUnit.SECONDS)
);
} catch (Exception e) {
throw new GenericException("Error suspending route " + id, e);
@@ -180,11 +196,11 @@ public class CamelRoutesMvcEndpoint extends EndpointMvcAdapter {
@ResponseBody
@PostMapping(
- value = "/{id}/resume",
- produces = {
- ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
- MediaType.APPLICATION_JSON_VALUE
- }
+ value = "/{id}/resume",
+ produces = {
+ ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
+ MediaType.APPLICATION_JSON_VALUE
+ }
)
public Object resume(
@PathVariable String id) {