Search in sources :

Example 16 with JanusGraph

use of org.janusgraph.core.JanusGraph in project grakn by graknlabs.

the class TxFactoryJanus method newJanusGraph.

private synchronized JanusGraph newJanusGraph(boolean batchLoading) {
    JanusGraph JanusGraph = configureGraph(batchLoading);
    buildJanusIndexes(JanusGraph);
    JanusGraph.tx().onClose(Transaction.CLOSE_BEHAVIOR.ROLLBACK);
    if (!strategiesApplied.getAndSet(true)) {
        TraversalStrategies strategies = TraversalStrategies.GlobalCache.getStrategies(StandardJanusGraph.class);
        strategies = strategies.clone().addStrategies(new JanusPreviousPropertyStepStrategy());
        // TODO: find out why Tinkerpop added these strategies. They result in many NoOpBarrier steps which slowed down our queries so we had to remove them.
        strategies.removeStrategies(PathRetractionStrategy.class, LazyBarrierStrategy.class);
        TraversalStrategies.GlobalCache.registerStrategies(StandardJanusGraph.class, strategies);
        TraversalStrategies.GlobalCache.registerStrategies(StandardJanusGraphTx.class, strategies);
    }
    return JanusGraph;
}
Also used : TraversalStrategies(org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) JanusGraph(org.janusgraph.core.JanusGraph)

Example 17 with JanusGraph

use of org.janusgraph.core.JanusGraph in project grakn by graknlabs.

the class TxFactoryJanusTest method getGraph.

private static JanusGraph getGraph() {
    Keyspace name = Keyspace.of("hehe" + UUID.randomUUID().toString().replaceAll("-", ""));
    when(session.keyspace()).thenReturn(name);
    janusGraphFactory = new TxFactoryJanus(session);
    Graph graph = janusGraphFactory.open(GraknTxType.WRITE).getTinkerPopGraph();
    assertThat(graph, instanceOf(JanusGraph.class));
    return (JanusGraph) graph;
}
Also used : Graph(org.apache.tinkerpop.gremlin.structure.Graph) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) JanusGraph(org.janusgraph.core.JanusGraph) Keyspace(ai.grakn.Keyspace) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) JanusGraph(org.janusgraph.core.JanusGraph)

Example 18 with JanusGraph

use of org.janusgraph.core.JanusGraph in project janusgraph by JanusGraph.

the class GraphOfTheGodsFactory method create.

public static JanusGraph create(final String directory) {
    JanusGraphFactory.Builder config = JanusGraphFactory.build();
    config.set("storage.backend", "berkeleyje");
    config.set("storage.directory", directory);
    config.set("index." + INDEX_NAME + ".backend", "elasticsearch");
    JanusGraph graph = config.open();
    GraphOfTheGodsFactory.load(graph);
    return graph;
}
Also used : StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) JanusGraph(org.janusgraph.core.JanusGraph) JanusGraphFactory(org.janusgraph.core.JanusGraphFactory)

Example 19 with JanusGraph

use of org.janusgraph.core.JanusGraph in project janusgraph by JanusGraph.

the class BerkeleyElasticsearchTest method testGraphOfTheGodsFactoryCreate.

/**
 * Test {@link org.janusgraph.example.GraphOfTheGodsFactory#create(String)}.
 */
@Test
public void testGraphOfTheGodsFactoryCreate() {
    File bdbtmp = new File("target/gotgfactory");
    IOUtils.deleteDirectory(bdbtmp, true);
    JanusGraph gotg = GraphOfTheGodsFactory.create(bdbtmp.getPath());
    JanusGraphIndexTest.assertGraphOfTheGods(gotg);
    gotg.close();
}
Also used : JanusGraph(org.janusgraph.core.JanusGraph) File(java.io.File) JanusGraphIndexTest(org.janusgraph.graphdb.JanusGraphIndexTest) Test(org.junit.Test)

Example 20 with JanusGraph

use of org.janusgraph.core.JanusGraph in project janusgraph by JanusGraph.

the class HadoopVertexScanMapper method setup.

@Override
protected void setup(Context context) throws IOException, InterruptedException {
    /* Don't call super implementation super.setup(context); */
    org.apache.hadoop.conf.Configuration hadoopConf = DEFAULT_COMPAT.getContextConfiguration(context);
    ModifiableHadoopConfiguration scanConf = ModifiableHadoopConfiguration.of(JanusGraphHadoopConfiguration.MAPRED_NS, hadoopConf);
    VertexScanJob vertexScan = getVertexScanJob(scanConf);
    ModifiableConfiguration graphConf = getJanusGraphConfiguration(context);
    JanusGraph graph = JanusGraphFactory.open(graphConf);
    job = VertexJobConverter.convert(graph, vertexScan);
    metrics = new HadoopContextScanMetrics(context);
    finishSetup(scanConf, graphConf);
}
Also used : JanusGraph(org.janusgraph.core.JanusGraph) VertexScanJob(org.janusgraph.graphdb.olap.VertexScanJob) ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration) ModifiableHadoopConfiguration(org.janusgraph.hadoop.config.ModifiableHadoopConfiguration)

Aggregations

JanusGraph (org.janusgraph.core.JanusGraph)38 Test (org.junit.Test)23 HashMap (java.util.HashMap)20 CredentialGraph (org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraph)20 ManagementSystem (org.janusgraph.graphdb.database.management.ManagementSystem)15 Transaction (org.apache.tinkerpop.gremlin.structure.Transaction)14 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)12 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)9 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)7 SimpleAuthenticator (org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator)5 PropertyKey (org.janusgraph.core.PropertyKey)5 JanusGraphIndex (org.janusgraph.core.schema.JanusGraphIndex)5 JanusGraphVertex (org.janusgraph.core.JanusGraphVertex)4 PropertyKeyMaker (org.janusgraph.core.schema.PropertyKeyMaker)3 LongHashSet (com.carrotsearch.hppc.LongHashSet)2 LongSet (com.carrotsearch.hppc.LongSet)2 ArrayList (java.util.ArrayList)2 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)2 AuthenticationException (org.apache.tinkerpop.gremlin.server.auth.AuthenticationException)2 Graph (org.apache.tinkerpop.gremlin.structure.Graph)2