Skip to content

Remove timeouts completely from ClientBuilder#110

Closed
rdegnan wants to merge 2 commits intomasterfrom
simple-clientbuilder
Closed

Remove timeouts completely from ClientBuilder#110
rdegnan wants to merge 2 commits intomasterfrom
simple-clientbuilder

Conversation

@rdegnan
Copy link
Copy Markdown
Member

@rdegnan rdegnan commented Jun 28, 2016

No description provided.

@NiteshKant
Copy link
Copy Markdown
Contributor

👍 . @stevegury can you take a look?

@stevegury
Copy link
Copy Markdown
Member

Please provide a minimal description of the motivations behind this PR.
Check the other PR for examples.

stevegury and others added 2 commits June 28, 2016 10:55
**Problem**
The loadbalancer uses internally 2 maps, one for the list of `ReactiveSocketFactory`
it can use for creating a new `ReactiveSocket`, and one for the active `ReactiveSocket`.
The link is made between the 2 maps through the `SocketAddress` of the associated
remote server. This is kind of clunky and requires explicit knowledge of
the `SocketAddress` (result type of `remote()`).

Also, when we select a new factory to connect to or when we select the slowest
ReactiveSocket to quick out, the sorting is made via the `sorted()` method
on the java stream. The comparison function is actually unstable because a
tcp socket can be closed while we do the sorting.

**Solution**
Use two queues, one for factories and one for ReactiveSocket. Selecting a factory
is made using the "Power of 2 Choices" technique, and we also "age" the unselected
factories by moving them at the end of the queue. The WeightedSocket now contains
a reference to the associated factory, and closing it add back the factory to the
factory queue.

**Modification**
Move the `WeightedSocket` class inside the `LoadBalancer`, no

I created a proper constructor to `LoadBalancer` with javadoc explaining all
parameters the algorithm requires.

The `LatencySubscriber` inside the LoadBalancer treats some exceptions
particularly:

- `TimeoutException` latency is used for predicating the next latency
- `TransportException` & `ClosedChannelException` removes the ReactiveSocket
   from the active list.

`Publishers.onError` now also `cancel` the subscription.

I created a StressTest file, which stress most of the part of the Client:

- Adding/Removing new servers
- High request concurrency
- Dealing with failing/black-hole servers
@rdegnan rdegnan force-pushed the simple-clientbuilder branch from 024d3f7 to 0dbbc40 Compare June 28, 2016 20:36
@NiteshKant
Copy link
Copy Markdown
Contributor

@rdegnan I think we don't need this anymore, rite?

@stevegury
Copy link
Copy Markdown
Member

I've merged most of that in #112 and the remaining will be in another PR.

@NiteshKant
Copy link
Copy Markdown
Contributor

Ok I am closing this now.

@NiteshKant NiteshKant closed this Jul 1, 2016
@stevegury stevegury deleted the simple-clientbuilder branch July 15, 2016 22:32
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.

3 participants