Skip to content

Commit

Permalink
Backport to branch(3) : Change default value of metadata cache expira…
Browse files Browse the repository at this point in the history
…tion time (#2276)

Co-authored-by: Toshihiro <[email protected]>
  • Loading branch information
feeblefakie and brfrn169 authored Oct 10, 2024
1 parent 11dbc96 commit 06b24f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
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

0 comments on commit 06b24f6

Please sign in to comment.