Skip to content

Simplify the logic of compute added and removed addresses in routing table #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2017

Conversation

zhenlineo
Copy link

Terms:

  • ConnectionPools which is a map from addresses to connection pools
  • RoutingTable which contains addresses for routers, writers, and readers

For 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 ConnectionPools to 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 from ConnectionPools.

So the logic that need to be changed to:

  • When a new RoutingTable is available, compute
    added_addr = distinct_addr_in(new_routingTable) - distinct_addr_in(pre_routingTable)
    removed_addr = distinct_addr_in(pre_routingTable) - distinct_addr_in(new_routingTable)
  • Mark all addresses in set added_addr in ConnectionPools to be active connection pools
  • Mark all addresses in set removed_addr in ConnectionPools to be passive connection pools
  • Remove passive connection pools if no connection is inUse (all connections are idle)
  • When returning a connection to a passive connection pool, terminate the connection directly, [and remove the connection pool if no connections is InUse]

* `ConnectionPools` which is a map from addresses to connection pools
* `RoutingTable` which contains addresses for routers, writers, and readers

For 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 `ConnectionPools` to 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 from `ConnectionPools`.

So the logic that need to be changed:
* When a new `RoutingTable` is available, compute
`added_addr = distinct_addr_in(new_routingTable) - distinct_addr_in(pre_routingTable)`
`removed_addr = distinct_addr_in(pre_routingTable) - distinct_addr_in(new_routingTable)`
* Mark all addresses in set `added_addr` in `ConnectionPools` to be `active` connection pools
* Mark all addresses in set `removed_addr` in `ConnectionPools` to be `passive` connection pools
* Remove `passive` connection pools if no connection is `inUse` (all connections are idle)
* When returning a connection to a `passive` connection pool, terminate the connection directly, [and remove the connection pool if no connections is `InUse`]
@lutovich lutovich merged commit 46647ab into lutovich:1.4-no-purge Nov 8, 2017
@zhenlineo zhenlineo deleted the 1.4-no-purge branch November 8, 2017 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants