Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: gremlin execution timeout #713

Merged
merged 1 commit into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions engine/src/main/java/com/arcadedb/GlobalConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ public Object call(final Object value) {
// COMMAND
COMMAND_TIMEOUT("arcadedb.command.timeout", "Default timeout for commands (in ms)", Long.class, 0),

GREMLIN_COMMAND_TIMEOUT("arcadedb.gremlin.timeout", "Default timeout for gremlin commands (in ms)", Long.class, 8_000),

// USER CODE
POLYGLOT_COMMAND_TIMEOUT("arcadedb.polyglotCommand.timeout", "Default timeout for polyglot commands (in ms)", Long.class, 10_000),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.tinkerpop.gremlin.arcadedb.structure;

import com.arcadedb.GlobalConfiguration;
import com.arcadedb.database.Database;
import com.arcadedb.database.DatabaseFactory;
import com.arcadedb.database.RID;
Expand Down Expand Up @@ -65,6 +66,9 @@
@Graph.OptIn("org.apache.tinkerpop.gremlin.arcadedb.structure.DebugStructureSuite")
public class ArcadeGraph implements Graph, Closeable {

public static final String CONFIG_DIRECTORY = "gremlin.arcadedb.directory";
public static final String CONFIG_EVALUATION_TIMEOUT = "gremlin.evaluationTimeout";

//private final ArcadeVariableFeatures graphVariables = new ArcadeVariableFeatures();
private final ArcadeGraphTransaction transaction;
protected final Database database;
Expand Down Expand Up @@ -105,11 +109,14 @@ protected ArcadeGraph(final Configuration configuration) {
protected ArcadeGraph(final Database database) {
this.database = database;
this.transaction = new ArcadeGraphTransaction(this);

if (database.getConfiguration().hasValue(GlobalConfiguration.GREMLIN_COMMAND_TIMEOUT.getKey()))
// SET CUSTOM TIMEOUT
configuration.setProperty(CONFIG_EVALUATION_TIMEOUT, database.getConfiguration().getValueAsLong(GlobalConfiguration.GREMLIN_COMMAND_TIMEOUT));

init();
}

public static final String CONFIG_DIRECTORY = "gremlin.arcadedb.directory";

@Override
public Features features() {
return features;
Expand Down Expand Up @@ -417,6 +424,11 @@ private void init() {

final GremlinExecutor.Builder builder = GremlinExecutor.build();
builder.globalBindings(globalBindings);

if (configuration.containsKey(CONFIG_EVALUATION_TIMEOUT))
// SET CUSTOM TIMEOUT
builder.evaluationTimeout(configuration.getLong(CONFIG_EVALUATION_TIMEOUT));

gremlinExecutor = builder.create();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.arcadedb.schema.Schema;
import com.arcadedb.utility.FileUtils;
import org.apache.commons.collections.IteratorUtils;
import org.apache.commons.configuration2.BaseConfiguration;
import org.apache.commons.configuration2.Configuration;
import org.apache.tinkerpop.gremlin.arcadedb.structure.ArcadeGraph;
import org.json.JSONObject;
import org.junit.jupiter.api.AfterEach;
Expand All @@ -34,9 +36,10 @@

import java.io.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.*;

import static org.apache.tinkerpop.gremlin.arcadedb.structure.ArcadeGraph.CONFIG_DIRECTORY;
import static org.apache.tinkerpop.gremlin.arcadedb.structure.ArcadeGraph.CONFIG_EVALUATION_TIMEOUT;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
Expand All @@ -49,8 +52,12 @@ public class CypherQueryEngineTest {
private static final String DB_PATH = "./target/testsql";

@Test
public void verifyProjectionWithCollectFunction() throws ExecutionException, InterruptedException {
final ArcadeGraph graph = ArcadeGraph.open(DB_PATH);
public void verifyProjectionWithCollectFunction() {
final Configuration config = new BaseConfiguration();
config.setProperty(CONFIG_DIRECTORY, DB_PATH);
config.setProperty(CONFIG_EVALUATION_TIMEOUT, 180000);

final ArcadeGraph graph = ArcadeGraph.open(config);
try (Database database = graph.getDatabase()) {
database.transaction(() -> {
Schema schema = database.getSchema();
Expand Down