gnodet-bot commented on code in PR #30919:
URL: https://github.com/apache/camel/pull/30919#discussion_r4716044449
##########
core/camel-cluster/src/main/java/org/apache/camel/impl/cluster/ClusteredRoutePolicy.java:
##########
@@ -272,6 +276,18 @@ public void onRemove(Route route) {
stoppedRoutes.remove(route);
}
+ @Override
+ public void onStart(Route route) {
Review Comment:
**Nit:** The new `onStart` override is public API (inherited from
`RoutePolicySupport`). A brief Javadoc would be useful to subclass authors and
IDEs — the inline comment is good, but it's not surfaced by tooling.
```suggestion
/**
* Applies the current leadership state to a route that just started. If
this node has lost the leadership
* before the route started, the leadership change is re-applied so the
route is stopped promptly.
*/
@Override
public void onStart(Route route) {
```
##########
core/camel-cluster/src/main/java/org/apache/camel/impl/cluster/ClusteredRoutePolicy.java:
##########
@@ -309,6 +327,25 @@ private void removeCamelEventListeners() {
}
}
+ private void restart() {
+ LOG.debug("ClusteredRoutePolicy for namespace {} is used again after
it was shut down", namespace);
+ // a change queued when the executor was shut down was dropped, and
the CamelContext starts again
+ leadershipChangePending.set(false);
+ reapply.set(false);
+ retryScheduled.set(false);
+ contextStarted.set(false);
+ contextResumed = false;
+ initialDelayElapsed = false;
+ // the routes are created while the CamelContext initializes: start
them once it has started
+ startManagedRoutesEarly = true;
+ camelContext.getManagementStrategy().addEventNotifier(listener);
Review Comment:
**Nit:** Consider adding `failedStarts.clear()` in `restart()` for
completeness. This is harmless today — `onRemove` clears per-route entries
during context shutdown so the map is already empty when `restart()` runs — but
an explicit clear documents the full-reset intent and guards against future
callers.
```suggestion
private void restart() {
LOG.debug("ClusteredRoutePolicy for namespace {} is used again after
it was shut down", namespace);
// a change queued when the executor was shut down was dropped, and
the CamelContext starts again
leadershipChangePending.set(false);
reapply.set(false);
retryScheduled.set(false);
contextStarted.set(false);
contextResumed = false;
initialDelayElapsed = false;
failedStarts.clear();
// the routes are created while the CamelContext initializes: start
them once it has started
startManagedRoutesEarly = true;
camelContext.getManagementStrategy().addEventNotifier(listener);
leadershipExecutor = newLeadershipExecutor();
}
```
--
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]