Elffuss BraidHub

kikocis/java-driver public

Ensure failed reconnection attempts don't re-trigger onDown.
Changeset85b9ff98a74326bd739972db680125e4251020f9d6eaa89e221d675fdc610509
Authorolim7t <omichallat+github@gmail.com> · 2014-10-15 15:58 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2014-10-15 17:40 +02:00
Parents8c0b4c94af46

Browse the files at this changeset

1 file changed

modified driver-core/src/main/java/com/datastax/driver/core/Connection.java +9 −2
@@ -261,8 +261,15 @@
261261 // sure the "suspected" mechanism work as expected
262262 Host host = factory.manager.metadata.getHost(address);
263263 if (host != null) {
264- boolean isDown = factory.manager.signalConnectionFailure(host, ce, host.wasJustAdded(), isInitialized);
265- notifyOwnerWhenDefunct(isDown);
264+ // If we get an error on a host that was already DOWN or SUSPECTED, this is a reconnection attempt.
265+ // We don't want to signal, because that would invoke triggerOnDown unnecessarily (the host's bad
266+ // condition is already taken care of by the reattempt in progress)
267+ boolean isReconnectionAttempt = (host.state == Host.State.DOWN || host.state == Host.State.SUSPECT)
268+ && !(this instanceof PooledConnection);
269+ if (!isReconnectionAttempt) {
270+ boolean isDown = factory.manager.signalConnectionFailure(host, ce, host.wasJustAdded(), isInitialized);
271+ notifyOwnerWhenDefunct(isDown);
272+ }
266273 }
267274
268275 // Force the connection to close to make sure the future completes. Otherwise force() might never get called and