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/10 13:57:08 UTC
[1/7] incubator-tinkerpop git commit: Use the existing Host iterator
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/TINKERPOP-1125-to-1127 [created] ec6499f31
Use the existing Host iterator
TINKERPOP-1125
Rather than creating a new iterator so skipping over a host in the pool.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/c5b24212
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/c5b24212
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/c5b24212
Branch: refs/heads/TINKERPOP-1125-to-1127
Commit: c5b242126131edbe7e87300fc34a54a4dcb9fce9
Parents: 93f430e
Author: Kieran Sherlock <ki...@identitymind.com>
Authored: Fri Feb 5 06:25:32 2016 -0800
Committer: Kieran Sherlock <ki...@identitymind.com>
Committed: Fri Feb 5 06:25:32 2016 -0800
----------------------------------------------------------------------
.../src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c5b24212/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
index 8c80b8a..17c9a99 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
@@ -341,7 +341,7 @@ public abstract class Client {
final Iterator<Host> possibleHosts = this.cluster.loadBalancingStrategy().select(msg);
if (!possibleHosts.hasNext()) throw new TimeoutException("Timed out waiting for an available host.");
- final Host bestHost = this.cluster.loadBalancingStrategy().select(msg).next();
+ final Host bestHost = possibleHosts.next();
final ConnectionPool pool = hostConnectionPools.get(bestHost);
return pool.borrowConnection(cluster.connectionPoolSettings().maxWaitForConnection, TimeUnit.MILLISECONDS);
}
[3/7] incubator-tinkerpop git commit: Check the value of
reconnectionAttempt and create scheduled task as a 2 step process.
Posted by sp...@apache.org.
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/TINKERPOP-1125-to-1127
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() {
[4/7] incubator-tinkerpop git commit: Use an AtomicReference
to protect the reconnect task, rather than synchronizing on it.
Posted by sp...@apache.org.
Use an AtomicReference<Boolean> to protect the reconnect task, rather than synchronizing on it.
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/a3264648
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/a3264648
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/a3264648
Branch: refs/heads/TINKERPOP-1125-to-1127
Commit: a3264648a41e4db95cc95d5425a61ea8e07b7e64
Parents: cced242
Author: Kieran Sherlock <ki...@identitymind.com>
Authored: Tue Feb 9 17:10:59 2016 -0800
Committer: Kieran Sherlock <ki...@identitymind.com>
Committed: Tue Feb 9 20:42:41 2016 -0800
----------------------------------------------------------------------
.../apache/tinkerpop/gremlin/driver/Host.java | 24 +++++++++++---------
1 file changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a3264648/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 c060b18..34ee719 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
@@ -42,7 +42,8 @@ public final class Host {
private final Cluster cluster;
private final String hostLabel;
- final AtomicReference<ScheduledFuture<?>> reconnectionAttempt = new AtomicReference<>(null);
+ final AtomicReference<Boolean> retryInProgress = new AtomicReference<>(Boolean.FALSE);
+ ScheduledFuture<?> retryThread = null;
Host(final InetSocketAddress address, final Cluster cluster) {
this.cluster = cluster;
@@ -71,20 +72,21 @@ public final class Host {
isAvailable = false;
// only do a connection re-attempt if one is not already in progress
- 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));
- }
+ if (retryInProgress.compareAndSet(Boolean.FALSE, Boolean.TRUE)) {
+ retryThread = 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() {
- reconnectionAttempt.get().cancel(false);
- reconnectionAttempt.set(null);
+ // race condition! retry boolean could be set to false, a new retryThread created above
+ // and then cancelled here. But we're only executing this at all because we *have* reconnected
+ retryThread.cancel(false);
+ retryThread = null;
+ retryInProgress.set(Boolean.FALSE);
makeAvailable();
}
[2/7] incubator-tinkerpop git commit: Keep the value of open counter
in sync when connections fail.
Posted by sp...@apache.org.
Keep the value of open counter in sync when connections fail.
TINKERPOP-1127
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/f1800bd6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/f1800bd6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/f1800bd6
Branch: refs/heads/TINKERPOP-1125-to-1127
Commit: f1800bd65ea0393b59254a94aaed3fc22ac71f4f
Parents: c5b2421
Author: Kieran Sherlock <ki...@identitymind.com>
Authored: Fri Feb 5 09:54:57 2016 -0800
Committer: Kieran Sherlock <ki...@identitymind.com>
Committed: Fri Feb 5 09:54:57 2016 -0800
----------------------------------------------------------------------
.../java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f1800bd6/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
index 96c151c..19a29e4 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java
@@ -301,6 +301,7 @@ final class ConnectionPool {
connections.add(new Connection(host.getHostUri(), this, settings().maxInProcessPerConnection));
} catch (ConnectionException ce) {
logger.debug("Connections were under max, but there was an error creating the connection.", ce);
+ open.decrementAndGet();
considerUnavailable();
return false;
}
@@ -326,6 +327,7 @@ final class ConnectionPool {
private void definitelyDestroyConnection(final Connection connection) {
bin.add(connection);
connections.remove(connection);
+ open.decrementAndGet();
if (connection.borrowed.get() == 0 && bin.remove(connection))
connection.closeAsync();
@@ -413,6 +415,7 @@ final class ConnectionPool {
this.cluster.loadBalancingStrategy().onAvailable(host);
return true;
} catch (Exception ex) {
+ logger.debug("Failed reconnect attempt on {}", host);
if (connection != null) definitelyDestroyConnection(connection);
return false;
}
[7/7] incubator-tinkerpop git commit: Merge branch 'TINKERPOP-1126'
of https://github.com/kieransherlock/incubator-tinkerpop into
TINKERPOP-1125-to-1127
Posted by sp...@apache.org.
Merge branch 'TINKERPOP-1126' of https://github.com/kieransherlock/incubator-tinkerpop into TINKERPOP-1125-to-1127
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/ec6499f3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/ec6499f3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/ec6499f3
Branch: refs/heads/TINKERPOP-1125-to-1127
Commit: ec6499f313c3be808e26ed681c68faeb48515adc
Parents: bf90af0 457ef48
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Feb 10 07:27:56 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Feb 10 07:27:56 2016 -0500
----------------------------------------------------------------------
.../apache/tinkerpop/gremlin/driver/Host.java | 23 ++++++++++++--------
.../AbstractGremlinServerIntegrationTest.java | 4 ++++
.../server/GremlinServerIntegrateTest.java | 19 ++++++++++++----
3 files changed, 33 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
[5/7] incubator-tinkerpop git commit: Extend
GremlinServerIntegrateTest::shouldFailOnDeadHost to restart and reconnect.
Posted by sp...@apache.org.
Extend GremlinServerIntegrateTest::shouldFailOnDeadHost to restart and reconnect.
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/457ef48e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/457ef48e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/457ef48e
Branch: refs/heads/TINKERPOP-1125-to-1127
Commit: 457ef48e464f5122daccf29ff8dd991c54d16d06
Parents: a326464
Author: Kieran Sherlock <ki...@identitymind.com>
Authored: Tue Feb 9 20:43:36 2016 -0800
Committer: Kieran Sherlock <ki...@identitymind.com>
Committed: Tue Feb 9 20:53:10 2016 -0800
----------------------------------------------------------------------
.../AbstractGremlinServerIntegrationTest.java | 4 ++++
.../server/GremlinServerIntegrateTest.java | 19 +++++++++++++++----
2 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/457ef48e/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/AbstractGremlinServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/AbstractGremlinServerIntegrationTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/AbstractGremlinServerIntegrationTest.java
index fd8762a..ba47218 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/AbstractGremlinServerIntegrationTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/AbstractGremlinServerIntegrationTest.java
@@ -58,6 +58,10 @@ public abstract class AbstractGremlinServerIntegrationTest {
logger.info("* Testing: " + name.getMethodName());
logger.info("* Epoll option enabled:" + GREMLIN_SERVER_EPOLL);
+ startServer();
+ }
+
+ public void startServer() throws Exception {
final InputStream stream = getSettingsInputStream();
final Settings settings = Settings.read(stream);
final Settings overridenSettings = overrideSettings(settings);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/457ef48e/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
index df515bd..c64cf8b 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
@@ -21,10 +21,7 @@ package org.apache.tinkerpop.gremlin.server;
import java.io.File;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.log4j.Logger;
-import org.apache.tinkerpop.gremlin.driver.Client;
-import org.apache.tinkerpop.gremlin.driver.Cluster;
-import org.apache.tinkerpop.gremlin.driver.ResultSet;
-import org.apache.tinkerpop.gremlin.driver.Tokens;
+import org.apache.tinkerpop.gremlin.driver.*;
import org.apache.tinkerpop.gremlin.driver.exception.ResponseException;
import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
@@ -551,6 +548,20 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
fail();
} catch (RuntimeException re) {
assertTrue(re.getCause().getCause() instanceof ClosedChannelException);
+
+ //
+ // should recover when the server comes back
+ //
+
+ // restart server
+ this.startServer();
+ // the retry interval is 1 second, wait a bit longer
+ TimeUnit.SECONDS.sleep(5);
+
+ List<Result> results = client.submit("1+1").all().join();
+ assertEquals(1, results.size());
+ assertEquals(2, results.get(0).getInt());
+
} finally {
cluster.close();
}
[6/7] incubator-tinkerpop git commit: Merge branch 'tp31' of
https://github.com/kieransherlock/incubator-tinkerpop into
TINKERPOP-1125-to-1127
Posted by sp...@apache.org.
Merge branch 'tp31' of https://github.com/kieransherlock/incubator-tinkerpop into TINKERPOP-1125-to-1127
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/bf90af02
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/bf90af02
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/bf90af02
Branch: refs/heads/TINKERPOP-1125-to-1127
Commit: bf90af02ea2128d4461c9eca952b1c90257e6834
Parents: b07400c f1800bd
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Feb 10 07:27:34 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Feb 10 07:27:34 2016 -0500
----------------------------------------------------------------------
.../src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java | 2 +-
.../java/org/apache/tinkerpop/gremlin/driver/ConnectionPool.java | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------