[ 
https://issues.apache.org/jira/browse/TINKERPOP-3217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18042986#comment-18042986
 ] 

ASF GitHub Bot commented on TINKERPOP-3217:
-------------------------------------------

kenhuuu commented on code in PR #3284:
URL: https://github.com/apache/tinkerpop/pull/3284#discussion_r2591605719


##########
gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinSessionReuseTxIntegrateTest.java:
##########
@@ -0,0 +1,411 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.server;
+
+import org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor;
+import org.apache.tinkerpop.gremlin.util.ExceptionHelper;
+import org.apache.tinkerpop.gremlin.driver.Client;
+import org.apache.tinkerpop.gremlin.driver.Cluster;
+import org.apache.tinkerpop.gremlin.driver.RequestOptions;
+import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection;
+import 
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Transaction;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import static 
org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Integration tests for gremlin-driver and bytecode sessions.
+ *
+ * NOTE: this is effectively a copy of GremlinSessionTxIntegrateTest but the 
expectation is that the gremlin-driver
+ * will be configured in a way that allows connection re-use as the server 
allows it via the "destroySessionPostGraphOp"
+ * setting.
+ */
+public class GremlinSessionReuseTxIntegrateTest extends 
AbstractGremlinServerIntegrationTest {
+
+    /**
+     * Configure specific Gremlin Server settings for specific tests.
+     */
+    @Override
+    public Settings overrideSettings(final Settings settings) {
+        final String nameOfTest = name.getMethodName();
+
+        settings.graphs.put("graph", 
"conf/tinkertransactiongraph-empty.properties");
+
+        // Set this as it is what allows connection re-use on the server side.
+        settings.destroySessionPostGraphOp = true;
+
+        switch (nameOfTest) {
+            case "shouldExecuteBytecodeInSession":
+                break;
+            case "shouldTimeoutTxBytecode":
+                settings.processors.clear();
+
+                // OpProcessor setting
+                final Settings.ProcessorSettings processorSettings = new 
Settings.ProcessorSettings();
+                processorSettings.className = 
SessionOpProcessor.class.getCanonicalName();
+                processorSettings.config = new HashMap<>();
+                
processorSettings.config.put(SessionOpProcessor.CONFIG_SESSION_TIMEOUT, 3000L);
+                settings.processors.add(processorSettings);
+
+                // Unified setting
+                settings.sessionLifetimeTimeout = 3000L;
+                break;
+        }
+
+        return settings;
+    }
+

Review Comment:
   Yes, but this can't be tested right now because the driver automatically 
closes the connection after commit/rollback. This test needs to wait on 
https://github.com/apache/tinkerpop/pull/3258 .





> Add mechanism to close session without closing connection on server
> -------------------------------------------------------------------
>
>                 Key: TINKERPOP-3217
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3217
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: server
>    Affects Versions: 3.8.0, 3.7.5
>            Reporter: Ken Hu
>            Priority: Major
>
> Currently, the Gremlin Server expects a closing of the underlying connection 
> to signal that the corresponding Session tied to the connection should be 
> closed. This is part of the [SessionOpProcessor 
> reference|https://tinkerpop.apache.org/docs/current/dev/provider/#_session_opprocessor].
>  An option should be added to the server so that alternative would be that 
> the Session closes automatically if a successful commit or rollback occurs. 
> This would only affect the Bytecode portion of the SessionOpProcessor that 
> makes the Session act like a Transaction. This would allow connection re-use 
> of connections for sessions and enable better performance for use cases that 
> require large number of transactions to occur.
> This needs to be an option to prevent breaking changes in the server in 3.7.x 
> and 3.8.x. In 4.x and later, this should probably be the default option.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to