use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class GraphDatabaseConfigurationInstanceExecutorServiceTest method shouldCreateCustomBackendExecutorServiceWithoutExecutorServiceConfigurationConstructor.
@Test
public void shouldCreateCustomBackendExecutorServiceWithoutExecutorServiceConfigurationConstructor() {
final Map<String, Object> map = getStorageConfiguration();
map.put(UNIQUE_INSTANCE_ID_HOSTNAME.toStringWithoutRoot(), true);
map.put(PARALLEL_BACKEND_OPS.toStringWithoutRoot(), true);
map.put(PARALLEL_BACKEND_EXECUTOR_SERVICE_CLASS.toStringWithoutRoot(), CustomParameterlessExecutorServiceImplementation.class.getName());
final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
assertDoesNotThrow(() -> {
final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
graph.traversal().V().hasNext();
graph.close();
});
}
use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class GraphDatabaseConfigurationInstanceExecutorServiceTest method shouldCreateCustomBackendExecutorServiceWithoutBothExecutorServiceConfigurationConstructors.
@Test
public void shouldCreateCustomBackendExecutorServiceWithoutBothExecutorServiceConfigurationConstructors() {
final Map<String, Object> map = getStorageConfiguration();
map.put(UNIQUE_INSTANCE_ID_HOSTNAME.toStringWithoutRoot(), true);
map.put(PARALLEL_BACKEND_OPS.toStringWithoutRoot(), true);
map.put(PARALLEL_BACKEND_EXECUTOR_SERVICE_CORE_POOL_SIZE.toStringWithoutRoot(), 15);
map.put(PARALLEL_BACKEND_EXECUTOR_SERVICE_CLASS.toStringWithoutRoot(), CustomExecutorServiceWithBothConstructorsImplementation.class.getName());
final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
assertDoesNotThrow(() -> {
final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
graph.traversal().V().hasNext();
graph.close();
});
}
use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class JanusGraphTest method testIndexShouldRegisterWhenWeRemoveAnInstance.
@Tag(TestCategory.BRITTLE_TESTS)
@Test
public void testIndexShouldRegisterWhenWeRemoveAnInstance() 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();
assertThrows(IllegalArgumentException.class, () -> mgmt.updateIndex(mgmt.getGraphIndex("theIndex"), SchemaAction.ENABLE_INDEX));
finishSchema();
// close second graph instance, so index can move to REGISTERED
Set<String> openInstances = mgmt.getOpenInstances();
assertEquals(2, openInstances.size());
assertTrue(openInstances.contains(graph.getConfiguration().getUniqueGraphId() + "(current)"));
assertTrue(openInstances.contains(graph2.getConfiguration().getUniqueGraphId()));
assertThrows(IllegalArgumentException.class, () -> mgmt.forceCloseInstance(graph.getConfiguration().getUniqueGraphId()));
mgmt.forceCloseInstance(graph2.getConfiguration().getUniqueGraphId());
mgmt.commit();
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();
}
use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class ConfiguredGraphFactoryTest method shouldCreateTwoGraphsUsingSameTemplateConfiguration.
@Test
public void shouldCreateTwoGraphsUsingSameTemplateConfiguration() throws Exception {
try {
final Map<String, Object> map = new HashMap<>();
map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
ConfiguredGraphFactory.createTemplateConfiguration(new MapConfiguration(map));
final StandardJanusGraph graph1 = (StandardJanusGraph) ConfiguredGraphFactory.create("graph1");
final StandardJanusGraph graph2 = (StandardJanusGraph) ConfiguredGraphFactory.create("graph2");
assertNotNull(graph1);
assertNotNull(graph2);
assertEquals("graph1", graph1.getConfiguration().getConfiguration().get(GRAPH_NAME));
assertEquals("graph2", graph2.getConfiguration().getConfiguration().get(GRAPH_NAME));
} finally {
ConfiguredGraphFactory.removeConfiguration("graph1");
ConfiguredGraphFactory.removeConfiguration("graph2");
ConfiguredGraphFactory.close("graph1");
ConfiguredGraphFactory.close("graph2");
}
}
use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class ConfiguredGraphFactoryTest method updateConfigurationShouldRemoveGraphFromCache.
@Test
public void updateConfigurationShouldRemoveGraphFromCache() throws Exception {
try {
final Map<String, Object> map = new HashMap<>();
map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
map.put(GRAPH_NAME.toStringWithoutRoot(), "graph1");
ConfiguredGraphFactory.createConfiguration(new MapConfiguration(map));
final StandardJanusGraph graph = (StandardJanusGraph) ConfiguredGraphFactory.open("graph1");
assertNotNull(graph);
map.put(STORAGE_BACKEND.toStringWithoutRoot(), "bogusBackend");
ConfiguredGraphFactory.updateConfiguration("graph1", new MapConfiguration(map));
assertNull(gm.getGraph("graph1"));
// we should throw an error since the config has been updated and we are attempting
// to open a bogus backend
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(equalTo("Could not find implementation class: bogusBackend"));
final StandardJanusGraph graph2 = (StandardJanusGraph) ConfiguredGraphFactory.open("graph1");
} finally {
ConfiguredGraphFactory.removeConfiguration("graph1");
ConfiguredGraphFactory.close("graph1");
}
}
Aggregations