Skip to content
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
7 changes: 1 addition & 6 deletions gremlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<artifactId>arcadedb-gremlin</artifactId>
<packaging>jar</packaging>

<properties>
<gremlin.version>3.5.1</gremlin.version>
<junit5.version>5.8.1</junit5.version>
</properties>

<dependencies>
<dependency>
<groupId>com.arcadedb</groupId>
Expand Down Expand Up @@ -73,7 +68,7 @@
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit5.version}</version>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<exclude.tests></exclude.tests>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<gremlin.version>3.5.1</gremlin.version>
<docker.plugin.version>1.2.2</docker.plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<jacoco-maven-plugin.version>0.8.7</jacoco-maven-plugin.version>
Expand Down
5 changes: 5 additions & 0 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-server</artifactId>
<version>${gremlin.version}</version>
</dependency>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright © 2021-present Arcade Data Ltd (info@arcadedata.com)
*
* Licensed 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 com.arcadedb.server.gremlin;

import com.arcadedb.ContextConfiguration;
import com.arcadedb.log.LogManager;
import com.arcadedb.server.ArcadeDBServer;
import com.arcadedb.server.ServerException;
import com.arcadedb.server.ServerPlugin;
import com.arcadedb.server.http.HttpServer;
import io.undertow.server.handlers.PathHandler;
import org.apache.tinkerpop.gremlin.server.GremlinServer;
import org.apache.tinkerpop.gremlin.server.Settings;

import java.io.*;
import java.lang.reflect.*;
import java.util.logging.*;

public class GremlinServerPlugin implements ServerPlugin {
private static final String CONFIG_GREMLIN_SERVER_YAML = "/config/gremlin-server.yaml";
private ArcadeDBServer server;
private ContextConfiguration configuration;
private GremlinServer gremlinServer;

@Override
public void configure(final ArcadeDBServer arcadeDBServer, final ContextConfiguration configuration) {
this.server = arcadeDBServer;
this.configuration = configuration;
}

@Override
public void startService() {
Settings settings = null;
final File confFile = new File(server.getRootPath() + CONFIG_GREMLIN_SERVER_YAML);
if (confFile.exists()) {
try (FileInputStream is = new FileInputStream(confFile.getAbsolutePath())) {
settings = Settings.read(is);
} catch (Exception e) {
LogManager.instance()
.log(this, Level.INFO, "Error on loading Gremlin Server configuration file '%s'. Using default configuration", null, CONFIG_GREMLIN_SERVER_YAML);
}
} else
LogManager.instance()
.log(this, Level.INFO, "Cannot find Gremlin Server configuration file '%s'. Using default configuration", null, CONFIG_GREMLIN_SERVER_YAML);

if (settings == null)
// DEFAULT CONFIGURATION
settings = new Settings();

for (String key : configuration.getContextKeys()) {
if (key.startsWith("gremlin.")) {
final Object value = configuration.getValue(key, null);
final String gremlinConfigKey = key.substring("gremlin.".length());

try {
final Field field = settings.getClass().getField(gremlinConfigKey);
field.set(settings, value);
} catch (NoSuchFieldException | IllegalAccessException e) {
// IGNORE IT
}
}
}

gremlinServer = new GremlinServer(settings);
try {
gremlinServer.start();
} catch (Exception e) {
throw new ServerException("Error on starting GremlinServer plugin", e);
}
}

@Override
public void stopService() {
if (gremlinServer != null)
gremlinServer.stop();
}

@Override
public void registerAPI(HttpServer httpServer, final PathHandler routes) {
}
}