Search in sources :

Example 1 with ContextGremlinServer

use of com.baidu.hugegraph.auth.ContextGremlinServer in project incubator-hugegraph by apache.

the class HugeGremlinServer method start.

public static GremlinServer start(String conf, String graphsDir, EventHub hub) throws Exception {
    // Start GremlinServer with inject traversal source
    LOG.info(GremlinServer.getHeader());
    final Settings settings;
    try {
        settings = Settings.read(conf);
    } catch (Exception e) {
        LOG.error("Can't found the configuration file at '{}' or " + "being parsed properly. [{}]", conf, e.getMessage());
        throw e;
    }
    // Scan graph confs and inject into gremlin server context
    E.checkState(settings.graphs != null, "The GremlinServer's settings.graphs is null");
    settings.graphs.putAll(ConfigUtil.scanGraphsDir(graphsDir));
    LOG.info("Configuring Gremlin Server from {}", conf);
    ContextGremlinServer server = new ContextGremlinServer(settings, hub);
    // Inject customized traversal source
    server.injectTraversalSource();
    server.start().exceptionally(t -> {
        LOG.error("Gremlin Server was unable to start and will " + "shutdown now: {}", t.getMessage());
        server.stop().join();
        throw new HugeException("Failed to start Gremlin Server");
    }).join();
    return server;
}
Also used : HugeException(com.baidu.hugegraph.HugeException) ContextGremlinServer(com.baidu.hugegraph.auth.ContextGremlinServer) Log(com.baidu.hugegraph.util.Log) Logger(org.slf4j.Logger) ConfigUtil(com.baidu.hugegraph.util.ConfigUtil) GremlinServer(org.apache.tinkerpop.gremlin.server.GremlinServer) Settings(org.apache.tinkerpop.gremlin.server.Settings) EventHub(com.baidu.hugegraph.event.EventHub) E(com.baidu.hugegraph.util.E) ContextGremlinServer(com.baidu.hugegraph.auth.ContextGremlinServer) HugeException(com.baidu.hugegraph.HugeException) Settings(org.apache.tinkerpop.gremlin.server.Settings) HugeException(com.baidu.hugegraph.HugeException)

Aggregations

HugeException (com.baidu.hugegraph.HugeException)1 ContextGremlinServer (com.baidu.hugegraph.auth.ContextGremlinServer)1 EventHub (com.baidu.hugegraph.event.EventHub)1 ConfigUtil (com.baidu.hugegraph.util.ConfigUtil)1 E (com.baidu.hugegraph.util.E)1 Log (com.baidu.hugegraph.util.Log)1 GremlinServer (org.apache.tinkerpop.gremlin.server.GremlinServer)1 Settings (org.apache.tinkerpop.gremlin.server.Settings)1 Logger (org.slf4j.Logger)1