Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default value of metadata cache expiration time #2274

Merged
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
6 changes: 5 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 @@ -57,6 +57,7 @@ public class DatabaseConfig {
public static final String CROSS_PARTITION_SCAN_ORDERING = SCAN_PREFIX + "ordering.enabled";
public static final String SYSTEM_NAMESPACE_NAME = PREFIX + "system_namespace_name";

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 @@ -180,7 +181,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()).isFalse();
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()).isFalse();
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()).isFalse();
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()).isFalse();
Expand Down