use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.
the class CQLConfigTest method testGraphConfigUsedByThreadBoundTx.
@Test
public void testGraphConfigUsedByThreadBoundTx() {
WriteConfiguration wc = getConfiguration();
wc.set(ConfigElement.getPath(READ_CONSISTENCY), "ALL");
wc.set(ConfigElement.getPath(WRITE_CONSISTENCY), "LOCAL_QUORUM");
graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
StandardJanusGraphTx tx = (StandardJanusGraphTx) graph.getCurrentThreadTx();
assertEquals("ALL", tx.getTxHandle().getBaseTransactionConfig().getCustomOptions().get(READ_CONSISTENCY));
assertEquals("LOCAL_QUORUM", tx.getTxHandle().getBaseTransactionConfig().getCustomOptions().get(WRITE_CONSISTENCY));
}
use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.
the class CQLConfigTest method shouldComposeProgrammaticConfigurationWithStringConfigurationAndFailDueToUnnecessaryKeyspaceConfigAdded.
@Test
public void shouldComposeProgrammaticConfigurationWithStringConfigurationAndFailDueToUnnecessaryKeyspaceConfigAdded() {
WriteConfiguration wc = getConfiguration();
wc.set(ConfigElement.getPath(BASE_PROGRAMMATIC_CONFIGURATION_ENABLED), true);
wc.set(ConfigElement.getPath(STRING_CONFIGURATION), DATASTAX_JAVA_DRIVER_STRING_KEYSPACE_ONLY_CONFIGURATION_PATTERN);
assertThrows(IllegalArgumentException.class, () -> JanusGraphFactory.open(wc));
}
use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.
the class CQLConfigTest method shouldCreateCQLSessionWithMultipleComposedConfigurations.
@Test
public void shouldCreateCQLSessionWithMultipleComposedConfigurations() throws IOException {
WriteConfiguration wc = getConfiguration();
String dataStaxConfiguration = prepareDataStaxConfiguration(wc);
File tempFile = File.createTempFile("datastaxTempExample", ".conf");
try {
tempFile.deleteOnExit();
FileUtils.writeStringToFile(tempFile, dataStaxConfiguration, Charset.defaultCharset(), false);
wc.set(ConfigElement.getPath(BASE_PROGRAMMATIC_CONFIGURATION_ENABLED), true);
wc.set(ConfigElement.getPath(URL_CONFIGURATION), new URL("file", "", tempFile.getAbsolutePath()).toString());
wc.set(ConfigElement.getPath(FILE_CONFIGURATION), tempFile.getAbsolutePath());
wc.set(ConfigElement.getPath(STRING_CONFIGURATION), dataStaxConfiguration);
graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
assertDoesNotThrow(() -> {
graph.traversal().V().hasNext();
graph.tx().rollback();
});
} finally {
tempFile.delete();
}
}
use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.
the class CQLConfigTest method testStorageVersionSet.
@Test
public void testStorageVersionSet() {
WriteConfiguration wc = getConfiguration();
assertNull(wc.get(ConfigElement.getPath(INITIAL_STORAGE_VERSION), INITIAL_STORAGE_VERSION.getDatatype()));
wc.set(ConfigElement.getPath(INITIAL_STORAGE_VERSION), JanusGraphConstants.STORAGE_VERSION);
graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
JanusGraphManagement mgmt = graph.openManagement();
assertEquals(JanusGraphConstants.STORAGE_VERSION, (mgmt.get("graph.storage-version")));
mgmt.rollback();
}
use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.
the class JanusGraphFactory method open.
/**
* Opens a {@link JanusGraph} database configured according to the provided configuration.
* This method shouldn't be called by end users; it is used by internal server processes to
* open graphs defined at server start that do not include the graphname property.
*
* @param configuration Configuration for the graph database
* @param backupName Backup name for graph
* @return JanusGraph graph database
*/
public static JanusGraph open(ReadConfiguration configuration, String backupName) {
final ModifiableConfiguration config = new ModifiableConfiguration(ROOT_NS, (WriteConfiguration) configuration, BasicConfiguration.Restriction.NONE);
final String graphName = config.has(GRAPH_NAME) ? config.get(GRAPH_NAME) : backupName;
final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
if (null != graphName) {
Preconditions.checkNotNull(jgm, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG);
return (JanusGraph) jgm.openGraph(graphName, gName -> new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(configuration)));
} else {
if (jgm != null) {
log.warn("You should supply \"graph.graphname\" in your .properties file configuration if you are opening " + "a graph that has not already been opened at server start, i.e. it was " + "defined in your YAML file. This will ensure the graph is tracked by the JanusGraphManager, " + "which will enable autocommit and rollback functionality upon all gremlin script executions. " + "Note that JanusGraphFactory#open(String === shortcut notation) does not support consuming the property " + "\"graph.graphname\" so these graphs should be accessed dynamically by supplying a .properties file here " + "or by using the ConfiguredGraphFactory.");
}
return new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(configuration));
}
}
Aggregations