Simplify the logic of compute added and removed addresses in routing table #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Terms:
ConnectionPoolswhich is a map from addresses to connection poolsRoutingTablewhich contains addresses for routers, writers, and readersFor a routing driver, once an address is removed from the current
RoutingTable, the address is no longer accessable. a.k.a. no new connection will be created in the corresponding connection pool.When updating routing table, we also need to signal the addresses in
ConnectionPoolsto be active if they are newly added into the current routing table or passive if they have already been removed from the routing table. For the pools connected to addresses that have been removed, when a connection is free, the connection should be terminated rather than reused. When there is no connection in the pool, the pool could be safely removed fromConnectionPools.So the logic that need to be changed to:
RoutingTableis available, computeadded_addr = distinct_addr_in(new_routingTable) - distinct_addr_in(pre_routingTable)removed_addr = distinct_addr_in(pre_routingTable) - distinct_addr_in(new_routingTable)added_addrinConnectionPoolsto beactiveconnection poolsremoved_addrinConnectionPoolsto bepassiveconnection poolspassiveconnection pools if no connection isinUse(all connections are idle)passiveconnection pool, terminate the connection directly, [and remove the connection pool if no connections isInUse]