Search in sources :

Example 31 with WriteConfiguration

use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.

the class CQLConfigTest method shouldCreateCQLSessionWithStringConfigurationOnly.

@Test
public void shouldCreateCQLSessionWithStringConfigurationOnly() {
    WriteConfiguration wc = getConfiguration();
    String dataStaxConfiguration = prepareDataStaxConfiguration(wc);
    wc.set(ConfigElement.getPath(BASE_PROGRAMMATIC_CONFIGURATION_ENABLED), false);
    wc.set(ConfigElement.getPath(STRING_CONFIGURATION), dataStaxConfiguration);
    graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
    assertDoesNotThrow(() -> {
        graph.traversal().V().hasNext();
        graph.tx().rollback();
    });
}
Also used : WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 32 with WriteConfiguration

use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.

the class CQLConfigTest method shouldCreateCQLSessionWithResourceAndStringConfigurations.

@Test
public void shouldCreateCQLSessionWithResourceAndStringConfigurations() {
    WriteConfiguration wc = getConfiguration();
    String dataStaxConfiguration = prepareDataStaxContactPointsOnlyConfiguration(wc);
    wc.set(ConfigElement.getPath(BASE_PROGRAMMATIC_CONFIGURATION_ENABLED), false);
    wc.set(ConfigElement.getPath(RESOURCE_CONFIGURATION), "datastaxResourceTestConfigWithoutContactPoints.conf");
    wc.set(ConfigElement.getPath(STRING_CONFIGURATION), dataStaxConfiguration);
    graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
    assertDoesNotThrow(() -> {
        graph.traversal().V().hasNext();
        graph.tx().rollback();
    });
}
Also used : WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 33 with WriteConfiguration

use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.

the class CQLConfigTest method testMetaDataGraphConfig.

@ParameterizedTest
@MethodSource("getMetadataConfigs")
public void testMetaDataGraphConfig(String partitionerName, boolean schemaEnabled, boolean tokenMapEnabled) {
    WriteConfiguration wc = getConfiguration();
    String currentPartitionerName = getCurrentPartitionerName();
    if (partitionerName != null)
        wc.set(ConfigElement.getPath(PARTITIONER_NAME), partitionerName);
    assertNull(wc.get(ConfigElement.getPath(METADATA_SCHEMA_ENABLED), METADATA_SCHEMA_ENABLED.getDatatype()));
    assertNull(wc.get(ConfigElement.getPath(METADATA_TOKEN_MAP_ENABLED), METADATA_TOKEN_MAP_ENABLED.getDatatype()));
    wc.set(ConfigElement.getPath(METADATA_SCHEMA_ENABLED), schemaEnabled);
    wc.set(ConfigElement.getPath(METADATA_TOKEN_MAP_ENABLED), tokenMapEnabled);
    if (// not matching
    tokenMapEnabled && partitionerName != null && !partitionerName.equals(currentPartitionerName) || // not provided and cannot be retrieved
    !tokenMapEnabled && partitionerName == null) {
        assertThrows(IllegalArgumentException.class, () -> JanusGraphFactory.open(wc));
    } else {
        JanusGraphFactory.open(wc);
    }
}
Also used : WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 34 with WriteConfiguration

use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.

the class CQLConfigTest method testCustomConfigUsedByTx.

@Test
public void testCustomConfigUsedByTx() {
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(READ_CONSISTENCY), "ALL");
    wc.set(ConfigElement.getPath(WRITE_CONSISTENCY), "ALL");
    graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
    StandardJanusGraphTx tx = (StandardJanusGraphTx) graph.buildTransaction().customOption(ConfigElement.getPath(READ_CONSISTENCY), "ONE").customOption(ConfigElement.getPath(WRITE_CONSISTENCY), "TWO").start();
    assertEquals("ONE", tx.getTxHandle().getBaseTransactionConfig().getCustomOptions().get(READ_CONSISTENCY));
    assertEquals("TWO", tx.getTxHandle().getBaseTransactionConfig().getCustomOptions().get(WRITE_CONSISTENCY));
    tx.rollback();
}
Also used : StandardJanusGraphTx(org.janusgraph.graphdb.transaction.StandardJanusGraphTx) WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 35 with WriteConfiguration

use of org.janusgraph.diskstorage.configuration.WriteConfiguration in project janusgraph by JanusGraph.

the class CQLConfigTest method shouldGracefullyCloseGraphWhichLostAConnection.

