Search in sources :

Example 1 with GraphManager

use of org.apache.tinkerpop.gremlin.server.GraphManager in project janusgraph by JanusGraph.

the class JanusGraphWebSocketChannelizer method init.

@Override
public void init(final ServerGremlinExecutor serverGremlinExecutor) {
    this.serverGremlinExecutor = serverGremlinExecutor;
    super.init(serverGremlinExecutor);
    final GraphManager graphManager = serverGremlinExecutor.getGraphManager();
    Preconditions.checkArgument(graphManager instanceof JanusGraphManager, "Must use JanusGraphManager with a JanusGraphChannelizer.");
    ((JanusGraphManager) graphManager).configureGremlinExecutor(serverGremlinExecutor.getGremlinExecutor());
}
Also used : GraphManager(org.apache.tinkerpop.gremlin.server.GraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager)

Example 2 with GraphManager

use of org.apache.tinkerpop.gremlin.server.GraphManager in project cypher-for-gremlin by opencypher.

the class CypherOpProcessor method traversal.

private GraphTraversalSource traversal(Context context) throws OpProcessorException {
    RequestMessage msg = context.getRequestMessage();
    GraphManager graphManager = context.getGraphManager();
    Optional<Map<String, String>> aliasesOptional = msg.optionalArgs(Tokens.ARGS_ALIASES);
    String gAlias = aliasesOptional.map(aliases -> aliases.get(Tokens.VAL_TRAVERSAL_SOURCE_ALIAS)).orElse(null);
    if (gAlias == null) {
        return graphManager.getGraphNames().stream().findFirst().map(graphManager::getGraph).map(Graph::traversal).orElseThrow(() -> opProcessorException(msg, "No graphs found on the server"));
    }
    Graph graph = graphManager.getGraph(gAlias);
    if (graph != null) {
        return graph.traversal();
    }
    TraversalSource traversalSource = graphManager.getTraversalSource(gAlias);
    if (traversalSource instanceof GraphTraversalSource) {
        return (GraphTraversalSource) traversalSource;
    }
    throw opProcessorException(msg, "Traversable alias '" + gAlias + "' not found");
}
Also used : Optional.empty(java.util.Optional.empty) OpProcessor(org.apache.tinkerpop.gremlin.server.OpProcessor) EXPLAIN(org.opencypher.gremlin.translation.StatementOption.EXPLAIN) ThrowingConsumer(org.apache.tinkerpop.gremlin.util.function.ThrowingConsumer) Graph(org.apache.tinkerpop.gremlin.structure.Graph) Tokens(org.apache.tinkerpop.gremlin.driver.Tokens) Translator(org.opencypher.gremlin.translation.translator.Translator) HashMap(java.util.HashMap) RequestMessage(org.apache.tinkerpop.gremlin.driver.message.RequestMessage) Collections.singletonList(java.util.Collections.singletonList) AbstractEvalOpProcessor(org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor) LinkedHashMap(java.util.LinkedHashMap) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ResponseMessage(org.apache.tinkerpop.gremlin.driver.message.ResponseMessage) GraphManager(org.apache.tinkerpop.gremlin.server.GraphManager) Map(java.util.Map) SERVER_ERROR(org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode.SERVER_ERROR) GroovyPredicate(org.opencypher.gremlin.translation.groovy.GroovyPredicate) OpProcessorException(org.apache.tinkerpop.gremlin.server.op.OpProcessorException) P(org.apache.tinkerpop.gremlin.process.traversal.P) DefaultGraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal) ReturnNormalizer(org.opencypher.gremlin.traversal.ReturnNormalizer) Logger(org.slf4j.Logger) CYPHER_OP_PROCESSOR_NAME(org.opencypher.gremlin.ClientServerCommunication.CYPHER_OP_PROCESSOR_NAME) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) Traversal(org.apache.tinkerpop.gremlin.process.traversal.Traversal) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Optional(java.util.Optional) ResponseStatusCode(org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode) TraversalSource(org.apache.tinkerpop.gremlin.process.traversal.TraversalSource) Context(org.apache.tinkerpop.gremlin.server.Context) CypherAstWrapper(org.opencypher.gremlin.translation.CypherAstWrapper) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) GraphManager(org.apache.tinkerpop.gremlin.server.GraphManager) Graph(org.apache.tinkerpop.gremlin.structure.Graph) TraversalSource(org.apache.tinkerpop.gremlin.process.traversal.TraversalSource) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) RequestMessage(org.apache.tinkerpop.gremlin.driver.message.RequestMessage) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 3 with GraphManager

