use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class ConfigurationManagementGraphTest method shouldReindexIfPropertyKeyExists.
@Test
public void shouldReindexIfPropertyKeyExists() {
final Map<String, Object> map = new HashMap<>();
map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
final String propertyKeyName = "Created_Using_Template";
final Class dataType = Boolean.class;
JanusGraphManagement management = graph.openManagement();
management.makePropertyKey(propertyKeyName).dataType(dataType).make();
management.commit();
// Instantiate the ConfigurationManagementGraph Singleton
// This is purposefully done after a property key is created to ensure that a REDINDEX is initiated
new ConfigurationManagementGraph(graph);
management = graph.openManagement();
final JanusGraphIndex index = management.getGraphIndex("Created_Using_Template_Index");
final PropertyKey propertyKey = management.getPropertyKey("Created_Using_Template");
assertNotNull(index);
assertNotNull(propertyKey);
assertEquals(ENABLED, index.getIndexStatus(propertyKey));
management.commit();
}
use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class ConfigurationManagementGraphTest method shouldCloseAllTxsIfIndexExists.
@Test
public void shouldCloseAllTxsIfIndexExists() {
final StandardJanusGraph graph = (StandardJanusGraph) JanusGraphFactory.open("inmemory");
// Emulate ConfigurationManagementGraph indices already exists
JanusGraphManagement management = graph.openManagement();
PropertyKey key = management.makePropertyKey("some_property").dataType(String.class).make();
management.buildIndex("Created_Using_Template_Index", Vertex.class).addKey(key).buildCompositeIndex();
management.buildIndex("Template_Index", Vertex.class).addKey(key).buildCompositeIndex();
management.buildIndex("Graph_Name_Index", Vertex.class).addKey(key).buildCompositeIndex();
management.commit();
new ConfigurationManagementGraph(graph);
assertEquals(0, graph.getOpenTransactions().size());
}
use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class EnsureCacheTest method NopTest.
@Test
public void NopTest() {
final Map<String, Object> map = new HashMap<>();
map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
graph.traversal().addV().iterate();
}
use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class JanusGraphServerTest method testGremlinServerIsCorrectlyLoadedWithExpectedGraphs.
@Test
public void testGremlinServerIsCorrectlyLoadedWithExpectedGraphs() {
final JanusGraphServer server = new JanusGraphServer("src/test/resources/janusgraph-server-with-serializers.yaml");
CompletableFuture<Void> start = server.start();
assertFalse(start.isCompletedExceptionally());
GremlinServer gremlinServer = server.getGremlinServer();
StandardJanusGraph graph = (StandardJanusGraph) gremlinServer.getServerGremlinExecutor().getGraphManager().getGraph("graph");
assertNotNull(graph);
CompletableFuture<Void> stop = server.stop();
CompletableFuture.allOf(start, stop).join();
}
use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class JanusGraphTest method testIndexUpdateSyncWithMultipleInstances.
@Tag(TestCategory.BRITTLE_TESTS)
@Test
public void testIndexUpdateSyncWithMultipleInstances() throws InterruptedException {
clopen(option(LOG_SEND_DELAY, MANAGEMENT_LOG), Duration.ofMillis(0), option(KCVSLog.LOG_READ_LAG_TIME, MANAGEMENT_LOG), Duration.ofMillis(50), option(LOG_READ_INTERVAL, MANAGEMENT_LOG), Duration.ofMillis(250));
StandardJanusGraph graph2 = (StandardJanusGraph) JanusGraphFactory.open(config);
JanusGraphTransaction tx2;
mgmt.makePropertyKey("name").dataType(String.class).make();
finishSchema();
tx.addVertex("name", "v1");
newTx();
evaluateQuery(tx.query().has("name", "v1"), ElementCategory.VERTEX, 1, new boolean[] { false, true });
tx2 = graph2.newTransaction();
evaluateQuery(tx2.query().has("name", "v1"), ElementCategory.VERTEX, 1, new boolean[] { false, true });
// Leave tx2 open to delay acknowledgement
mgmt.buildIndex("theIndex", Vertex.class).addKey(mgmt.getPropertyKey("name")).buildCompositeIndex();
mgmt.commit();
JanusGraphTransaction tx3 = graph2.newTransaction();
tx3.addVertex("name", "v2");
tx3.commit();
newTx();
tx.addVertex("name", "v3");
tx.commit();
finishSchema();
try {
mgmt.updateIndex(mgmt.getGraphIndex("theIndex"), SchemaAction.ENABLE_INDEX);
// Open tx2 should not make this possible
fail();
} catch (IllegalArgumentException ignored) {
}
finishSchema();
// Release transaction and wait a little for registration which should make enabling possible
tx2.commit();
mgmt.rollback();
assertTrue(ManagementSystem.awaitGraphIndexStatus(graph, "theIndex").status(SchemaStatus.REGISTERED).timeout(TestGraphConfigs.getSchemaConvergenceTime(ChronoUnit.SECONDS), ChronoUnit.SECONDS).call().getSucceeded());
finishSchema();
mgmt.updateIndex(mgmt.getGraphIndex("theIndex"), SchemaAction.ENABLE_INDEX);
finishSchema();
tx2 = graph2.newTransaction();
// Should be added to index but index not yet enabled
tx2.addVertex("name", "v4");
tx2.commit();
newTx();
evaluateQuery(tx.query().has("name", "v1"), ElementCategory.VERTEX, 0, new boolean[] { true, true }, "theIndex");
evaluateQuery(tx.query().has("name", "v2"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "theIndex");
evaluateQuery(tx.query().has("name", "v3"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "theIndex");
evaluateQuery(tx.query().has("name", "v4"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "theIndex");
tx2 = graph2.newTransaction();
evaluateQuery(tx2.query().has("name", "v1"), ElementCategory.VERTEX, 0, new boolean[] { true, true }, "theIndex");
evaluateQuery(tx2.query().has("name", "v2"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "theIndex");
evaluateQuery(tx2.query().has("name", "v3"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "theIndex");
evaluateQuery(tx2.query().has("name", "v4"), ElementCategory.VERTEX, 1, new boolean[] { true, true }, "theIndex");
tx2.commit();
// Finally test retrieving and closing open instances
Set<String> openInstances = mgmt.getOpenInstances();
assertEquals(2, openInstances.size());
assertTrue(openInstances.contains(graph.getConfiguration().getUniqueGraphId() + "(current)"));
assertTrue(openInstances.contains(graph2.getConfiguration().getUniqueGraphId()));
try {
mgmt.forceCloseInstance(graph.getConfiguration().getUniqueGraphId());
// Cannot close current instance
fail();
} catch (IllegalArgumentException ignored) {
}
mgmt.forceCloseInstance(graph2.getConfiguration().getUniqueGraphId());
graph2.close();
}
Aggregations