xiazcy edited a comment on pull request #1478:
URL: https://github.com/apache/tinkerpop/pull/1478#issuecomment-928255527


   Hi Divij, thank you so much for your suggestions!
   
   Just as a response to the two cases you outlined, and to make sure we are on 
the same page, re-init() is actually triggered when 
`Client.noLiveHostAvailable` is set to `true`, and not `false`. 
   
   > The code change in this PR sets a flag `noLiveHostAvailable` if at least 
one of the hosts fail during client initialization.
   > On the next request, it then tries to init() the client again for all the 
hosts registered in the cluster.
   
   Actually the `Client.noLiveHostAvailable` flag is set to `true` at beginning 
of `Client.initializeImplementation()`, and is set to `false` if at least one 
host is alive during initialization, not the other way around. This follows an 
"assume no live hosts unless proven otherwise" logic. So if there is at last 
one live host at initiation leading to a successful connection pool, then 
`Client.noLiveHostAvailable` is set to `false` and it will not re-init() the 
client.  
   
   More specifically, in the case when there are dead hosts among other live 
hosts, `Client.noLiveHostAvailable` is first set to `true`, and then set to 
`false` when any live hosts successfully initialized a connection pool inside 
the async call to `Client.initializeConnectionSetupForHost`. This also leaves 
`Client.initialized` as `true`, which shouldn’t trigger `Client.init()` at `if 
(!initialized || noLiveHostAvailable)` inside `Client.submitAsync()`, and if 
`Client.init()` is somehow called, its `if (initialized && 
!noLiveHostAvailable)` check would be `true` and any further initialization 
would be skipped. I believe this should avoid Case#2.
   
   But in any case, this change doesn’t resolve the fact that 
`Client.initialized` is set as `true` when by definition it shouldn’t when no 
host is available, and I’m working on a way to approach this based on your 
suggestions.


-- 
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: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to