Search in sources :

Example 46 with JanusGraphManagement

use of org.janusgraph.core.schema.JanusGraphManagement in project atlas by apache.

the class AtlasJanusGraph method getIndexKeys.

private Set<String> getIndexKeys(Class<? extends Element> janusGraphElementClass) {
    JanusGraphManagement mgmt = getGraph().openManagement();
    Iterable<JanusGraphIndex> indices = mgmt.getGraphIndexes(janusGraphElementClass);
    Set<String> result = new HashSet<String>();
    for (JanusGraphIndex index : indices) {
        result.add(index.name());
    }
    mgmt.commit();
    return result;
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) JanusGraphIndex(org.janusgraph.core.schema.JanusGraphIndex) HashSet(java.util.HashSet)

Example 47 with JanusGraphManagement

use of org.janusgraph.core.schema.JanusGraphManagement in project atlas by apache.

the class AtlasJanusGraphDatabase method updateGlobalConfiguration.

private static void updateGlobalConfiguration(Map<String, Object> map) {
    JanusGraph graph = null;
    JanusGraphManagement managementSystem = null;
    try {
        graph = initJanusGraph(getConfiguration());
        managementSystem = graph.openManagement();
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            managementSystem.set(entry.getKey(), entry.getValue());
        }
        LOG.info("Global properties updated!: {}", map);
    } catch (Exception ex) {
        LOG.error("Error updating global configuration: {}", map, ex);
    } finally {
        if (managementSystem != null) {
            managementSystem.commit();
        }
        if (graph != null) {
            graph.close();
        }
    }
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) JanusGraph(org.janusgraph.core.JanusGraph) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) JanusGraphException(org.janusgraph.core.JanusGraphException) AtlasException(org.apache.atlas.AtlasException)

Example 48 with JanusGraphManagement

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

the class JanusGraphIndexTest method testOrForceIndexMixedAndCompositeIndex.

@Test
public void testOrForceIndexMixedAndCompositeIndex() throws Exception {
    JanusGraph customGraph = null;
    try {
        customGraph = this.getForceIndexGraph();
        final JanusGraphManagement management = customGraph.openManagement();
        final PropertyKey nameProperty = management.makePropertyKey("name").dataType(String.class).cardinality(Cardinality.SINGLE).make();
        final PropertyKey ageProperty = management.makePropertyKey("age").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        final PropertyKey lengthProperty = management.makePropertyKey("length").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        management.buildIndex("nameidx", Vertex.class).addKey(nameProperty, getStringMapping()).buildMixedIndex(INDEX);
        management.buildIndex("ageridx", Vertex.class).addKey(ageProperty).buildCompositeIndex();
        management.buildIndex("lengthidx", Vertex.class).addKey(lengthProperty).buildMixedIndex(INDEX);
        management.commit();
        customGraph.tx().commit();
        testOr(customGraph);
    } finally {
        if (customGraph != null) {
            JanusGraphFactory.close(customGraph);
        }
    }
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) JanusGraph(org.janusgraph.core.JanusGraph) PropertyKey(org.janusgraph.core.PropertyKey) RepeatedIfExceptionsTest(io.github.artsok.RepeatedIfExceptionsTest) Test(org.junit.jupiter.api.Test)

Example 49 with JanusGraphManagement

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

the class AbstractJanusGraphProvider method loadGraphData.

@Override
public void loadGraphData(final Graph g, final LoadGraphWith loadGraphWith, final Class testClass, final String testName) {
    if (loadGraphWith != null) {
        this.createIndices((JanusGraph) g, loadGraphWith.value());
    } else {
        if (TransactionTest.class.equals(testClass) && testName.equalsIgnoreCase("shouldExecuteWithCompetingThreads")) {
            JanusGraphManagement management = ((JanusGraph) g).openManagement();
            management.makePropertyKey("blah").dataType(Double.class).make();
            management.makePropertyKey("bloop").dataType(Integer.class).make();
            management.makePropertyKey("test").dataType(Object.class).make();
            management.makeEdgeLabel("friend").make();
            management.commit();
        }
    }
    super.loadGraphData(g, loadGraphWith, testClass, testName);
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) JanusGraph(org.janusgraph.core.JanusGraph) TransactionTest(org.apache.tinkerpop.gremlin.structure.TransactionTest)

Example 50 with JanusGraphManagement

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

the class MgmtOlapJobBenchmark method runReindex.

@Benchmark
public void runReindex(Blackhole blackhole) throws ExecutionException, InterruptedException {
    JanusGraphManagement mgmt = graph.openManagement();
    blackhole.consume(mgmt.updateIndex(mgmt.getGraphIndex("aliasIndex"), SchemaAction.REINDEX).get());
    mgmt.commit();
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Aggregations

JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)92 PropertyKey (org.janusgraph.core.PropertyKey)44 Test (org.junit.jupiter.api.Test)26 JanusGraphIndex (org.janusgraph.core.schema.JanusGraphIndex)24 JanusGraph (org.janusgraph.core.JanusGraph)23 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)20 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)17 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)12 HashMap (java.util.HashMap)9 JanusGraphVertex (org.janusgraph.core.JanusGraphVertex)9 ArrayList (java.util.ArrayList)8 Before (org.junit.Before)8 Test (org.junit.Test)8 JanusGraphDBEngine (org.onap.aai.serialization.engines.JanusGraphDBEngine)8 TransactionalGraphEngine (org.onap.aai.serialization.engines.TransactionalGraphEngine)8 JanusGraphBaseTest (org.janusgraph.graphdb.JanusGraphBaseTest)7 RepeatedIfExceptionsTest (io.github.artsok.RepeatedIfExceptionsTest)6 EdgeLabel (org.janusgraph.core.EdgeLabel)6 Map (java.util.Map)5 JanusGraphException (org.janusgraph.core.JanusGraphException)5