tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [3/9] incubator-tinkerpop git commit: Check the value of reconnectionAttempt and create scheduled task as a 2 step process.
Date Fri, 12 Feb 2016 23:16:15 GMT
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/tp31
Commit: cced24238fa5a0e3c8f03294e42bac7674faf154
Parents: 93f430e
Author: Kieran Sherlock <kieran@identitymind.com>
Authored: Fri Feb 5 10:44:59 2016 -0800
Committer: Kieran Sherlock <kieran@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() {


Mime
View raw message