ghostly72 commented on issue #13856:
URL: https://github.com/apache/dubbo/issues/13856#issuecomment-3732937899

   
   
   so to detect only the case of registry failure, can we add another flag like 
`isRegistryDown` in abstract registry?
   im thinking of maybr adding:
   ```
   private volatile boolean registryDown = false;
   
   protected boolean isRegistryDown() {
       return registryDown;
   }
   
   protected void setRegistryDown(boolean down) {
       this.registryDown = down;
   }
   ``` 
   and 
   ```
   private boolean isConnectionException(Throwable t) {
       return t instanceof java.io.IOException
           || t instanceof java.net.ConnectException
           || t instanceof java.net.SocketTimeoutException
           || (t.getMessage() != null && t.getMessage().contains("Connection 
refused"));
   // we can add other exceptions that correspond to the registry failure or 
unavailability scenario as well
   }
   ```
   inside abstract registry. 
   other registry implementatoins ultimately extend this.
   
   so in every registry, we'll have code block similar to
   ```
   try{
       // register/unregister/subscriber/unsubscribe to registry
   }catch{
       // msg saying failed to connect due to some error
      // here we can call isConnectionException and check if we should set the 
flag or not accordingly
   ```
   
   and then finally inside abstractregistry's code
   we can have 
   ```
   if(!isRegistryDown) enable local cache 
   ```
   
   thoughts anyone?


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to