This is an automated email from the ASF dual-hosted git repository.
kenhuuu pushed a commit to branch master-http
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
The following commit(s) were added to refs/heads/master-http by this push:
new f6ece675b5 Temporarily disable remote tx from Java driver CTR
f6ece675b5 is described below
commit f6ece675b564f3e95568903c0c0d09b4049f7bb2
Author: Ken Hu <[email protected]>
AuthorDate: Tue Oct 15 23:16:11 2024 -0700
Temporarily disable remote tx from Java driver CTR
A replacement for sessions in TinkerPop 4 doesn't exist yet so disable
remote tx for now to prevent misuse.
---
.../traversal/dsl/graph/GraphTraversalSource.java | 8 +-
.../driver/remote/DriverRemoteConnection.java | 16 +-
.../driver/remote/DriverRemoteTransaction.java | 260 +++++++++++----------
3 files changed, 140 insertions(+), 144 deletions(-)
diff --git
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
index a95fa5b952..a28089247f 100644
---
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
+++
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
@@ -600,13 +600,7 @@ public class GraphTraversalSource implements
TraversalSource {
if (null == this.connection)
return this.graph.tx();
else {
- // prevent child transactions and let the current Transaction
object be bound to the
- // TraversalSource that spawned it
- final Transaction tx = this.connection.tx();
- if (tx == Transaction.NO_OP && this.connection instanceof
Transaction)
- return (Transaction) this.connection;
- else
- return tx;
+ throw new UnsupportedOperationException("TinkerPop 4 does not yet
support remote transactions");
}
}
diff --git
a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
index b779e57ab3..c89ac5164d 100644
---
a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
+++
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
@@ -248,15 +248,15 @@ public class DriverRemoteConnection implements
RemoteConnection {
}
/**
- * Constructs a new {@link DriverRemoteTransaction}.
+ * Constructs a new {@link DriverRemoteTransaction}. Not yet supported in
TinkerPop 4.
*/
- @Override
- public Transaction tx() {
- // todo: not implemented
- final DriverRemoteConnection session = new DriverRemoteConnection(
- client.getCluster().connect(), remoteTraversalSourceName,
true);
- return new DriverRemoteTransaction(session);
- }
+// @Override
+// public Transaction tx() {
+// // todo: not implemented
+// final DriverRemoteConnection session = new DriverRemoteConnection(
+// client.getCluster().connect(), remoteTraversalSourceName,
true);
+// return new DriverRemoteTransaction(session);
+// }
@Override
public String toString() {
diff --git
a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTransaction.java
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTransaction.java
index 3cc3f8f52f..0ba4c61213 100644
---
a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTransaction.java
+++
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTransaction.java
@@ -33,6 +33,8 @@ import static
org.apache.tinkerpop.gremlin.process.traversal.GraphOp.TX_COMMIT;
import static
org.apache.tinkerpop.gremlin.process.traversal.GraphOp.TX_ROLLBACK;
/**
+ * Not yet supported in TinkerPop 4.
+ *
* A remote {@link Transaction} implementation that is implemented with the
Java driver. It is also a proxy for a
* {@link RemoteConnection} that is bound to a session.
* <p/>
@@ -43,132 +45,132 @@ import static
org.apache.tinkerpop.gremlin.process.traversal.GraphOp.TX_ROLLBACK
* {@link TraversalSource}. A fresh call to {@link #begin()} will be required
to open a fresh session to work with.
* The default behavior of {@link #close()} is to commit the transaction.
*/
-public class DriverRemoteTransaction implements Transaction, RemoteConnection {
-
- private final DriverRemoteConnection sessionBasedConnection;
-
- protected Consumer<Transaction> closeConsumer = CLOSE_BEHAVIOR.COMMIT;
-
- public DriverRemoteTransaction(final DriverRemoteConnection
sessionBasedConnection) {
- this.sessionBasedConnection = sessionBasedConnection;
- }
-
- @Override
- public <T extends TraversalSource> T begin(final Class<T>
traversalSourceClass) {
- if (!isOpen())
- throw new IllegalStateException("Transaction cannot begin as the
session is already closed - create a new Transaction");
-
- try {
- return
traversalSourceClass.getConstructor(RemoteConnection.class).newInstance(this);
- } catch (final Exception e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
-
- /**
- * By virtue of creating a {@code DriverRemoteTransaction}, the
transaction is considered open. There is no need
- * to call this method. Calling it when the transaction is closed will
result in exception.
- */
- @Override
- public void open() {
- // no need to issue a command to open the transaction, the server is
already in such a state if the
- if (!isOpen())
- throw new IllegalStateException("Transaction cannot be opened as
the session is already closed - create a new Transaction");
- }
-
- @Override
- public void commit() {
- closeRemoteTransaction(TX_COMMIT, "Transaction commit for %s failed");
- }
-
- @Override
- public void rollback() {
- closeRemoteTransaction(TX_ROLLBACK, "Transaction rollback for %s
failed");
- }
-
- private void closeRemoteTransaction(final GraphOp closeTxWith, final
String failureMsg) {
- try {
- // kinda weird but we hasNext() the graph command here to ensure
that it runs to completion or
- // else you don't guarantee that we have the returned NO_CONTENT
message in hand before proceeding
- // which could mean the transaction is still in the process of
committing. not sure why iterate()
- // doesn't quite work in this context.
-
this.sessionBasedConnection.submitAsync(closeTxWith.getGremlinLang()).join().hasNext();
- this.sessionBasedConnection.close();
- } catch (Exception ex) {
- throw new RuntimeException(String.format(failureMsg,
sessionBasedConnection.getSessionId()), ex);
- }
- }
-
- @Override
- public boolean isOpen() {
- // for tx purposes closing is a good enough check
- return !sessionBasedConnection.client.isClosing();
- }
-
- /**
- * The default close behavior for this {@link Transaction} implementation
is to {@link #commit()}.
- */
- @Override
- public void close() {
- this.closeConsumer.accept(this);
- }
-
- /**
- * This {@link Transaction} implementation is not auto-managed and
therefore this method is not supported.
- */
- @Override
- public void readWrite() {
- throw new UnsupportedOperationException("Remote transaction behaviors
are not auto-managed - they are always manually controlled");
- }
-
- /**
- * This {@link Transaction} implementation is not auto-managed and
therefore this method is not supported.
- */
- @Override
- public Transaction onReadWrite(final Consumer<Transaction> consumer) {
- throw new UnsupportedOperationException("Remote transaction behaviors
are not configurable - they are always manually controlled");
- }
-
- @Override
- public Transaction onClose(final Consumer<Transaction> consumer) {
- this.closeConsumer = consumer;
- return this;
- }
-
- /**
- * There is no support for remote transaction listeners.
- */
- @Override
- public void addTransactionListener(final Consumer<Status> listener) {
- throw new UnsupportedOperationException("Remote transactions cannot
have listeners attached");
- }
-
- /**
- * There is no support for remote transaction listeners.
- */
- @Override
- public void removeTransactionListener(final Consumer<Status> listener) {
- throw new UnsupportedOperationException("Remote transactions cannot
have listeners attached");
- }
-
- /**
- * There is no support for remote transaction listeners.
- */
- @Override
- public void clearTransactionListeners() {
- throw new UnsupportedOperationException("Remote transactions cannot
have listeners attached");
- }
-
- /**
- * It is not possible to have child transactions, therefore this method
always returns {@link Transaction#NO_OP}.
- */
- @Override
- public Transaction tx() {
- return Transaction.NO_OP;
- }
-
- @Override
- public <E> CompletableFuture<RemoteTraversal<?, E>> submitAsync(final
GremlinLang gremlinLang) throws RemoteConnectionException {
- return sessionBasedConnection.submitAsync(gremlinLang);
- }
-}
+//public class DriverRemoteTransaction implements Transaction,
RemoteConnection {
+//
+// private final DriverRemoteConnection sessionBasedConnection;
+//
+// protected Consumer<Transaction> closeConsumer = CLOSE_BEHAVIOR.COMMIT;
+//
+// public DriverRemoteTransaction(final DriverRemoteConnection
sessionBasedConnection) {
+// this.sessionBasedConnection = sessionBasedConnection;
+// }
+//
+// @Override
+// public <T extends TraversalSource> T begin(final Class<T>
traversalSourceClass) {
+// if (!isOpen())
+// throw new IllegalStateException("Transaction cannot begin as the
session is already closed - create a new Transaction");
+//
+// try {
+// return
traversalSourceClass.getConstructor(RemoteConnection.class).newInstance(this);
+// } catch (final Exception e) {
+// throw new IllegalStateException(e.getMessage(), e);
+// }
+// }
+//
+// /**
+// * By virtue of creating a {@code DriverRemoteTransaction}, the
transaction is considered open. There is no need
+// * to call this method. Calling it when the transaction is closed will
result in exception.
+// */
+// @Override
+// public void open() {
+// // no need to issue a command to open the transaction, the server is
already in such a state if the
+// if (!isOpen())
+// throw new IllegalStateException("Transaction cannot be opened as
the session is already closed - create a new Transaction");
+// }
+//
+// @Override
+// public void commit() {
+// closeRemoteTransaction(TX_COMMIT, "Transaction commit for %s
failed");
+// }
+//
+// @Override
+// public void rollback() {
+// closeRemoteTransaction(TX_ROLLBACK, "Transaction rollback for %s
failed");
+// }
+//
+// private void closeRemoteTransaction(final GraphOp closeTxWith, final
String failureMsg) {
+// try {
+// // kinda weird but we hasNext() the graph command here to ensure
that it runs to completion or
+// // else you don't guarantee that we have the returned NO_CONTENT
message in hand before proceeding
+// // which could mean the transaction is still in the process of
committing. not sure why iterate()
+// // doesn't quite work in this context.
+//
this.sessionBasedConnection.submitAsync(closeTxWith.getGremlinLang()).join().hasNext();
+// this.sessionBasedConnection.close();
+// } catch (Exception ex) {
+// throw new RuntimeException(String.format(failureMsg,
sessionBasedConnection.getSessionId()), ex);
+// }
+// }
+//
+// @Override
+// public boolean isOpen() {
+// // for tx purposes closing is a good enough check
+// return !sessionBasedConnection.client.isClosing();
+// }
+//
+// /**
+// * The default close behavior for this {@link Transaction}
implementation is to {@link #commit()}.
+// */
+// @Override
+// public void close() {
+// this.closeConsumer.accept(this);
+// }
+//
+// /**
+// * This {@link Transaction} implementation is not auto-managed and
therefore this method is not supported.
+// */
+// @Override
+// public void readWrite() {
+// throw new UnsupportedOperationException("Remote transaction
behaviors are not auto-managed - they are always manually controlled");
+// }
+//
+// /**
+// * This {@link Transaction} implementation is not auto-managed and
therefore this method is not supported.
+// */
+// @Override
+// public Transaction onReadWrite(final Consumer<Transaction> consumer) {
+// throw new UnsupportedOperationException("Remote transaction
behaviors are not configurable - they are always manually controlled");
+// }
+//
+// @Override
+// public Transaction onClose(final Consumer<Transaction> consumer) {
+// this.closeConsumer = consumer;
+// return this;
+// }
+//
+// /**
+// * There is no support for remote transaction listeners.
+// */
+// @Override
+// public void addTransactionListener(final Consumer<Status> listener) {
+// throw new UnsupportedOperationException("Remote transactions cannot
have listeners attached");
+// }
+//
+// /**
+// * There is no support for remote transaction listeners.
+// */
+// @Override
+// public void removeTransactionListener(final Consumer<Status> listener) {
+// throw new UnsupportedOperationException("Remote transactions cannot
have listeners attached");
+// }
+//
+// /**
+// * There is no support for remote transaction listeners.
+// */
+// @Override
+// public void clearTransactionListeners() {
+// throw new UnsupportedOperationException("Remote transactions cannot
have listeners attached");
+// }
+//
+// /**
+// * It is not possible to have child transactions, therefore this method
always returns {@link Transaction#NO_OP}.
+// */
+// @Override
+// public Transaction tx() {
+// return Transaction.NO_OP;
+// }
+//
+// @Override
+// public <E> CompletableFuture<RemoteTraversal<?, E>> submitAsync(final
GremlinLang gremlinLang) throws RemoteConnectionException {
+// return sessionBasedConnection.submitAsync(gremlinLang);
+// }
+//}