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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations