Search in sources :

Example 61 with DatabaseConfig

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

the class CassandraEnv method getDatabaseConfig.

public static DatabaseConfig getDatabaseConfig() {
    String contactPoints = System.getProperty(PROP_CASSANDRA_CONTACT_POINTS, DEFAULT_CASSANDRA_CONTACT_POINTS);
    String username = System.getProperty(PROP_CASSANDRA_USERNAME, DEFAULT_CASSANDRA_USERNAME);
    String password = System.getProperty(PROP_CASSANDRA_PASSWORD, DEFAULT_CASSANDRA_PASSWORD);
    Properties props = new Properties();
    props.setProperty(DatabaseConfig.CONTACT_POINTS, contactPoints);
    props.setProperty(DatabaseConfig.USERNAME, username);
    props.setProperty(DatabaseConfig.PASSWORD, password);
    return new DatabaseConfig(props);
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig)

Example 62 with DatabaseConfig

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

the class ConsensusCommitWithMultiStorageIntegrationTest method getDatabaseConfig.

@Override
protected DatabaseConfig getDatabaseConfig() {
    Properties props = new Properties();
    props.setProperty(DatabaseConfig.STORAGE, "multi-storage");
    // Define storages, storage1 and storage2
    props.setProperty(MultiStorageConfig.STORAGES, "storage1,storage2");
    DatabaseConfig configForStorage1 = MultiStorageEnv.getDatabaseConfigForStorage1();
    props.setProperty(MultiStorageConfig.STORAGES + ".storage1.storage", configForStorage1.getProperties().getProperty(DatabaseConfig.STORAGE));
    props.setProperty(MultiStorageConfig.STORAGES + ".storage1.contact_points", configForStorage1.getProperties().getProperty(DatabaseConfig.CONTACT_POINTS));
    if (configForStorage1.getProperties().containsValue(DatabaseConfig.CONTACT_PORT)) {
        props.setProperty(MultiStorageConfig.STORAGES + ".storage1.contact_port", configForStorage1.getProperties().getProperty(DatabaseConfig.CONTACT_PORT));
    }
    props.setProperty(MultiStorageConfig.STORAGES + ".storage1.username", configForStorage1.getProperties().getProperty(DatabaseConfig.USERNAME));
    props.setProperty(MultiStorageConfig.STORAGES + ".storage1.password", configForStorage1.getProperties().getProperty(DatabaseConfig.PASSWORD));
    DatabaseConfig configForStorage2 = MultiStorageEnv.getDatabaseConfigForStorage2();
    props.setProperty(MultiStorageConfig.STORAGES + ".storage2.storage", configForStorage2.getProperties().getProperty(DatabaseConfig.STORAGE));
    props.setProperty(MultiStorageConfig.STORAGES + ".storage2.contact_points", configForStorage2.getProperties().getProperty(DatabaseConfig.CONTACT_POINTS));
    if (configForStorage2.getProperties().containsValue(DatabaseConfig.CONTACT_PORT)) {
        props.setProperty(MultiStorageConfig.STORAGES + ".storage2.contact_port", configForStorage2.getProperties().getProperty(DatabaseConfig.CONTACT_PORT));
    }
    props.setProperty(MultiStorageConfig.STORAGES + ".storage2.username", configForStorage2.getProperties().getProperty(DatabaseConfig.USERNAME));
    props.setProperty(MultiStorageConfig.STORAGES + ".storage2.password", configForStorage2.getProperties().getProperty(DatabaseConfig.PASSWORD));
    // Define namespace mapping from namespace1 to storage1, from namespace2 to storage2, and from
    // the coordinator namespace to storage1
    props.setProperty(MultiStorageConfig.NAMESPACE_MAPPING, getNamespace1() + ":storage1," + getNamespace2() + ":storage2," + Coordinator.NAMESPACE + ":storage1");
    // The default storage is storage1
    props.setProperty(MultiStorageConfig.DEFAULT_STORAGE, "storage1");
    return new DatabaseConfig(props);
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig)

Example 63 with DatabaseConfig

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

the class TwoPhaseConsensusCommitIntegrationTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws ExecutionException {
    DatabaseConfig config = getDatabaseConfig();
    initStorageAndAdmin(config);
    createTables();
    initManagerAndCoordinator(config);
}
Also used : DatabaseConfig(com.scalar.db.config.DatabaseConfig) BeforeClass(org.junit.BeforeClass)

Example 64 with DatabaseConfig

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

the class TwoPhaseConsensusCommitIntegrationTest method getDatabaseConfig.

private static DatabaseConfig getDatabaseConfig() {
    String contactPoints = System.getProperty(PROP_CONTACT_POINTS, DEFAULT_CONTACT_POINTS);
    String contactPort = System.getProperty(PROP_CONTACT_PORT);
    String username = System.getProperty(PROP_USERNAME, DEFAULT_USERNAME);
    String password = System.getProperty(PROP_PASSWORD, DEFAULT_PASSWORD);
    String storage = System.getProperty(PROP_STORAGE, DEFAULT_STORAGE);
    Properties properties = new Properties();
    properties.setProperty(DatabaseConfig.CONTACT_POINTS, contactPoints);
    if (contactPort != null) {
        properties.setProperty(DatabaseConfig.CONTACT_PORT, contactPort);
    }
    properties.setProperty(DatabaseConfig.USERNAME, username);
    properties.setProperty(DatabaseConfig.PASSWORD, password);
    properties.setProperty(DatabaseConfig.STORAGE, storage);
    return new DatabaseConfig(properties);
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig)

Example 65 with DatabaseConfig

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

the class JdbcTransactionIntegrationTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws ExecutionException {
    DatabaseConfig databaseConfig = TestUtils.addSuffix(JdbcEnv.getJdbcConfig(), TEST_NAME);
    JdbcConfig config = new JdbcConfig(databaseConfig.getProperties());
    StorageFactory factory = new StorageFactory(config);
    admin = factory.getAdmin();
    admin.createNamespace(NAMESPACE, true);
    admin.createTable(NAMESPACE, TABLE, TableMetadata.newBuilder().addColumn(ACCOUNT_ID, DataType.INT).addColumn(ACCOUNT_TYPE, DataType.INT).addColumn(BALANCE, DataType.INT).addPartitionKey(ACCOUNT_ID).addClusteringKey(ACCOUNT_TYPE).build(), true);
    manager = new JdbcTransactionManager(config);
}
Also used : StorageFactory(com.scalar.db.service.StorageFactory) JdbcConfig(com.scalar.db.storage.jdbc.JdbcConfig) DatabaseConfig(com.scalar.db.config.DatabaseConfig) BeforeClass(org.junit.BeforeClass)

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