Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1202#discussion_r41272295
  
    --- Diff: 
flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/RuntimeMonitorHandler.java
 ---
    @@ -44,27 +47,40 @@
     public class RuntimeMonitorHandler extends 
SimpleChannelInboundHandler<Routed> {
        
        private static final Charset ENCODING = Charset.forName("UTF-8");
    +
    +   private final JobManagerArchiveRetriever retriever;
        
        private final RequestHandler handler;
        
        private final String contentType;
        
    -   public RuntimeMonitorHandler(RequestHandler handler) {
    -           if (handler == null) {
    -                   throw new NullPointerException();
    -           }
    -           this.handler = handler;
    +   public RuntimeMonitorHandler(RequestHandler handler, 
JobManagerArchiveRetriever retriever) {
    +           this.retriever = checkNotNull(retriever);
    +           this.handler = checkNotNull(handler);
                this.contentType = (handler instanceof 
RequestHandler.JsonResponse) ? "application/json" : "text/plain";
        }
        
        @Override
        protected void channelRead0(ChannelHandlerContext ctx, Routed routed) 
throws Exception {
    +           // Redirect to leader if necessary
    +           String redirectAddress = retriever.getRedirectAddress();
    --- End diff --
    
    Get rid of this `getRedirectAddress` method here and simply ask for the 
current leader. Then compare the leader address with the local job manager 
address to decide whether you have to redirect or not.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to