wardlican commented on code in PR #3969:
URL: https://github.com/apache/amoro/pull/3969#discussion_r3038470029
##########
amoro-ams/src/main/java/org/apache/amoro/server/dashboard/DashboardServer.java:
##########
@@ -412,6 +416,41 @@ private EndpointGroup apiGroup() {
public void preHandleRequest(Context ctx) {
String uriPath = ctx.path();
+
+ // Check if request should be forwarded to leader node
+ if (requestForwarder != null && requestForwarder.shouldForward(ctx)) {
+ try {
+ // forwardRequest will throw RequestForwardedException if forwarding
is successful
+ boolean forwarded = requestForwarder.forwardRequest(ctx);
+ // If we reach here, forwarding was skipped (e.g., circuit breaker
open)
+ LOG.warn("Request forwarding was skipped for path: {}", uriPath);
+ } catch (RequestForwardedException e) {
+ // Request was successfully forwarded, response is already set by
RequestForwarder
+ // Re-throw the exception to ensure no further local processing occurs
+ LOG.info("Request successfully forwarded to leader node for path: {}",
uriPath);
+ // Re-throw to completely stop all subsequent processing
+ throw e;
+ } catch (IOException e) {
+ LOG.error("Failed to forward request to leader node: {}", uriPath, e);
+
+ // Enhanced error handling for forwarding failures
+ String errorMessage = "Failed to forward request to leader node: " +
e.getMessage();
+
+ // Check if circuit breaker is open
+ if (requestForwarder.isCircuitBreakerOpenForMonitoring()) {
+ errorMessage += " (Circuit breaker is open due to repeated
failures)";
+ }
+
+ ctx.json(
Review Comment:
okay,I will fix it.
--
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]