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 2015/05/06 17:54:22 UTC
[1/2] incubator-tinkerpop git commit: toString calls on some of the
gremlin-driver objects were kinda expensive.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master 911489b28 -> 710295654
toString calls on some of the gremlin-driver objects were kinda expensive.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/319ede46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/319ede46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/319ede46
Branch: refs/heads/master
Commit: 319ede46123a0ce135133788bed510f45bb0cefc
Parents: 9ad039a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed May 6 11:38:09 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed May 6 11:38:09 2015 -0400
----------------------------------------------------------------------
.../tinkerpop/gremlin/driver/Connection.java | 16 ++++++++++----
.../gremlin/driver/ConnectionPool.java | 22 +++++++++++++-------
.../apache/tinkerpop/gremlin/driver/Host.java | 7 +++----
3 files changed, 29 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/319ede46/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
index 659f4ad..959b531 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Connection.java
@@ -64,6 +64,8 @@ class Connection {
private volatile boolean isDead = false;
private final int maxInProcess;
+ private final String connectionLabel;
+
private final AtomicReference<CompletableFuture<Void>> closeFuture = new AtomicReference<>();
public Connection(final URI uri, final ConnectionPool pool, final Cluster cluster, final int maxInProcess) throws ConnectionException {
@@ -72,6 +74,8 @@ class Connection {
this.pool = pool;
this.maxInProcess = maxInProcess;
+ connectionLabel = String.format("Connection{host=%s}", pool.host);
+
final Bootstrap b = this.cluster.getFactory().createBootstrap();
// todo: dynamically instantiate the channelizer from settings
@@ -154,7 +158,7 @@ class Connection {
final ChannelPromise promise = channel.newPromise()
.addListener(f -> {
if (!f.isSuccess()) {
- logger.debug(String.format("Write on connection %s failed", thisConnection), f.cause());
+ logger.debug(String.format("Write on connection %s failed", thisConnection.getConnectionInfo()), f.cause());
thisConnection.isDead = true;
thisConnection.returnToPool();
future.completeExceptionally(f.cause());
@@ -185,7 +189,7 @@ class Connection {
try {
if (pool != null) pool.returnConnection(this);
} catch (ConnectionException ce) {
- logger.debug("Returned {} connection to {} but an error occurred - {}", this, pool, ce.getMessage());
+ logger.debug("Returned {} connection to {} but an error occurred - {}", this.getConnectionInfo(), pool, ce.getMessage());
}
}
@@ -202,9 +206,13 @@ class Connection {
channel.close(promise);
}
- @Override
- public String toString() {
+ public String getConnectionInfo() {
return String.format("Connection{host=%s, isDead=%s, inFlight=%s, pending=%s}",
pool.host, isDead, inFlight, pending.size());
}
+
+ @Override
+ public String toString() {
+ return connectionLabel;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/319ede46/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 eeac649..1e4d0c7 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
@@ -58,6 +58,7 @@ class ConnectionPool {
private final int minSimultaneousRequestsPerConnection;
private final int maxSimultaneousRequestsPerConnection;
private final int minInProcess;
+ private final String poolLabel;
private final AtomicInteger scheduledForCreation = new AtomicInteger();
@@ -70,6 +71,7 @@ class ConnectionPool {
public ConnectionPool(final Host host, final Cluster cluster) {
this.host = host;
this.cluster = cluster;
+ poolLabel = String.format("Connection Pool {host=%s}", host);
final Settings.ConnectionPoolSettings settings = settings();
this.minPoolSize = settings.minSize;
@@ -129,7 +131,7 @@ class ConnectionPool {
final int currentPoolSize = connections.size();
if (leastUsedConn.inFlight.get() >= maxSimultaneousRequestsPerConnection && currentPoolSize < maxPoolSize) {
logger.debug("Least used {} on {} exceeds maxSimultaneousRequestsPerConnection but pool size {} < maxPoolSize - consider new connection",
- leastUsedConn, host, currentPoolSize);
+ leastUsedConn.getConnectionInfo(), host, currentPoolSize);
considerNewConnection();
}
@@ -146,7 +148,7 @@ class ConnectionPool {
}
if (leastUsedConn.inFlight.compareAndSet(inFlight, inFlight + 1)) {
- logger.debug("Return least used {} on {}", leastUsedConn, host);
+ logger.debug("Return least used {} on {}", leastUsedConn.getConnectionInfo(), host);
return leastUsedConn;
}
}
@@ -176,10 +178,10 @@ class ConnectionPool {
final int availableInProcess = connection.availableInProcess();
if (poolSize > minPoolSize && inFlight <= minSimultaneousRequestsPerConnection) {
logger.debug("On {} pool size of {} > minPoolSize {} and inFlight of {} <= minSimultaneousRequestsPerConnection {} so destroy {}",
- host, poolSize, minPoolSize, inFlight, minSimultaneousRequestsPerConnection, connection);
+ host, poolSize, minPoolSize, inFlight, minSimultaneousRequestsPerConnection, connection.getConnectionInfo());
destroyConnection(connection);
} else if (connection.availableInProcess() < minInProcess) {
- logger.debug("On {} availableInProcess {} < minInProcess {} so replace {}", host, availableInProcess, minInProcess, connection);
+ logger.debug("On {} availableInProcess {} < minInProcess {} so replace {}", host, availableInProcess, minInProcess, connection.getConnectionInfo());
replaceConnection(connection);
} else
announceAvailableConnection();
@@ -301,7 +303,7 @@ class ConnectionPool {
if (connection.inFlight.get() == 0 && bin.remove(connection))
connection.closeAsync();
- logger.debug("{} destroyed", connection);
+ logger.debug("{} destroyed", connection.getConnectionInfo());
}
private Connection waitForConnection(final long timeout, final TimeUnit unit) throws TimeoutException, ConnectionException {
@@ -331,7 +333,7 @@ class ConnectionPool {
}
if (leastUsed.inFlight.compareAndSet(inFlight, inFlight + 1)) {
- logger.debug("Return least used {} on {} after waiting", leastUsed, host);
+ logger.debug("Return least used {} on {} after waiting", leastUsed.getConnectionInfo(), host);
return leastUsed;
}
}
@@ -428,8 +430,7 @@ class ConnectionPool {
}
}
- @Override
- public String toString() {
+ public String getPoolInfo() {
final StringBuilder sb = new StringBuilder("ConnectionPool (");
sb.append(host);
sb.append(") - ");
@@ -439,4 +440,9 @@ class ConnectionPool {
});
return sb.toString().trim();
}
+
+ @Override
+ public String toString() {
+ return poolLabel;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/319ede46/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 b573a48..7ed7e4f 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
@@ -38,6 +38,7 @@ class Host {
private final URI hostUri;
private volatile boolean isAvailable;
private final Cluster cluster;
+ private final String hostLabel;
final AtomicReference<ScheduledFuture<?>> reconnectionAttempt = new AtomicReference<>(null);
@@ -45,6 +46,7 @@ class Host {
this.cluster = cluster;
this.address = address;
this.hostUri = makeUriFromAddress(address, cluster.connectionPoolSettings().enableSsl);
+ hostLabel = String.format("Host{address=%s, hostUri=%s}", address, hostUri);
}
public InetSocketAddress getAddress() {
@@ -92,10 +94,7 @@ class Host {
@Override
public String toString() {
- return "Host{" +
- "address=" + address +
- ", hostUri=" + hostUri +
- '}';
+ return hostLabel;
}
public static interface Listener {
[2/2] incubator-tinkerpop git commit: Merge remote-tracking branch
'origin/master'
Posted by sp...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/71029565
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/71029565
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/71029565
Branch: refs/heads/master
Commit: 710295654fd71c330d65714168ef356f5d7687d3
Parents: 319ede4 911489b
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed May 6 11:38:41 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed May 6 11:38:41 2015 -0400
----------------------------------------------------------------------
.../process/traversal/TraversalStrategies.java | 3 +-
.../lambda/AbstractLambdaTraversal.java | 11 +-
.../traversal/lambda/HasNextTraversal.java | 13 +-
.../decoration/ConjunctionStrategy.java | 7 +
.../decoration/LabeledEndStepStrategy.java | 51 --------
.../AdjacentToIncidentStrategy.java | 15 ++-
.../optimization/DedupBijectionStrategy.java | 29 ++++-
.../optimization/IdentityRemovalStrategy.java | 7 +
.../IncidentToAdjacentStrategy.java | 117 +++++++++++++++++
.../optimization/MatchWhereStrategy.java | 16 ++-
.../verification/LambdaRestrictionStrategy.java | 28 ++--
.../strategy/verification/ReadOnlyStrategy.java | 14 +-
.../decoration/ConjunctionStrategyTest.java | 125 ++++++++++++++++++
.../AdjacentToIncidentStrategyTest.java | 10 +-
.../DedupBijectionStrategyTest.java | 127 ++++++++++++++++++
.../IdentityRemovalStrategyTest.java | 128 ++++++++++++++++++
.../IncidentToAdjacentStrategyTest.java | 130 +++++++++++++++++++
.../optimization/MatchWhereStrategyTest.java | 126 ++++++++++++++++++
.../LambdaRestrictionStrategyTest.java | 20 ++-
.../verification/ReadOnlyStrategyTest.java | 4 +-
.../gremlin/groovy/function/GComparator.java | 5 +-
.../gremlin/groovy/function/GFunction.java | 3 +-
.../gremlin/groovy/function/GSupplier.java | 3 +-
.../gremlin/groovy/function/GUnaryOperator.java | 3 +-
.../gremlin/process/ProcessComputerSuite.java | 4 +-
.../gremlin/process/ProcessStandardSuite.java | 5 +-
...ComputerVerificationStrategyProcessTest.java | 129 ++++++++++++++++++
.../TraversalVerificationStrategyTest.java | 129 ------------------
.../tinkergraph/structure/TinkerGraphTest.java | 10 +-
29 files changed, 1033 insertions(+), 239 deletions(-)
----------------------------------------------------------------------