gnodet-bot commented on code in PR #30353:
URL: https://github.com/apache/camel/pull/30353#discussion_r4625976059
##########
core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultSupervisingRouteController.java:
##########
@@ -409,6 +409,56 @@ public void resumeRoute(String routeId) throws Exception {
}
}
+ @Override
+ public void startRouteGroup(String routeGroup) throws Exception {
+ lock.lock();
+ try {
+ List<RouteHolder> group = routesOfGroup(routeGroup);
+ for (RouteHolder route : group) {
+ // as startRoute: the controller takes care that the route is
started, and the manual start cancels a
+ // restart task (and clears an exhausted state)
+ route.get().setRouteController(this);
+ routeManager.release(route);
+ }
+ try {
+ super.startRouteGroup(routeGroup);
+ } catch (Exception e) {
+ // as startRoute: the routes of the group that did not start
are moved to the controller supervision,
+ // so they get (eventually) restarted
+ for (RouteHolder route : group) {
+ if (route.getStatus().isStopped()) {
+ LOG.debug("Route {} of route group {} failed to start
and is moved to the controller supervision",
+ route.getId(), routeGroup);
+
EventHelper.notifyRouteRestartingFailure(getCamelContext(), route.get(), 0, e,
false);
+ routeManager.start(route);
+ }
+ }
+ throw e;
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public void stopRouteGroup(String routeGroup) throws Exception {
+ lock.lock();
+ try {
+ for (RouteHolder route : routesOfGroup(routeGroup)) {
+ // as stopRoute: a route stopped manually is no longer started
by its restart task
+ routeManager.release(route);
+ route.get().setRouteController(null);
+ }
+ super.stopRouteGroup(routeGroup);
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ private List<RouteHolder> routesOfGroup(String routeGroup) {
Review Comment:
This helper filters routes by group name but does not check
`isSupervised()`. As a result, `startRouteGroup`/`stopRouteGroup` will also
affect routes in the group that are not supervised by this controller. This
mirrors the existing `startRoute` behavior (not a regression), but filtering to
supervised routes only would be more correct:
```suggestion
private List<RouteHolder> routesOfGroup(String routeGroup) {
return routes.stream()
.filter(r -> routeGroup.equals(r.get().getGroup()) &&
r.get().isSupervised())
.toList();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]