use of org.apache.tinkerpop.gremlin.server.GraphManager in project janusgraph by JanusGraph.

the class JanusGraphServer method configure.

private static void configure(ServerGremlinExecutor serverGremlinExecutor) {
    GraphManager graphManager = serverGremlinExecutor.getGraphManager();
    if (!(graphManager instanceof JanusGraphManager)) {
        return;
    }
    ((JanusGraphManager) graphManager).configureGremlinExecutor(serverGremlinExecutor.getGremlinExecutor());
}
Also used : GraphManager(org.apache.tinkerpop.gremlin.server.GraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager)

Example 4 with GraphManager

use of org.apache.tinkerpop.gremlin.server.GraphManager in project janusgraph by JanusGraph.

the class JanusGraphNioChannelizer method init.

@Override
public void init(final ServerGremlinExecutor serverGremlinExecutor) {
    this.serverGremlinExecutor = serverGremlinExecutor;
    super.init(serverGremlinExecutor);
    final GraphManager graphManager = serverGremlinExecutor.getGraphManager();
    Preconditions.checkArgument(graphManager instanceof JanusGraphManager, "Must use JanusGraphManager with a JanusGraphChannelizer.");
    ((JanusGraphManager) graphManager).configureGremlinExecutor(serverGremlinExecutor.getGremlinExecutor());
}
Also used : GraphManager(org.apache.tinkerpop.gremlin.server.GraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager)

Example 5 with GraphManager

use of org.apache.tinkerpop.gremlin.server.GraphManager in project janusgraph by JanusGraph.

the class JanusGraphWsAndHttpChannelizer method init.

@Override
public void init(final ServerGremlinExecutor serverGremlinExecutor) {
    this.serverGremlinExecutor = serverGremlinExecutor;
    super.init(serverGremlinExecutor);
    final GraphManager graphManager = serverGremlinExecutor.getGraphManager();
    Preconditions.checkArgument(graphManager instanceof JanusGraphManager, "Must use JanusGraphManager with a JanusGraphChannelizer.");
    ((JanusGraphManager) graphManager).configureGremlinExecutor(serverGremlinExecutor.getGremlinExecutor());
}
Also used : GraphManager(org.apache.tinkerpop.gremlin.server.GraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager) JanusGraphManager(org.janusgraph.graphdb.management.JanusGraphManager)

Aggregations

GraphManager (org.apache.tinkerpop.gremlin.server.GraphManager)7 JanusGraphManager (org.janusgraph.graphdb.management.JanusGraphManager)6 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 IOException (java.io.IOException)1 Collections.singletonList (java.util.Collections.singletonList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Optional.empty (java.util.Optional.empty)1 Tokens (org.apache.tinkerpop.gremlin.driver.Tokens)1 RequestMessage (org.apache.tinkerpop.gremlin.driver.message.RequestMessage)1 ResponseMessage (org.apache.tinkerpop.gremlin.driver.message.ResponseMessage)1 ResponseStatusCode (org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode)1 SERVER_ERROR (org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode.SERVER_ERROR)1 P (org.apache.tinkerpop.gremlin.process.traversal.P)1 Traversal (org.apache.tinkerpop.gremlin.process.traversal.Traversal)1 TraversalSource (org.apache.tinkerpop.gremlin.process.traversal.TraversalSource)1 DefaultGraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal)1 GraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal)1