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/07/31 18:32:11 UTC

[1/3] incubator-tinkerpop git commit: Update javadoc.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/tp30 58b699e6b -> 7e4c80ddb


Update javadoc.


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

Branch: refs/heads/tp30
Commit: 1ba77237ae340592869da9b4532223f402cb2c25
Parents: 58b699e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 31 08:11:16 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 31 08:11:16 2015 -0400

----------------------------------------------------------------------
 .../java/org/apache/tinkerpop/gremlin/structure/Transaction.java  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1ba77237/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 d80c87f..14a346e 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
@@ -156,7 +156,8 @@ public interface Transaction extends Closeable {
     }
 
     /**
-     * Behaviors to supply to the {@link #onClose(Consumer)}.
+     * Behaviors to supply to the {@link #onClose(Consumer)}. The semantics of these behaviors must be examined in
+     * the context of the implementation.  In most cases, these behaviors will be applied as {{@link ThreadLocal}}.
      */
     public enum CLOSE_BEHAVIOR implements Consumer<Transaction> {
         /**


[2/3] incubator-tinkerpop git commit: Update javadoc around transactions/close behavor.

Posted by sp...@apache.org.
Update javadoc around transactions/close behavor.


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

Branch: refs/heads/tp30
Commit: 1359dc8045ce200ca169b072d98d283d4ece1c69
Parents: 1ba7723
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 31 08:25:17 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 31 08:25:17 2015 -0400

----------------------------------------------------------------------
 .../org/apache/tinkerpop/gremlin/structure/Graph.java    | 11 ++++++-----
 .../apache/tinkerpop/gremlin/structure/Transaction.java  |  9 +++++----
 .../tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java    |  1 -
 3 files changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1359dc80/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
index d4c15d8..355f824 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
@@ -246,11 +246,12 @@ public interface Graph extends AutoCloseable, Host {
     public Transaction tx();
 
     /**
-     * Closing a {@code Graph} is equivalent to "shutdown".  Users should consult the documentation of the underlying
-     * graph database implementation for what this "shutdown" will mean as it pertains to open transactions.  It will
-     * typically be the end user's responsibility to synchronize the thread that calls {@code close()} with other
-     * threads that are accessing open transactions. In other words, be sure that all work performed on the
-     * {@code Graph} instance is complete prior to calling this method.
+     * Closing a {@code Graph} is equivalent to "shutdown" and implies that no futher operations can be executed on
+     * the instance.  Users should consult the documentation of the underlying graph database implementation for what
+     * this "shutdown" will mean as it pertains to open transactions.  It will typically be the end user's
+     * responsibility to synchronize the thread that calls {@code close()} with other threads that are accessing open
+     * transactions. In other words, be sure that all work performed on the {@code Graph} instance is complete prior
+     * to calling this method.
      */
     @Override
     void close() throws Exception;

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1359dc80/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 14a346e..820649a 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
@@ -83,7 +83,8 @@ public interface Transaction extends Closeable {
     public void readWrite();
 
     /**
-     * Closes the transaction where the default close behavior will be executed.
+     * Closes the transaction where the default close behavior defined by {{@link #onClose(Consumer)}} will be
+     * executed.
      */
     @Override
     public void close();
@@ -161,7 +162,7 @@ public interface Transaction extends Closeable {
      */
     public enum CLOSE_BEHAVIOR implements Consumer<Transaction> {
         /**
-         * Any open transaction will commit on close.
+         * Commit the transaction when {@link #close()} is called.
          */
         COMMIT {
             @Override
@@ -171,7 +172,7 @@ public interface Transaction extends Closeable {
         },
 
         /**
-         * Any open transaction will rollback on close.
+         * Rollback the transaction when {@link #close()} is called.
          */
         ROLLBACK {
             @Override
@@ -181,7 +182,7 @@ public interface Transaction extends Closeable {
         },
 
         /**
-         * Open transactions on close will throw an exception
+         * Throw an exception if the current transaction is open when {@link #close()} is called.
          */
         MANUAL {
             @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/1359dc80/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
index 4c1b87b..3d1c0e0 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
@@ -272,7 +272,6 @@ public final class Neo4jGraph implements Graph, WrappedGraph<Neo4jGraphAPI> {
         return this.configuration;
     }
 
-
     /**
      * This implementation of {@code close} will also close the current transaction on the the thread, but it
      * is up to the caller to deal with dangling transactions in other threads prior to calling this method.


[3/3] incubator-tinkerpop git commit: Alter semantics of Transaction.close() in relation to Graph.close().

Posted by sp...@apache.org.
Alter semantics of Transaction.close() in relation to Graph.close().

More info on TINKERPOP3-764.  As a result of this change Neo4jGraph doesn't need to OptOut of one of the TransactionTests anymore.


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

Branch: refs/heads/tp30
Commit: 7e4c80ddba1da41cff9b3c688b1b40fc7d58b948
Parents: 1359dc8
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 31 12:21:15 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 31 12:21:15 2015 -0400

----------------------------------------------------------------------
 docs/src/the-graph.asciidoc                     |  2 +-
 .../gremlin/structure/TransactionTest.java      | 44 ++++++++++++--------
 .../gremlin/neo4j/structure/Neo4jGraph.java     |  4 --
 3 files changed, 27 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/7e4c80dd/docs/src/the-graph.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/the-graph.asciidoc b/docs/src/the-graph.asciidoc
index 007b4ff..c27c432 100644
--- a/docs/src/the-graph.asciidoc
+++ b/docs/src/the-graph.asciidoc
@@ -176,7 +176,7 @@ Providing a `Consumer` function to `onReadWrite` allows definition of how a tran
 * `AUTO` - automatic transactions where the transaction is started implicitly to the read or write operation
 * `MANUAL` - manual transactions where it is up to the user to explicitly open a transaction, throwing an exception if the transaction is not open
 
-Providing a `Consumer` function to `onClose` allows configuration of how a transaction is handled when `Graph.close()` is called.  `Transaction.CLOSE_BEHAVIOR` has several pre-defined options that can be supplied to this method:
+Providing a `Consumer` function to `onClose` allows configuration of how a transaction is handled when `Transaction.close()` is called.  `Transaction.CLOSE_BEHAVIOR` has several pre-defined options that can be supplied to this method:
 
 * `COMMIT` - automatically commit an open transaction
 * `ROLLBACK` - automatically rollback an open transaction

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/7e4c80dd/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 7d6c7c6..5736be8 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
@@ -79,7 +79,7 @@ public class TransactionTest extends AbstractGremlinTest {
             g.tx().open();
 
         try {
-            graph.close();
+            graph.tx().close();
             fail("An exception should be thrown when close behavior is manual and the graph is close with an open transaction");
         } catch (Exception ex) {
             validateException(Transaction.Exceptions.openTransactionsOnClose(), ex);
@@ -357,13 +357,17 @@ public class TransactionTest extends AbstractGremlinTest {
     @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
     @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
     @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_PERSISTENCE)
-    public void shouldCommitOnShutdownByDefault() throws Exception {
-        final Vertex v1 = graph.addVertex("name", "marko");
-        final Object oid = v1.id();
-        graph.close();
+    public void shouldCommitOnCloseByDefault() throws Exception {
+        final AtomicReference<Object> oid = new AtomicReference<>();
+        final Thread t = new Thread(() -> {
+            final Vertex v1 = graph.addVertex("name", "marko");
+            oid.set(v1.id());
+            graph.tx().close();
+        });
+        t.start();
+        t.join();
 
-        graph = graphProvider.openTestGraph(config);
-        final Vertex v2 = graph.vertices(oid).next();
+        final Vertex v2 = graph.vertices(oid.get()).next();
         assertEquals("marko", v2.<String>value("name"));
     }
 
@@ -371,23 +375,27 @@ public class TransactionTest extends AbstractGremlinTest {
     @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
     @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
     @FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_PERSISTENCE)
-    public void shouldRollbackOnShutdownWhenConfigured() throws Exception {
-        final Vertex v2 = graph.addVertex("name", "stephen");
-        graph.tx().commit();
-
-        final Vertex v1 = graph.addVertex("name", "marko");
-        final Object oid = v1.id();
-        g.tx().onClose(Transaction.CLOSE_BEHAVIOR.ROLLBACK);
-        graph.close();
+    public void shouldRollbackOnCloseWhenConfigured() throws Exception {
+        final AtomicReference<Object> oid = new AtomicReference<>();
+        final AtomicReference<Vertex> vid = new AtomicReference<>();
+        final Thread t = new Thread(() -> {
+            vid.set(graph.addVertex("name", "stephen"));
+            graph.tx().commit();
 
-        graph = graphProvider.openTestGraph(config);
+            final Vertex v1 = graph.addVertex("name", "marko");
+            oid.set(v1.id());
+            g.tx().onClose(Transaction.CLOSE_BEHAVIOR.ROLLBACK);
+            graph.tx().close();
+        });
+        t.start();
+        t.join();
 
         // this was committed
-        assertTrue(graph.vertices(v2.id()).hasNext());
+        assertTrue(graph.vertices(vid.get().id()).hasNext());
 
         try {
             // this was not
-            graph.vertices(oid).next();
+            graph.vertices(oid.get()).next();
             fail("Vertex should not be found as close behavior was set to rollback");
         } catch (Exception ex) {
             validateException(Graph.Exceptions.elementNotFound(Vertex.class, oid), ex);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/7e4c80dd/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
index 3d1c0e0..17b9976 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
@@ -71,10 +71,6 @@ import java.util.stream.Stream;
 @Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT_INTEGRATE)
 @Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT_PERFORMANCE)
 @Graph.OptIn("org.apache.tinkerpop.gremlin.neo4j.NativeNeo4jSuite")
-@Graph.OptOut(
-        test = "org.apache.tinkerpop.gremlin.structure.TransactionTest",
-        method = "shouldRollbackOnShutdownWhenConfigured",
-        reason = "There appears to be a race condition that occurs between Graph.close() and Neo4jGraphAPI.shutdown()")
 public final class Neo4jGraph implements Graph, WrappedGraph<Neo4jGraphAPI> {
 
     public static final Logger LOGGER = LoggerFactory.getLogger(Neo4jGraph.class);