Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/src/main/java/com/scalar/db/config/DatabaseConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class DatabaseConfig {
public static final String CROSS_PARTITION_SCAN = SCAN_PREFIX + "enabled";
public static final String CROSS_PARTITION_SCAN_FILTERING = SCAN_PREFIX + "filtering.enabled";
public static final String CROSS_PARTITION_SCAN_ORDERING = SCAN_PREFIX + "ordering.enabled";

public static final int DEFAULT_METADATA_CACHE_EXPIRATION_TIME_SECS = 60;
public static final String DEFAULT_SYSTEM_NAMESPACE_NAME = "scalardb";

public DatabaseConfig(File propertiesFile) throws IOException {
Expand Down Expand Up @@ -171,7 +173,10 @@ public static String getTransactionManager(Properties properties) {
}

public static long getMetadataCacheExpirationTimeSecs(Properties properties) {
return getLong(properties, METADATA_CACHE_EXPIRATION_TIME_SECS, -1);
return getLong(
properties,
METADATA_CACHE_EXPIRATION_TIME_SECS,
DEFAULT_METADATA_CACHE_EXPIRATION_TIME_SECS);
}

public static long getActiveTransactionManagementExpirationTimeMillis(Properties properties) {
Expand Down
12 changes: 8 additions & 4 deletions core/src/test/java/com/scalar/db/config/DatabaseConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public void constructor_PropertiesWithoutPortGiven_ShouldLoadProperly() {
assertThat(config.getPassword().get()).isEqualTo(ANY_PASSWORD);
assertThat(config.getStorage()).isEqualTo("cassandra");
assertThat(config.getTransactionManager()).isEqualTo("consensus-commit");
assertThat(config.getMetadataCacheExpirationTimeSecs()).isEqualTo(-1);
assertThat(config.getMetadataCacheExpirationTimeSecs())
.isEqualTo(DatabaseConfig.DEFAULT_METADATA_CACHE_EXPIRATION_TIME_SECS);
assertThat(config.getActiveTransactionManagementExpirationTimeMillis()).isEqualTo(-1);
assertThat(config.isCrossPartitionScanEnabled()).isTrue();
assertThat(config.isCrossPartitionScanFilteringEnabled()).isFalse();
Expand All @@ -61,7 +62,8 @@ public void constructor_PropertiesWithoutUsernameGiven_ShouldLoadProperly() {
assertThat(config.getPassword().get()).isEqualTo(ANY_PASSWORD);
assertThat(config.getStorage()).isEqualTo("cassandra");
assertThat(config.getTransactionManager()).isEqualTo("consensus-commit");
assertThat(config.getMetadataCacheExpirationTimeSecs()).isEqualTo(-1);
assertThat(config.getMetadataCacheExpirationTimeSecs())
.isEqualTo(DatabaseConfig.DEFAULT_METADATA_CACHE_EXPIRATION_TIME_SECS);
assertThat(config.getActiveTransactionManagementExpirationTimeMillis()).isEqualTo(-1);
assertThat(config.getDefaultNamespaceName()).isEmpty();
assertThat(config.isCrossPartitionScanEnabled()).isTrue();
Expand All @@ -88,7 +90,8 @@ public void constructor_PropertiesWithoutPasswordGiven_ShouldLoadProperly() {
assertThat(config.getPassword().isPresent()).isFalse();
assertThat(config.getStorage()).isEqualTo("cassandra");
assertThat(config.getTransactionManager()).isEqualTo("consensus-commit");
assertThat(config.getMetadataCacheExpirationTimeSecs()).isEqualTo(-1);
assertThat(config.getMetadataCacheExpirationTimeSecs())
.isEqualTo(DatabaseConfig.DEFAULT_METADATA_CACHE_EXPIRATION_TIME_SECS);
assertThat(config.getActiveTransactionManagementExpirationTimeMillis()).isEqualTo(-1);
assertThat(config.getDefaultNamespaceName()).isEmpty();
assertThat(config.isCrossPartitionScanEnabled()).isTrue();
Expand Down Expand Up @@ -117,7 +120,8 @@ public void constructor_PropertiesWithPortGiven_ShouldLoadProperly() {
assertThat(config.getPassword().get()).isEqualTo(ANY_PASSWORD);
assertThat(config.getStorage()).isEqualTo("cassandra");
assertThat(config.getTransactionManager()).isEqualTo("consensus-commit");
assertThat(config.getMetadataCacheExpirationTimeSecs()).isEqualTo(-1);
assertThat(config.getMetadataCacheExpirationTimeSecs())
.isEqualTo(DatabaseConfig.DEFAULT_METADATA_CACHE_EXPIRATION_TIME_SECS);
assertThat(config.getActiveTransactionManagementExpirationTimeMillis()).isEqualTo(-1);
assertThat(config.getDefaultNamespaceName()).isEmpty();
assertThat(config.isCrossPartitionScanEnabled()).isTrue();
Expand Down