Search in sources :

Example 26 with DatabaseConfig

use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.

the class ConsensusCommitConfigTest method constructor_ParallelExecutionRelatedPropertiesWithoutParallelValidationAndParallelRollbackPropertyGiven_ShouldUseParallelCommitValueForParallelValidationAndParallelRollback.

@Test
public void constructor_ParallelExecutionRelatedPropertiesWithoutParallelValidationAndParallelRollbackPropertyGiven_ShouldUseParallelCommitValueForParallelValidationAndParallelRollback() {
    // Arrange
    Properties props = new Properties();
    props.setProperty(ConsensusCommitConfig.PARALLEL_EXECUTOR_COUNT, "100");
    props.setProperty(ConsensusCommitConfig.PARALLEL_PREPARATION_ENABLED, "false");
    props.setProperty(ConsensusCommitConfig.PARALLEL_COMMIT_ENABLED, "true");
    // Act
    ConsensusCommitConfig config = new ConsensusCommitConfig(new DatabaseConfig(props));
    // Assert
    assertThat(config.getParallelExecutorCount()).isEqualTo(100);
    assertThat(config.isParallelPreparationEnabled()).isEqualTo(false);
    assertThat(config.isParallelValidationEnabled()).isEqualTo(// use the parallel commit value
    true);
    assertThat(config.isParallelCommitEnabled()).isEqualTo(true);
    // use the parallel commit value
    assertThat(config.isParallelRollbackEnabled()).isEqualTo(true);
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) Test(org.junit.jupiter.api.Test)

Example 27 with DatabaseConfig

use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.

the class MultiStorageIntegrationTest method initMultiStorage.

private void initMultiStorage() {
    Properties props = new Properties();
    props.setProperty(DatabaseConfig.STORAGE, "multi-storage");
    // Define storages, storage1 and storage2
    props.setProperty(MultiStorageConfig.STORAGES, "storage1,storage2");
    Properties propertiesForStorage1 = MultiStorageEnv.getPropertiesForStorage1();
    props.setProperty(MultiStorageConfig.STORAGES + ".storage1.storage", propertiesForStorage1.getProperty(DatabaseConfig.STORAGE));
    props.setProperty(MultiStorageConfig.STORAGES + ".storage1.contact_points", propertiesForStorage1.getProperty(DatabaseConfig.CONTACT_POINTS));
    if (propertiesForStorage1.containsValue(DatabaseConfig.CONTACT_PORT)) {
        props.setProperty(MultiStorageConfig.STORAGES + ".storage1.contact_port", propertiesForStorage1.getProperty(DatabaseConfig.CONTACT_PORT));
    }
    props.setProperty(MultiStorageConfig.STORAGES + ".storage1.username", propertiesForStorage1.getProperty(DatabaseConfig.USERNAME));
    props.setProperty(MultiStorageConfig.STORAGES + ".storage1.password", propertiesForStorage1.getProperty(DatabaseConfig.PASSWORD));
    Properties propertiesForStorage2 = MultiStorageEnv.getPropertiesForStorage2();
    props.setProperty(MultiStorageConfig.STORAGES + ".storage2.storage", propertiesForStorage2.getProperty(DatabaseConfig.STORAGE));
    props.setProperty(MultiStorageConfig.STORAGES + ".storage2.contact_points", propertiesForStorage2.getProperty(DatabaseConfig.CONTACT_POINTS));
    if (propertiesForStorage2.containsValue(DatabaseConfig.CONTACT_PORT)) {
        props.setProperty(MultiStorageConfig.STORAGES + ".storage2.contact_port", propertiesForStorage2.getProperty(DatabaseConfig.CONTACT_PORT));
    }
    props.setProperty(MultiStorageConfig.STORAGES + ".storage2.username", propertiesForStorage2.getProperty(DatabaseConfig.USERNAME));
    props.setProperty(MultiStorageConfig.STORAGES + ".storage2.password", propertiesForStorage2.getProperty(DatabaseConfig.PASSWORD));
    // Define table mapping from table1 to storage1, and from table2 to storage2
    props.setProperty(MultiStorageConfig.TABLE_MAPPING, NAMESPACE1 + "." + TABLE1 + ":storage1," + NAMESPACE1 + "." + TABLE2 + ":storage2");
    // Define namespace mapping from namespace2 to storage2
    props.setProperty(MultiStorageConfig.NAMESPACE_MAPPING, NAMESPACE2 + ":storage2");
    // The default storage is storage1
    props.setProperty(MultiStorageConfig.DEFAULT_STORAGE, "storage1");
    multiStorage = new MultiStorage(new DatabaseConfig(props));
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig)

Example 28 with DatabaseConfig

use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.

the class JdbcDatabaseSecondaryIndexIntegrationTest method getProperties.

@Override
protected Properties getProperties() {
    Properties properties = JdbcEnv.getProperties();
    rdbEngine = JdbcUtils.getRdbEngine(new JdbcConfig(new DatabaseConfig(properties)).getJdbcUrl());
    return properties;
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig)

Example 29 with DatabaseConfig

use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.

the class JdbcDatabaseSingleClusteringKeyScanIntegrationTest method getProperties.

@Override
protected Properties getProperties() {
    Properties properties = JdbcEnv.getProperties();
    rdbEngine = JdbcUtils.getRdbEngine(new JdbcConfig(new DatabaseConfig(properties)).getJdbcUrl());
    return properties;
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig)

Example 30 with DatabaseConfig

use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.

the class JdbcDatabaseConditionalMutationIntegrationTest method getProperties.

@Override
protected Properties getProperties() {
    Properties properties = JdbcEnv.getProperties();
    rdbEngine = JdbcUtils.getRdbEngine(new JdbcConfig(new DatabaseConfig(properties)).getJdbcUrl());
    return properties;
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig)

Aggregations

DatabaseConfig (com.scalar.db.config.DatabaseConfig)66 Properties (java.util.Properties)60 Test (org.junit.jupiter.api.Test)40 StorageFactory (com.scalar.db.service.StorageFactory)6 BasicDataSource (org.apache.commons.dbcp2.BasicDataSource)4 BeforeAll (org.junit.jupiter.api.BeforeAll)3 ImmutableList (com.google.common.collect.ImmutableList)2 ConsensusCommitAdmin (com.scalar.db.transaction.consensuscommit.ConsensusCommitAdmin)2 File (java.io.File)2 Before (org.junit.Before)2 BeforeClass (org.junit.BeforeClass)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ConfigUtils.getString (com.scalar.db.config.ConfigUtils.getString)1 JdbcConfig (com.scalar.db.storage.jdbc.JdbcConfig)1 ConsensusCommitConfig (com.scalar.db.transaction.consensuscommit.ConsensusCommitConfig)1