You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/02/13 13:30:51 UTC

[04/37] incubator-tinkerpop git commit: Check the value of reconnectionAttempt and create scheduled task as a 2 step process.

Check the value of reconnectionAttempt and create scheduled task as a 2 step process.

TINKERPOP-1126


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/cced2423
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/cced2423
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/cced2423

Branch: refs/heads/master
Commit: cced24238fa5a0e3c8f03294e42bac7674faf154
Parents: 93f430e
Author: Kieran Sherlock <ki...@identitymind.com>
Authored: Fri Feb 5 10:44:59 2016 -0800
Committer: Kieran Sherlock <ki...@identitymind.com>
Committed: Fri Feb 5 10:44:59 2016 -0800

----------------------------------------------------------------------
 .../org/apache/tinkerpop/gremlin/driver/Host.java    | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/cced2423/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Host.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Host.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Host.java
index bd628c8..c060b18 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Host.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Host.java
@@ -71,12 +71,15 @@ public final class Host {
         isAvailable = false;
 
         // only do a connection re-attempt if one is not already in progress
-        reconnectionAttempt.compareAndSet(null,
-                this.cluster.executor().scheduleAtFixedRate(() -> {
-                            logger.debug("Trying to reconnect to dead host at {}", this);
-                            if (reconnect.apply(this)) reconnected();
-                        }, cluster.connectionPoolSettings().reconnectInitialDelay,
-                        cluster.connectionPoolSettings().reconnectInterval, TimeUnit.MILLISECONDS));
+        synchronized (reconnectionAttempt) {
+            if (reconnectionAttempt.get() == null) {
+                reconnectionAttempt.set(this.cluster.executor().scheduleAtFixedRate(() -> {
+                    logger.debug("Trying to reconnect to dead host at {}", this);
+                    if (reconnect.apply(this))
+                        reconnected();
+                }, cluster.connectionPoolSettings().reconnectInitialDelay, cluster.connectionPoolSettings().reconnectInterval, TimeUnit.MILLISECONDS));
+            }
+        }
     }
 
     private void reconnected() {