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 2017/06/28 17:50:10 UTC
[1/7] tinkerpop git commit: TINKERPOP-741 Deprecated
Transaction.submit(Function)
Repository: tinkerpop
Updated Branches:
refs/heads/master ea20ca192 -> ec1159340
TINKERPOP-741 Deprecated Transaction.submit(Function)
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/eba0a2c0
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/eba0a2c0
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/eba0a2c0
Branch: refs/heads/master
Commit: eba0a2c0a3dbb8ea1bb4d5358b8c7445cad15c85
Parents: 9af4cce
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jun 19 11:45:32 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jun 19 11:51:51 2017 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
docs/src/reference/the-graph.asciidoc | 20 --------------------
.../gremlin/structure/Transaction.java | 4 ++++
.../structure/util/AbstractTransaction.java | 2 ++
4 files changed, 7 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eba0a2c0/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 4e6dc16..bfb7aa9 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -28,6 +28,7 @@ TinkerPop 3.2.6 (Release Date: NOT OFFICIALLY RELEASED YET)
This release also includes changes from <<release-3-1-8, 3.1.8>>.
+* Deprecated `Transaction.submit(Function)`.
* Fixed `HADOOP_GREMLIN_LIBS` parsing for Windows.
* Improved GraphSON serialization performance around `VertexProperty`.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eba0a2c0/docs/src/reference/the-graph.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-graph.asciidoc b/docs/src/reference/the-graph.asciidoc
index 063c174..b66f5bd 100644
--- a/docs/src/reference/the-graph.asciidoc
+++ b/docs/src/reference/the-graph.asciidoc
@@ -280,26 +280,6 @@ NOTE: It may be important to consult the documentation of the `Graph` implementa
specifics of how transactions will behave. TinkerPop allows some latitude in this area and implementations may not have
the exact same behaviors and link:https://en.wikipedia.org/wiki/ACID[ACID] guarantees.
-Retries
-~~~~~~~
-
-There are times when transactions fail. Failure may be indicative of some permanent condition, but other failures
-might simply require the transaction to be retried for possible future success. The `Transaction` object also exposes
-a method for executing automatic transaction retries:
-
-[gremlin-groovy]
-----
-graph = Neo4jGraph.open('/tmp/neo4j')
-graph.tx().submit {it.addVertex("name","josh")}.retry(10)
-graph.tx().submit {it.addVertex("name","daniel")}.exponentialBackoff(10)
-graph.close()
-----
-
-As shown above, the `submit` method takes a `Function<Graph, R>` which is the unit of work to execute and possibly
-retry on failure. The method returns a `Transaction.Workload` object which has a number of default methods for common
-retry strategies. It is also possible to supply a custom retry function if a default one does not suit the required
-purpose.
-
Threaded Transactions
~~~~~~~~~~~~~~~~~~~~~
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eba0a2c0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Transaction.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Transaction.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Transaction.java
index 82f3820..ff4232d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Transaction.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Transaction.java
@@ -63,7 +63,9 @@ public interface Transaction extends AutoCloseable {
/**
* Submit a unit of work that represents a transaction returning a {@link Workload} that can be automatically
* retried in the event of failure.
+ * @deprecated As of release 3.2.6, not replaced.
*/
+ @Deprecated
public <R> Workload<R> submit(final Function<Graph, R> work);
/**
@@ -228,7 +230,9 @@ public interface Transaction extends AutoCloseable {
* or the unit of work succeeds with a commit operation.
*
* @param <R> The type of the result from the unit of work.
+ * @deprecated As of release 3.2.6, not replaced.
*/
+ @Deprecated
public static class Workload<R> {
public static final long DEFAULT_DELAY_MS = 20;
public static final int DEFAULT_TRIES = 8;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eba0a2c0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
index 00d15c5..35f484e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
@@ -125,8 +125,10 @@ public abstract class AbstractTransaction implements Transaction {
/**
* {@inheritDoc}
+ * @deprecated As of release 3.2.6, not replaced.
*/
@Override
+ @Deprecated
public <R> Workload<R> submit(final Function<Graph, R> work) {
return new Workload<>(g, work);
}
[2/7] tinkerpop git commit: Merge branch 'TINKERPOP-741' into
TINKERPOP-741-master
Posted by sp...@apache.org.
Merge branch 'TINKERPOP-741' into TINKERPOP-741-master
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/21102e4f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/21102e4f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/21102e4f
Branch: refs/heads/master
Commit: 21102e4fa86c1094a36e44bba8147d27f3da7628
Parents: 05d8a0a eba0a2c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jun 19 11:52:04 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jun 19 11:52:04 2017 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
docs/src/reference/the-graph.asciidoc | 20 --------------------
.../gremlin/structure/Transaction.java | 4 ++++
.../structure/util/AbstractTransaction.java | 2 ++
4 files changed, 7 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21102e4f/CHANGELOG.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21102e4f/docs/src/reference/the-graph.asciidoc
----------------------------------------------------------------------
[3/7] tinkerpop git commit: TINKERPOP-741 Removed deprecated
transaction retry methods
Posted by sp...@apache.org.
TINKERPOP-741 Removed deprecated transaction retry methods
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/80822ee5
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/80822ee5
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/80822ee5
Branch: refs/heads/master
Commit: 80822ee52c7eb500e38a444d44f98b5469c496e6
Parents: 21102e4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jun 19 12:15:33 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jun 19 12:15:33 2017 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../gremlin/structure/Transaction.java | 216 -----------------
.../structure/util/AbstractTransaction.java | 9 -
.../gremlin/structure/TransactionTest.java | 242 +------------------
4 files changed, 11 insertions(+), 457 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/80822ee5/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index af56ed1..ddf3a83 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -32,6 +32,7 @@ TinkerPop 3.3.0 (Release Date: NOT OFFICIALLY RELEASED YET)
* Added "attachment requisite" `VertexProperty.element()` and `Property.element()` data in GraphSON serialization.
* GraphSON 3.0 is now the default serialization format in TinkerGraph and Gremlin Server.
* Established the GraphSON 3.0 format.
+* Removed previously deprecated `Transaction.submit(Function)`.
* Removed previously deprecated `OpSelectorHandler.errorMeter` and `AbstractEvalOpProcessor.errorMeter` fields.
* Removed previously deprecated `AbstractEvalOpProcessor.validBindingName` field.
* Removed previously deprecated `SimpleAuthenticator.CONFIG_CREDENTIALS_LOCATION` field.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/80822ee5/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Transaction.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Transaction.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Transaction.java
index ff4232d..8d73bf6 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Transaction.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Transaction.java
@@ -61,14 +61,6 @@ public interface Transaction extends AutoCloseable {
public void rollback();
/**
- * Submit a unit of work that represents a transaction returning a {@link Workload} that can be automatically
- * retried in the event of failure.
- * @deprecated As of release 3.2.6, not replaced.
- */
- @Deprecated
- public <R> Workload<R> submit(final Function<Graph, R> work);
-
- /**
* Creates a transaction that can be executed across multiple threads. The {@link Graph} returned from this
* method is not meant to represent some form of child transaction that can be committed from this object.
* A threaded transaction is a {@link Graph} instance that has a transaction context that enables multiple
@@ -221,212 +213,4 @@ public interface Transaction extends AutoCloseable {
}
}
}
-
- /**
- * A {@link Workload} represents a unit of work constructed by the {@link Workload#submit(Function)} method on
- * the {@link Transaction} interface. The unit of work is a {@link Function} typically containing mutations to
- * the {@link Graph}. The {@link Workload} is responsible for executing the unit of work in the context of a
- * retry strategy, such that a failed unit of work is rolled back and executed again until retries are exhausted
- * or the unit of work succeeds with a commit operation.
- *
- * @param <R> The type of the result from the unit of work.
- * @deprecated As of release 3.2.6, not replaced.
- */
- @Deprecated
- public static class Workload<R> {
- public static final long DEFAULT_DELAY_MS = 20;
- public static final int DEFAULT_TRIES = 8;
-
- private final Function<Graph, R> workToDo;
- private final Graph g;
-
- /**
- * Creates a new {@link Workload} that will be tried to be executed within a transaction.
- *
- * @param g The {@link Graph} instance on which the work will be performed.
- * @param work The work to be executed on the Graph instance which will optionally return a value.
- */
- public Workload(final Graph g, final Function<Graph, R> work) {
- this.g = g;
- this.workToDo = work;
- }
-
- /**
- * Try to execute a {@link Workload} with a mapper retry strategy.
- *
- * @param retryStrategy The first argument to this function is the Graph instance and the second is
- * the encapsulated work to be performed. The function should ultimately return the
- * result of the encapsulated work function.
- * @return The result of the encapsulated work.
- */
- public R attempt(final BiFunction<Graph, Function<Graph, R>, R> retryStrategy) {
- return retryStrategy.apply(g, workToDo);
- }
-
- /**
- * Executes the {@link Workload} committing if possible and rolling back on failure. On failure, an exception
- * is reported.
- */
- public R oneAndDone() {
- return attempt((g, w) -> {
- try {
- R result = w.apply(g);
- g.tx().commit();
-
- return result;
- } catch (Throwable t) {
- g.tx().rollback();
- throw new RuntimeException(t);
- }
- });
- }
-
- /**
- * Executes the {@link Workload} committing if possible and rolling back on failure. On failure no exception
- * is reported.
- */
- public R fireAndForget() {
- return attempt((g, w) -> {
- R result = null;
- try {
- result = w.apply(g);
- g.tx().commit();
- } catch (Throwable t) {
- g.tx().rollback();
- }
-
- return result;
- });
- }
-
- /**
- * Executes the {@link Workload} with the default number of retries and with the default number of
- * milliseconds delay between each try.
- */
- public R retry() {
- return retry(DEFAULT_TRIES);
- }
-
- /**
- * Executes the {@link Workload} with a number of retries and with the default number of milliseconds delay
- * between each try.
- */
- public R retry(final int tries) {
- return retry(tries, DEFAULT_DELAY_MS);
- }
-
- /**
- * Executes the {@link Workload} with a number of retries and with a number of milliseconds delay between
- * each try.
- */
- public R retry(final int tries, final long delay) {
- return retry(tries, delay, Collections.emptySet());
- }
-
- /**
- * Executes the {@link Workload} with a number of retries and with a number of milliseconds delay between each
- * try and will only retry on the set of supplied exceptions. Exceptions outside of that set will generate a
- * RuntimeException and immediately fail.
- */
- public R retry(final int tries, final long delay, final Set<Class> exceptionsToRetryOn) {
- return attempt(retry(tries, exceptionsToRetryOn, i -> delay));
- }
-
- /**
- * Executes the {@link Workload} with the default number of retries and with a exponentially increasing
- * number of milliseconds between each retry using the default retry delay.
- */
- public R exponentialBackoff() {
- return exponentialBackoff(DEFAULT_TRIES);
- }
-
- /**
- * Executes the {@link Workload} with a number of retries and with a exponentially increasing number of
- * milliseconds between each retry using the default retry delay.
- */
- public R exponentialBackoff(final int tries) {
- return exponentialBackoff(tries, DEFAULT_DELAY_MS);
- }
-
- /**
- * Executes the {@link Workload} with a number of retries and with a exponentially increasing number of
- * milliseconds between each retry.
- */
- public R exponentialBackoff(final int tries, final long initialDelay) {
- return exponentialBackoff(tries, initialDelay, Collections.emptySet());
- }
-
- /**
- * Executes the {@link Workload} with a number of retries and with a exponentially increasing number of
- * milliseconds between each retry. It will only retry on the set of supplied exceptions. Exceptions outside
- * of that set will generate a {@link RuntimeException} and immediately fail.
- */
- public R exponentialBackoff(final int tries, final long initialDelay, final Set<Class> exceptionsToRetryOn) {
- return attempt(retry(tries, exceptionsToRetryOn, retryCount -> (long) (initialDelay * Math.pow(2, retryCount))));
- }
-
- /**
- * Creates a generic retry function to be passed to the {@link Workload#attempt(java.util.function.BiFunction)}
- * method.
- */
- private static <R> BiFunction<Graph, Function<Graph, R>, R> retry(final int tries,
- final Set<Class> exceptionsToRetryOn,
- final Function<Integer, Long> delay) {
- return (g, w) -> {
- R returnValue;
-
- // this is the default exception...it may get reassgined during retries
- Exception previousException = new RuntimeException("Exception initialized when trying commit");
-
- // try to commit a few times
- for (int ix = 0; ix < tries; ix++) {
-
- // increase time after each failed attempt though there is no delay on the first try
- if (ix > 0)
- try {
- Thread.sleep(delay.apply(ix));
- } catch (InterruptedException ignored) {
- }
-
- try {
- // ensure that a transaction is open for this try. even if there was an open transaction
- // from the first try it would be rolled back on failure and unless automatic transactions
- // are used, the transaction would be closed on the next retry.
- if (!g.tx().isOpen()) g.tx().open();
-
- returnValue = w.apply(g);
- g.tx().commit();
-
- // need to exit the function here so that retries don't happen
- return returnValue;
- } catch (Exception ex) {
- g.tx().rollback();
-
- // retry if this is an allowed exception otherwise, just throw and go
- boolean retry = false;
- if (exceptionsToRetryOn.size() == 0)
- retry = true;
- else {
- for (Class exceptionToRetryOn : exceptionsToRetryOn) {
- if (ex.getClass().equals(exceptionToRetryOn)) {
- retry = true;
- break;
- }
- }
- }
-
- if (!retry) {
- throw new RuntimeException(ex);
- }
-
- previousException = ex;
- }
- }
-
- // the exception just won't go away after all the retries
- throw new RuntimeException(previousException);
- };
- }
- }
-
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/80822ee5/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
index 35f484e..fec7df7 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
@@ -125,15 +125,6 @@ public abstract class AbstractTransaction implements Transaction {
/**
* {@inheritDoc}
- * @deprecated As of release 3.2.6, not replaced.
- */
- @Override
- @Deprecated
- public <R> Workload<R> submit(final Function<Graph, R> work) {
- return new Workload<>(g, work);
- }
- /**
- * {@inheritDoc}
*/
@Override
public <G extends Graph> G createThreadedTx() {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/80822ee5/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/TransactionTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/TransactionTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/TransactionTest.java
index 4dbbc5f..ad08132 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/TransactionTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/TransactionTest.java
@@ -22,15 +22,12 @@ import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
import org.apache.tinkerpop.gremlin.ExceptionCoverage;
import org.apache.tinkerpop.gremlin.FeatureRequirement;
import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
-import org.apache.tinkerpop.gremlin.util.function.FunctionUtils;
import org.apache.commons.configuration.Configuration;
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
import org.junit.Test;
-import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.Random;
-import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -44,7 +41,9 @@ import static org.apache.tinkerpop.gremlin.structure.Graph.Features.VertexProper
import static org.apache.tinkerpop.gremlin.structure.Graph.Features.VertexPropertyFeatures.FEATURE_INTEGER_VALUES;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
/**
* @author Stephen Mallette (http://stephen.genoprime.com)
@@ -407,7 +406,7 @@ public class TransactionTest extends AbstractGremlinTest {
t.join();
// this was committed
- assertTrue(graph.vertices(vid.get().id()).hasNext());
+ assertThat(graph.vertices(vid.get().id()).hasNext(), is(true));
try {
// this was not
@@ -571,7 +570,7 @@ public class TransactionTest extends AbstractGremlinTest {
threadTxStarter.join();
threadTryCommitTx.join();
- assertTrue(noVerticesInFirstThread.get());
+ assertThat(noVerticesInFirstThread.get(), is(true));
assertVertexEdgeCounts(graph, 0, 0);
}
@@ -653,224 +652,6 @@ public class TransactionTest extends AbstractGremlinTest {
}
@Test
- @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
- @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
- public void shouldSupportTransactionFireAndForget() {
- // first fail the tx
- g.tx().submit(FunctionUtils.wrapFunction(grx -> {
- grx.addVertex();
- throw new Exception("fail");
- })).fireAndForget();
- assertVertexEdgeCounts(graph, 0, 0);
-
- // this tx will work
- g.tx().submit(grx -> graph.addVertex()).fireAndForget();
- assertVertexEdgeCounts(graph, 1, 0);
-
- // make sure a commit happened and a new tx started
- g.tx().rollback();
- assertVertexEdgeCounts(graph, 1, 0);
- }
-
- @Test
- @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
- @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
- public void shouldSupportTransactionOneAndDone() {
- // first fail the tx
- try {
- g.tx().submit(FunctionUtils.wrapFunction(grx -> {
- grx.addVertex();
- throw new Exception("fail");
- })).oneAndDone();
- } catch (Exception ex) {
- assertEquals("fail", ex.getCause().getCause().getMessage());
- }
-
- assertVertexEdgeCounts(graph, 0, 0);
-
- // this tx will work
- g.tx().submit(grx -> graph.addVertex()).oneAndDone();
- assertVertexEdgeCounts(graph, 1, 0);
-
- // make sure a commit happened and a new tx started
- g.tx().rollback();
- assertVertexEdgeCounts(graph, 1, 0);
- }
-
- @Test
- @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
- @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
- public void shouldSupportTransactionExponentialBackoff() {
-
- // first fail the tx
- final AtomicInteger attempts = new AtomicInteger(0);
- try {
- g.tx().submit(FunctionUtils.wrapFunction(grx -> {
- grx.addVertex();
- attempts.incrementAndGet();
- throw new Exception("fail");
- })).exponentialBackoff();
- } catch (Exception ex) {
- assertEquals("fail", ex.getCause().getCause().getMessage());
- }
-
- assertEquals(Transaction.Workload.DEFAULT_TRIES, attempts.get());
- assertVertexEdgeCounts(graph, 0, 0);
-
- // this tx will work after several tries
- final AtomicInteger tries = new AtomicInteger(0);
- g.tx().submit(FunctionUtils.wrapFunction(grx -> {
- final int tryNumber = tries.incrementAndGet();
- if (tryNumber == Transaction.Workload.DEFAULT_TRIES - 2)
- return graph.addVertex();
- else
- throw new Exception("fail");
- })).exponentialBackoff();
-
- assertEquals(Transaction.Workload.DEFAULT_TRIES - 2, tries.get());
- assertVertexEdgeCounts(graph, 1, 0);
-
- // make sure a commit happened and a new tx started
- g.tx().rollback();
- assertVertexEdgeCounts(graph, 1, 0);
- }
-
- @Test
- @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
- @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
- public void shouldSupportTransactionExponentialBackoffWithExceptionChecks() {
- final Set<Class> exceptions = new HashSet<Class>() {{
- add(IllegalStateException.class);
- }};
-
- // first fail the tx
- final AtomicInteger attempts = new AtomicInteger(0);
- try {
- g.tx().submit(FunctionUtils.wrapFunction(grx -> {
- grx.addVertex();
- attempts.incrementAndGet();
- throw new Exception("fail");
- })).exponentialBackoff(Transaction.Workload.DEFAULT_TRIES, 20, exceptions);
- } catch (Exception ex) {
- assertEquals("fail", ex.getCause().getCause().getMessage());
- }
-
- assertEquals(1, attempts.get());
- assertVertexEdgeCounts(graph, 0, 0);
-
- // this tx will retry for specific tx and then fail after several tries
- final AtomicInteger setOfTries = new AtomicInteger(0);
- try {
- g.tx().submit(FunctionUtils.wrapFunction(grx -> {
- final int tryNumber = setOfTries.incrementAndGet();
- if (tryNumber == Transaction.Workload.DEFAULT_TRIES - 2)
- throw new Exception("fail");
- else
- throw new IllegalStateException("fail");
- })).exponentialBackoff(Transaction.Workload.DEFAULT_TRIES, 20, exceptions);
- } catch (Exception ex) {
- assertEquals("fail", ex.getCause().getCause().getMessage());
- }
-
- assertEquals(Transaction.Workload.DEFAULT_TRIES - 2, setOfTries.get());
- assertVertexEdgeCounts(graph, 0, 0);
-
- // this tx will work after several tries
- final AtomicInteger tries = new AtomicInteger(0);
- g.tx().submit(FunctionUtils.wrapFunction(grx -> {
- final int tryNumber = tries.incrementAndGet();
- if (tryNumber == Transaction.Workload.DEFAULT_TRIES - 2)
- return graph.addVertex();
- else
- throw new IllegalStateException("fail");
- })).exponentialBackoff(Transaction.Workload.DEFAULT_TRIES, 20, exceptions);
-
- assertEquals(Transaction.Workload.DEFAULT_TRIES - 2, tries.get());
- assertVertexEdgeCounts(graph, 1, 0);
-
- // make sure a commit happened and a new tx started
- g.tx().rollback();
- assertVertexEdgeCounts(graph, 1, 0);
- }
-
- @Test
- @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
- @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
- public void shouldSupportTransactionRetry() {
- // first fail the tx
- final AtomicInteger attempts = new AtomicInteger(0);
- try {
- g.tx().submit(FunctionUtils.wrapFunction(grx -> {
- grx.addVertex();
- attempts.incrementAndGet();
- throw new Exception("fail");
- })).retry();
- } catch (Exception ex) {
- assertEquals("fail", ex.getCause().getCause().getMessage());
- }
-
- assertEquals(Transaction.Workload.DEFAULT_TRIES, attempts.get());
- assertVertexEdgeCounts(graph, 0, 0);
-
- // this tx will work after several tries
- final AtomicInteger tries = new AtomicInteger(0);
- g.tx().submit(FunctionUtils.wrapFunction(grx -> {
- final int tryNumber = tries.incrementAndGet();
- if (tryNumber == Transaction.Workload.DEFAULT_TRIES - 2)
- return graph.addVertex();
- else
- throw new Exception("fail");
- })).retry();
-
- assertEquals(Transaction.Workload.DEFAULT_TRIES - 2, tries.get());
- assertVertexEdgeCounts(graph, 1, 0);
-
- // make sure a commit happened and a new tx started
- g.tx().rollback();
- assertVertexEdgeCounts(graph, 1, 0);
- }
-
- @Test
- @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
- @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
- public void shouldSupportTransactionRetryWhenUsingManualTransactions() {
- g.tx().onReadWrite(Transaction.READ_WRITE_BEHAVIOR.MANUAL);
-
- // first fail the tx
- final AtomicInteger attempts = new AtomicInteger(0);
- try {
- g.tx().submit(FunctionUtils.wrapFunction(grx -> {
- grx.addVertex();
- attempts.incrementAndGet();
- throw new Exception("fail");
- })).retry();
- } catch (Exception ex) {
- assertEquals("fail", ex.getCause().getCause().getMessage());
- }
-
- assertEquals(Transaction.Workload.DEFAULT_TRIES, attempts.get());
- assertFalse(g.tx().isOpen());
- g.tx().open();
- assertVertexEdgeCounts(graph, 0, 0);
-
- // this tx will work after several tries
- final AtomicInteger tries = new AtomicInteger(0);
- g.tx().submit(FunctionUtils.wrapFunction(grx -> {
- final int tryNumber = tries.incrementAndGet();
- if (tryNumber == Transaction.Workload.DEFAULT_TRIES - 2)
- return graph.addVertex();
- else
- throw new Exception("fail");
- })).retry();
-
- assertEquals(Transaction.Workload.DEFAULT_TRIES - 2, tries.get());
- assertFalse(g.tx().isOpen());
- g.tx().open();
- assertVertexEdgeCounts(graph, 1, 0);
- g.tx().rollback();
- }
-
- @Test
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
@@ -1149,14 +930,11 @@ public class TransactionTest extends AbstractGremlinTest {
manualThread.join();
autoThread.join();
- assertTrue(
- "manualThread transaction readWrite should be MANUAL and should fail to commit the transaction",
- commitFailed.get()
- );
- assertTrue(
- "autoThread transaction readWrite should be AUTO and should commit the transaction",
- commitOccurred.get()
- );
+ assertThat("manualThread transaction readWrite should be MANUAL and should fail to commit the transaction",
+ commitFailed.get(),
+ is(true));
+ assertThat("autoThread transaction readWrite should be AUTO and should commit the transaction",
+ commitOccurred.get(), is(true));
}
@Test
[5/7] tinkerpop git commit: Merge branch 'TINKERPOP-741' into tp32
Posted by sp...@apache.org.
Merge branch 'TINKERPOP-741' into tp32
Conflicts:
CHANGELOG.asciidoc
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/aa81313b
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/aa81313b
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/aa81313b
Branch: refs/heads/master
Commit: aa81313ba1e031f895c02529573bffd79a999d9c
Parents: 9436585 eba0a2c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jun 28 13:32:11 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Jun 28 13:32:11 2017 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
docs/src/reference/the-graph.asciidoc | 20 --------------------
.../gremlin/structure/Transaction.java | 4 ++++
.../structure/util/AbstractTransaction.java | 2 ++
4 files changed, 7 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aa81313b/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index 9da8d47,bfb7aa9..ba9f2a7
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -28,11 -28,9 +28,12 @@@ TinkerPop 3.2.6 (Release Date: NOT OFFI
This release also includes changes from <<release-3-1-8, 3.1.8>>.
+* Added annotations to the traversal metrics pretty print.
+* `EdgeVertexStep` is no longer final and can be extended by providers.
+ * Deprecated `Transaction.submit(Function)`.
* Fixed `HADOOP_GREMLIN_LIBS` parsing for Windows.
* Improved GraphSON serialization performance around `VertexProperty`.
+* Changed some tests in `EventStrategyProcessTest` which were enforcing some unintended semantics around transaction state.
[[release-3-2-5]]
TinkerPop 3.2.5 (Release Date: June 12, 2017)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aa81313b/docs/src/reference/the-graph.asciidoc
----------------------------------------------------------------------
[7/7] tinkerpop git commit: Merge branch 'TINKERPOP-741-master'
Posted by sp...@apache.org.
Merge branch 'TINKERPOP-741-master'
Conflicts:
CHANGELOG.asciidoc
docs/src/upgrade/release-3.3.x.asciidoc
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/ec115934
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/ec115934
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/ec115934
Branch: refs/heads/master
Commit: ec1159340d771cee9c72999fd506f377d50eb1c8
Parents: 0551620 21bc4d8
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jun 28 13:33:51 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Jun 28 13:33:51 2017 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
docs/src/upgrade/release-3.3.x.asciidoc | 1 +
.../gremlin/structure/Transaction.java | 216 -----------------
.../structure/util/AbstractTransaction.java | 9 -
.../gremlin/structure/TransactionTest.java | 242 +------------------
5 files changed, 12 insertions(+), 457 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec115934/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index 3aee122,ddf3a83..e158be1
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -35,13 -32,7 +35,14 @@@ TinkerPop 3.3.0 (Release Date: NOT OFFI
* Added "attachment requisite" `VertexProperty.element()` and `Property.element()` data in GraphSON serialization.
* GraphSON 3.0 is now the default serialization format in TinkerGraph and Gremlin Server.
* Established the GraphSON 3.0 format.
+* Removed previously deprecated `Io.Builder#registry(IoRegistry)` method.
+* Removed previously deprecated `GryoMessageSerializerV1d0(GryoMapper)` constructor.
+* Removed previously deprecated `TinkerIoRegistry`.
+* Removed previously deprecated `getInstance()` methods on all TinkerPop classes.
+* Removed previously deprecated `VertexPropertyFeatures.supportsAddProperty()`.
+* Removed previously deprecated TinkerGraph configuration member variables.
+* Changed `ServerGremlinExecutor` to not use generics since there really is no flexibility in the kind of `ScheduledExecutorService` that will be used.
+ * Removed previously deprecated `Transaction.submit(Function)`.
* Removed previously deprecated `OpSelectorHandler.errorMeter` and `AbstractEvalOpProcessor.errorMeter` fields.
* Removed previously deprecated `AbstractEvalOpProcessor.validBindingName` field.
* Removed previously deprecated `SimpleAuthenticator.CONFIG_CREDENTIALS_LOCATION` field.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec115934/docs/src/upgrade/release-3.3.x.asciidoc
----------------------------------------------------------------------
diff --cc docs/src/upgrade/release-3.3.x.asciidoc
index 6fefe28,9507603..0f71714
--- a/docs/src/upgrade/release-3.3.x.asciidoc
+++ b/docs/src/upgrade/release-3.3.x.asciidoc
@@@ -208,9 -196,7 +208,10 @@@ The following deprecated classes, metho
** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_PROCESS_COMPUTER`
** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_ENVIRONMENT`
** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_ENVIRONMENT_INTEGRATE`
+** `org.apache.tinkerpop.gremlin.structure.io.Io.Builder#registry(IoRegistry)`
+ ** `org.apache.tinkerpop.gremlin.structure.Transaction.submit(Function)`
+* `gremlin-driver`
+** `org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0(GryoMapper)`
* `gremlin-groovy`
** `org.apache.tinkerpop.gremlin.groovy.AbstractImportCustomizerProvider`
** `org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider`
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec115934/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Transaction.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ec115934/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
----------------------------------------------------------------------
[6/7] tinkerpop git commit: Merge branch 'tp32'
Posted by sp...@apache.org.
Merge branch 'tp32'
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/0551620f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/0551620f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/0551620f
Branch: refs/heads/master
Commit: 0551620f1f30bb40dad631e8862b33d97c436cf2
Parents: ea20ca1 aa81313
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jun 28 13:32:47 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Jun 28 13:32:47 2017 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
docs/src/reference/the-graph.asciidoc | 20 --------------------
.../gremlin/structure/Transaction.java | 4 ++++
.../structure/util/AbstractTransaction.java | 2 ++
4 files changed, 7 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0551620f/CHANGELOG.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0551620f/docs/src/reference/the-graph.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0551620f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Transaction.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0551620f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/AbstractTransaction.java
----------------------------------------------------------------------
[4/7] tinkerpop git commit: TINKERPOP-741 Added upgrade docs around
deprecation
Posted by sp...@apache.org.
TINKERPOP-741 Added upgrade docs around deprecation
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/21bc4d85
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/21bc4d85
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/21bc4d85
Branch: refs/heads/master
Commit: 21bc4d85945cdd9beeeaedd92eb2769d75de53ba
Parents: 80822ee
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jun 19 12:24:47 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jun 19 12:25:09 2017 -0400
----------------------------------------------------------------------
docs/src/upgrade/release-3.3.x.asciidoc | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21bc4d85/docs/src/upgrade/release-3.3.x.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc
index dbb40b4..9507603 100644
--- a/docs/src/upgrade/release-3.3.x.asciidoc
+++ b/docs/src/upgrade/release-3.3.x.asciidoc
@@ -196,6 +196,7 @@ The following deprecated classes, methods or fields have been removed in this ve
** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_PROCESS_COMPUTER`
** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_ENVIRONMENT`
** `org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_ENVIRONMENT_INTEGRATE`
+** `org.apache.tinkerpop.gremlin.structure.Transaction.submit(Function)`
* `gremlin-groovy`
** `org.apache.tinkerpop.gremlin.groovy.AbstractImportCustomizerProvider`
** `org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider`