use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class SchemaLoaderIntegrationTestBase method setUp.
@Before
public void setUp() throws Exception {
if (!initialized) {
initialize();
DatabaseConfig config = getDatabaseConfig();
namespace1 = getNamespace1();
namespace2 = getNamespace2();
writeConfigFile(config.getProperties());
Map<String, Object> schemaJsonMap = getSchemaJsonMap();
writeSchemaFile(schemaJsonMap);
StorageFactory factory = new StorageFactory(config);
admin = factory.getAdmin();
consensusCommitAdmin = new ConsensusCommitAdmin(admin, new ConsensusCommitConfig(config.getProperties()));
initialized = true;
}
dropTablesIfExist();
}
use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class TestUtils method addSuffix.
/**
* Add a suffix to the metadata database/namespace/schema name and the consensus-commit
* coordinator table name.
*
* @param config the original config
* @param testName used for the suffix
* @return config added the suffix
*/
public static DatabaseConfig addSuffix(DatabaseConfig config, String testName) {
Properties properties = new Properties();
properties.putAll(config.getProperties());
// for Cosmos
String tableMetadataDatabase = properties.getProperty(CosmosConfig.TABLE_METADATA_DATABASE);
if (tableMetadataDatabase == null) {
tableMetadataDatabase = CosmosAdmin.METADATA_DATABASE;
}
properties.setProperty(CosmosConfig.TABLE_METADATA_DATABASE, tableMetadataDatabase + "_" + testName);
// for Dynamo
String tableMetadataNamespace = properties.getProperty(DynamoConfig.TABLE_METADATA_NAMESPACE);
if (tableMetadataNamespace == null) {
tableMetadataNamespace = DynamoAdmin.METADATA_NAMESPACE;
}
properties.setProperty(DynamoConfig.TABLE_METADATA_NAMESPACE, tableMetadataNamespace + "_" + testName);
// for JDBC
String tableMetadataSchema = properties.getProperty(JdbcConfig.TABLE_METADATA_SCHEMA);
if (tableMetadataSchema == null) {
tableMetadataSchema = JdbcAdmin.METADATA_SCHEMA;
}
properties.setProperty(JdbcConfig.TABLE_METADATA_SCHEMA, tableMetadataSchema + "_" + testName);
// for consensus-commit
String coordinatorNamespace = properties.getProperty(ConsensusCommitConfig.COORDINATOR_NAMESPACE);
if (coordinatorNamespace == null) {
coordinatorNamespace = Coordinator.NAMESPACE;
}
properties.setProperty(ConsensusCommitConfig.COORDINATOR_NAMESPACE, coordinatorNamespace + "_" + testName);
return new DatabaseConfig(properties);
}
use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class MultiStorageConfig method loadDatabaseConfigs.
private void loadDatabaseConfigs() {
String[] storages = getStringArray(getProperties(), STORAGES, null);
if (storages == null) {
databaseConfigMap = Collections.emptyMap();
return;
}
ImmutableMap.Builder<String, DatabaseConfig> builder = ImmutableMap.builder();
for (String storage : storages) {
Properties dbProps = new Properties();
for (String propertyName : props.stringPropertyNames()) {
if (propertyName.startsWith(STORAGES + "." + storage + ".")) {
dbProps.put(propertyName.replace("multi_storage.storages." + storage + ".", ""), props.getProperty(propertyName));
}
}
if (dbProps.getProperty(DatabaseConfig.STORAGE).equals(MULTI_STORAGE)) {
throw new IllegalArgumentException("Does not support nested " + MULTI_STORAGE + ": " + storage);
}
builder.put(storage, new DatabaseConfig(dbProps));
}
databaseConfigMap = builder.build();
}
use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class CosmosSchemaLoaderWithStorageSpecificArgsIntegrationTest method getCommandArgsForCreationWithCoordinatorTable.
@Override
protected List<String> getCommandArgsForCreationWithCoordinatorTable(String configFile, String schemaFile) throws IOException {
DatabaseConfig config = new DatabaseConfig(new File(configFile));
ImmutableList.Builder<String> builder = ImmutableList.<String>builder().add("--cosmos").add("-h").add(config.getContactPoints().get(0)).add("--schema-file").add(schemaFile).add("-p").add(config.getPassword().get());
CosmosEnv.getDatabasePrefix().ifPresent((prefix) -> builder.add("--table-metadata-database-prefix").add(prefix).add("--coordinator-namespace-prefix").add(prefix));
return builder.build();
}
use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class JdbcConfigTest method constructor_PropertiesWithInvalidPreparedStatementsPoolPropertiesGiven_ShouldThrowIllegalArgumentException.
@Test
public void constructor_PropertiesWithInvalidPreparedStatementsPoolPropertiesGiven_ShouldThrowIllegalArgumentException() {
// Arrange
Properties props = new Properties();
props.setProperty(DatabaseConfig.CONTACT_POINTS, ANY_JDBC_URL);
props.setProperty(DatabaseConfig.USERNAME, ANY_USERNAME);
props.setProperty(DatabaseConfig.PASSWORD, ANY_PASSWORD);
props.setProperty(DatabaseConfig.STORAGE, JDBC_STORAGE);
props.setProperty(JdbcConfig.PREPARED_STATEMENTS_POOL_ENABLED, "ddd");
props.setProperty(JdbcConfig.PREPARED_STATEMENTS_POOL_MAX_OPEN, "eee");
// Act Assert
assertThatThrownBy(() -> new JdbcConfig(new DatabaseConfig(props))).isInstanceOf(IllegalArgumentException.class);
}
Aggregations