Search in sources :

Example 56 with DatabaseConfig

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

the class JdbcDatabaseSinglePartitionKeyIntegrationTest 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 57 with DatabaseConfig

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

the class MultiStorageAdminIntegrationTest method initMultiStorageAdmin.

private void initMultiStorageAdmin() {
    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 in namespace1 to storage1, and from table2 in namespace1 to
    // storage2
    props.setProperty(MultiStorageConfig.TABLE_MAPPING, NAMESPACE1 + "." + TABLE1 + ":storage1," + NAMESPACE1 + "." + TABLE2 + ":storage2");
    // Define namespace mapping from namespace2 and namespace3 to storage2
    props.setProperty(MultiStorageConfig.NAMESPACE_MAPPING, NAMESPACE2 + ":storage2," + NAMESPACE3 + ":storage2");
    // The default storage is storage1
    props.setProperty(MultiStorageConfig.DEFAULT_STORAGE, "storage1");
    multiStorageAdmin = new MultiStorageAdmin(new DatabaseConfig(props));
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig)

Example 58 with DatabaseConfig

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

the class ConsensusCommitIntegrationTestBase method setUp.

@Before
public void setUp() throws Exception {
    if (!initialized) {
        initialize();
        DatabaseConfig config = TestUtils.addSuffix(getDatabaseConfig(), TEST_NAME);
        StorageFactory factory = new StorageFactory(config);
        admin = factory.getAdmin();
        consensusCommitConfig = new ConsensusCommitConfig(config.getProperties());
        consensusCommitAdmin = new ConsensusCommitAdmin(admin, consensusCommitConfig);
        namespace1 = getNamespace1();
        namespace2 = getNamespace2();
        createTables();
        originalStorage = factory.getStorage();
        parallelExecutor = new ParallelExecutor(consensusCommitConfig);
        initialized = true;
    }
    truncateTables();
    storage = spy(originalStorage);
    coordinator = spy(new Coordinator(storage, consensusCommitConfig));
    TransactionalTableMetadataManager tableMetadataManager = new TransactionalTableMetadataManager(admin, -1);
    recovery = spy(new RecoveryHandler(storage, coordinator, tableMetadataManager));
    commit = spy(new CommitHandler(storage, coordinator, tableMetadataManager, parallelExecutor));
    manager = new ConsensusCommitManager(storage, admin, consensusCommitConfig, coordinator, parallelExecutor, recovery, commit);
}
Also used : StorageFactory(com.scalar.db.service.StorageFactory) DatabaseConfig(com.scalar.db.config.DatabaseConfig) Before(org.junit.Before)

Example 59 with DatabaseConfig

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

the class MultiStorageEnv method getDatabaseConfigForStorage2.

public static DatabaseConfig getDatabaseConfigForStorage2() {
    String contactPoints = System.getProperty(PROP_STORAGE2_CONTACT_POINTS, DEFAULT_STORAGE2_CONTACT_POINT);
    String contactPort = System.getProperty(PROP_STORAGE2_CONTACT_PORT);
    String username = System.getProperty(PROP_STORAGE2_USERNAME, DEFAULT_STORAGE2_USERNAME);
    String password = System.getProperty(PROP_STORAGE2_PASSWORD, DEFAULT_STORAGE2_PASSWORD);
    String storage = System.getProperty(PROP_STORAGE2_STORAGE, DEFAULT_STORAGE2_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 60 with DatabaseConfig

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

the class MultiStorageEnv method getDatabaseConfigForStorage1.

public static DatabaseConfig getDatabaseConfigForStorage1() {
    String contactPoints = System.getProperty(PROP_STORAGE1_CONTACT_POINTS, DEFAULT_STORAGE1_CONTACT_POINT);
    String contactPort = System.getProperty(PROP_STORAGE1_CONTACT_PORT);
    String username = System.getProperty(PROP_STORAGE1_USERNAME, DEFAULT_STORAGE1_USERNAME);
    String password = System.getProperty(PROP_STORAGE1_PASSWORD, DEFAULT_STORAGE1_PASSWORD);
    String storage = System.getProperty(PROP_STORAGE1_STORAGE, DEFAULT_STORAGE1_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)

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