@Test
public void shouldGracefullyCloseGraphWhichLostAConnection() {
    WriteConfiguration wc = getConfiguration();
    wc.set(ConfigElement.getPath(EXECUTOR_SERVICE_MAX_SHUTDOWN_WAIT_TIME), 60000);
    wc.set(ConfigElement.getPath(PARALLEL_BACKEND_EXECUTOR_SERVICE_MAX_SHUTDOWN_WAIT_TIME), 60000);
    wc.set(ConfigElement.getPath(IDS_RENEW_TIMEOUT), 10000);
    wc.set(ConfigElement.getPath(CONNECTION_TIMEOUT), 10000);
    wc.set(ConfigElement.getPath(HEARTBEAT_TIMEOUT), 10000);
    if (graph != null && graph.isOpen()) {
        graph.close();
    }
    Set<Thread> threadsFromPossibleOtherOpenedConnections = Thread.getAllStackTraces().keySet().stream().filter(thread -> {
        String threadNameLowercase = thread.getName().toLowerCase();
        return thread.isAlive() && (threadNameLowercase.startsWith("cql") || threadNameLowercase.startsWith("janusgraph"));
    }).collect(Collectors.toSet());
    boolean flakyTest = !threadsFromPossibleOtherOpenedConnections.isEmpty();
    graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
    assertDoesNotThrow(() -> {
        graph.traversal().V().hasNext();
        graph.tx().rollback();
    });
    Set<Thread> threadsToAwait = Thread.getAllStackTraces().keySet().stream().filter(thread -> {
        String threadNameLowercase = thread.getName().toLowerCase();
        return thread.isAlive() && !threadsFromPossibleOtherOpenedConnections.contains(thread) && (threadNameLowercase.startsWith("cql") || threadNameLowercase.startsWith("janusgraph"));
    }).collect(Collectors.toSet());
    cqlContainer.stop();
    graph.close();
    for (Thread thread : threadsToAwait) {
        if (thread.isAlive()) {
            if (flakyTest) {
                log.warn("Test shouldGracefullyCloseGraphWhichLostAConnection is currently running in flaky mode " + "because there were open instances available before the test started. " + "Thus, we don't fail this test because we can't be sure that current thread {} " + "is leaked or were created by other JanusGraph instances.", thread.getName());
            } else {
                fail("Thread " + thread.getName() + " was alive but expected to be terminated");
            }
        }
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) StandardJanusGraphTx(org.janusgraph.graphdb.transaction.StandardJanusGraphTx) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) JanusGraphConstants(org.janusgraph.graphdb.configuration.JanusGraphConstants) NETTY_TIMER_TICK_DURATION(org.janusgraph.diskstorage.cql.CQLConfigOptions.NETTY_TIMER_TICK_DURATION) METADATA_TOKEN_MAP_ENABLED(org.janusgraph.diskstorage.cql.CQLConfigOptions.METADATA_TOKEN_MAP_ENABLED) ROOT_NS(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.ROOT_NS) WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) REQUEST_TRACKER_CLASS(org.janusgraph.diskstorage.cql.CQLConfigOptions.REQUEST_TRACKER_CLASS) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) Duration(java.time.Duration) EXECUTOR_SERVICE_CLASS(org.janusgraph.diskstorage.cql.CQLConfigOptions.EXECUTOR_SERVICE_CLASS) REQUEST_TIMEOUT(org.janusgraph.diskstorage.cql.CQLConfigOptions.REQUEST_TIMEOUT) P(org.apache.tinkerpop.gremlin.process.traversal.P) MethodSource(org.junit.jupiter.params.provider.MethodSource) KEYSPACE(org.janusgraph.diskstorage.cql.CQLConfigOptions.KEYSPACE) RESOURCE_CONFIGURATION(org.janusgraph.diskstorage.cql.CQLConfigOptions.RESOURCE_CONFIGURATION) JanusGraphFactory(org.janusgraph.core.JanusGraphFactory) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) READ_CONSISTENCY(org.janusgraph.diskstorage.cql.CQLConfigOptions.READ_CONSISTENCY) STRING_CONFIGURATION(org.janusgraph.diskstorage.cql.CQLConfigOptions.STRING_CONFIGURATION) Set(java.util.Set) REQUEST_LOGGER_SHOW_STACK_TRACES(org.janusgraph.diskstorage.cql.CQLConfigOptions.REQUEST_LOGGER_SHOW_STACK_TRACES) SESSION_LEAK_THRESHOLD(org.janusgraph.diskstorage.cql.CQLConfigOptions.SESSION_LEAK_THRESHOLD) WithOptions(org.apache.tinkerpop.gremlin.process.traversal.step.util.WithOptions) Arguments(org.junit.jupiter.params.provider.Arguments) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) REQUEST_LOGGER_SUCCESS_ENABLED(org.janusgraph.diskstorage.cql.CQLConfigOptions.REQUEST_LOGGER_SUCCESS_ENABLED) Stream(java.util.stream.Stream) CONNECTION_TIMEOUT(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.CONNECTION_TIMEOUT) PARALLEL_BACKEND_EXECUTOR_SERVICE_MAX_SHUTDOWN_WAIT_TIME(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.PARALLEL_BACKEND_EXECUTOR_SERVICE_MAX_SHUTDOWN_WAIT_TIME) DriverConfigLoader(com.datastax.oss.driver.api.core.config.DriverConfigLoader) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) BasicConfiguration(org.janusgraph.diskstorage.configuration.BasicConfiguration) EXECUTOR_SERVICE_MAX_SHUTDOWN_WAIT_TIME(org.janusgraph.diskstorage.cql.CQLConfigOptions.EXECUTOR_SERVICE_MAX_SHUTDOWN_WAIT_TIME) Assertions.assertDoesNotThrow(org.junit.jupiter.api.Assertions.assertDoesNotThrow) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) BASE_PROGRAMMATIC_CONFIGURATION_ENABLED(org.janusgraph.diskstorage.cql.CQLConfigOptions.BASE_PROGRAMMATIC_CONFIGURATION_ENABLED) RequestLogger(com.datastax.oss.driver.internal.core.tracker.RequestLogger) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) REQUEST_LOGGER_SLOW_ENABLED(org.janusgraph.diskstorage.cql.CQLConfigOptions.REQUEST_LOGGER_SLOW_ENABLED) STORAGE_PORT(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.STORAGE_PORT) INITIAL_STORAGE_VERSION(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.INITIAL_STORAGE_VERSION) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) REQUEST_LOGGER_SHOW_VALUES(org.janusgraph.diskstorage.cql.CQLConfigOptions.REQUEST_LOGGER_SHOW_VALUES) ExecutorServiceBuilder(org.janusgraph.diskstorage.configuration.ExecutorServiceBuilder) REQUEST_LOGGER_MAX_QUERY_LENGTH(org.janusgraph.diskstorage.cql.CQLConfigOptions.REQUEST_LOGGER_MAX_QUERY_LENGTH) METADATA_SCHEMA_ENABLED(org.janusgraph.diskstorage.cql.CQLConfigOptions.METADATA_SCHEMA_ENABLED) DefaultDriverOption(com.datastax.oss.driver.api.core.config.DefaultDriverOption) ConfigElement(org.janusgraph.diskstorage.configuration.ConfigElement) Charset(java.nio.charset.Charset) FILE_CONFIGURATION(org.janusgraph.diskstorage.cql.CQLConfigOptions.FILE_CONFIGURATION) STORAGE_HOSTS(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.STORAGE_HOSTS) WRITE_CONSISTENCY(org.janusgraph.diskstorage.cql.CQLConfigOptions.WRITE_CONSISTENCY) URL_CONFIGURATION(org.janusgraph.diskstorage.cql.CQLConfigOptions.URL_CONFIGURATION) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) JanusGraphCassandraContainer(org.janusgraph.JanusGraphCassandraContainer) Container(org.testcontainers.junit.jupiter.Container) REQUEST_LOGGER_MAX_VALUE_LENGTH(org.janusgraph.diskstorage.cql.CQLConfigOptions.REQUEST_LOGGER_MAX_VALUE_LENGTH) Logger(org.slf4j.Logger) REQUEST_LOGGER_SLOW_THRESHOLD(org.janusgraph.diskstorage.cql.CQLConfigOptions.REQUEST_LOGGER_SLOW_THRESHOLD) Configuration(org.janusgraph.diskstorage.configuration.Configuration) Testcontainers(org.testcontainers.junit.jupiter.Testcontainers) LOCAL_DATACENTER(org.janusgraph.diskstorage.cql.CQLConfigOptions.LOCAL_DATACENTER) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) REQUEST_LOGGER_ERROR_ENABLED(org.janusgraph.diskstorage.cql.CQLConfigOptions.REQUEST_LOGGER_ERROR_ENABLED) REQUEST_LOGGER_MAX_VALUES(org.janusgraph.diskstorage.cql.CQLConfigOptions.REQUEST_LOGGER_MAX_VALUES) CQLProgrammaticConfigurationLoaderBuilder(org.janusgraph.diskstorage.cql.builder.CQLProgrammaticConfigurationLoaderBuilder) File(java.io.File) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ChronoUnit(java.time.temporal.ChronoUnit) PARTITIONER_NAME(org.janusgraph.diskstorage.cql.CQLConfigOptions.PARTITIONER_NAME) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) IDS_RENEW_TIMEOUT(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.IDS_RENEW_TIMEOUT) Collections(java.util.Collections) HEARTBEAT_TIMEOUT(org.janusgraph.diskstorage.cql.CQLConfigOptions.HEARTBEAT_TIMEOUT) ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration) WriteConfiguration(org.janusgraph.diskstorage.configuration.WriteConfiguration) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

WriteConfiguration (org.janusgraph.diskstorage.configuration.WriteConfiguration)40 Test (org.junit.jupiter.api.Test)26 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)21 ModifiableConfiguration (org.janusgraph.diskstorage.configuration.ModifiableConfiguration)7 StandardJanusGraphTx (org.janusgraph.graphdb.transaction.StandardJanusGraphTx)7 BasicConfiguration (org.janusgraph.diskstorage.configuration.BasicConfiguration)6 File (java.io.File)5 GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)5 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)5 Test (org.junit.Test)5 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)4 URL (java.net.URL)3 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)3 Configuration (org.janusgraph.diskstorage.configuration.Configuration)3 RequestLogger (com.datastax.oss.driver.internal.core.tracker.RequestLogger)2 IOException (java.io.IOException)2 StringWriter (java.io.StringWriter)2 Duration (java.time.Duration)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2