This is an automated email from the ASF dual-hosted git repository. edimitrova pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 755fd9446b084e659e98bd7336b9e910c2e12577 Author: Ekaterina Dimitrova <ekaterina.dimitr...@datastax.com> AuthorDate: Thu Feb 3 14:39:48 2022 -0500 Transfer parameters to the newly introduced configuration framework (3) patch by Ekaterina Dimitrova; reviewed by Caleb Rackliffe, David Capwell, Michael Semb Wever and Benjamin Lerer for CASSANDRA-15234 --- conf/cassandra.yaml | 36 +++++++++---------- src/java/org/apache/cassandra/auth/AuthConfig.java | 6 ++-- .../apache/cassandra/auth/AuthenticatedUser.java | 2 +- src/java/org/apache/cassandra/auth/Roles.java | 2 +- src/java/org/apache/cassandra/config/Config.java | 21 ++++++++---- .../cassandra/config/DatabaseDescriptor.java | 40 +++++++++++----------- .../apache/cassandra/service/StorageService.java | 2 +- .../test/BootstrapBinaryDisabledTest.java | 4 +-- .../db/virtual/CredentialsCacheKeysTableTest.java | 2 +- .../virtual/JmxPermissionsCacheKeysTableTest.java | 2 +- .../NetworkPermissionsCacheKeysTableTest.java | 2 +- .../db/virtual/PermissionsCacheKeysTableTest.java | 2 +- .../db/virtual/RolesCacheKeysTableTest.java | 2 +- 13 files changed, 65 insertions(+), 58 deletions(-) diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml index 884a432..e9cce68 100644 --- a/conf/cassandra.yaml +++ b/conf/cassandra.yaml @@ -61,7 +61,7 @@ hinted_handoff_enabled: true # this defines the maximum amount of time a dead host will have hints # generated. After it has been dead this long, new hints for it will not be # created until it has been seen alive and gone down again. -max_hint_window_in_ms: 10800000 # 3 hours +max_hint_window: 3h # Maximum throttle in KBs per second, per delivery thread. This will be # reduced proportionally to the number of nodes in the cluster. (If there @@ -101,10 +101,10 @@ auto_hints_cleanup_enabled: false # Enable / disable persistent hint windows. # # If set to false, a hint will be stored only in case a respective node -# that hint is for is down less than or equal to max_hint_window_in_ms. +# that hint is for is down less than or equal to max_hint_window. # # If set to true, a hint will be stored in case there is not any -# hint which was stored earlier than max_hint_window_in_ms. This is for cases +# hint which was stored earlier than max_hint_window. This is for cases # when a node keeps to restart and hints are not delivered yet, we would be saving # hints for that node indefinitely. # @@ -172,21 +172,21 @@ network_authorizer: AllowAllNetworkAuthorizer # Will be disabled automatically for AllowAllAuthenticator. # For a long-running cache using roles_cache_active_update, consider # setting to something longer such as a daily validation: 86400000 -roles_validity_in_ms: 2000 +roles_validity: 2000ms # Refresh interval for roles cache (if enabled). # After this interval, cache entries become eligible for refresh. Upon next # access, an async reload is scheduled and the old value returned until it -# completes. If roles_validity_in_ms is non-zero, then this must be +# completes. If roles_validity is non-zero, then this must be # also. # This setting is also used to inform the interval of auto-updating if # using roles_cache_active_update. -# Defaults to the same value as roles_validity_in_ms. +# Defaults to the same value as roles_validity. # For a long-running cache, consider setting this to 60000 (1 hour) etc. -# roles_update_interval_in_ms: 2000 +# roles_update_interval: 2000ms # If true, cache contents are actively updated by a background task at the -# interval set by roles_update_interval_in_ms. If false, cache entries +# interval set by roles_update_interval. If false, cache entries # become eligible for refresh after their update interval. Upon next access, # an async reload is scheduled and the old value returned until it completes. # roles_cache_active_update: false @@ -197,21 +197,21 @@ roles_validity_in_ms: 2000 # Will be disabled automatically for AllowAllAuthorizer. # For a long-running cache using permissions_cache_active_update, consider # setting to something longer such as a daily validation: 86400000 -permissions_validity_in_ms: 2000 +permissions_validity: 2000ms # Refresh interval for permissions cache (if enabled). # After this interval, cache entries become eligible for refresh. Upon next # access, an async reload is scheduled and the old value returned until it -# completes. If permissions_validity_in_ms is non-zero, then this must be +# completes. If permissions_validity is non-zero, then this must be # also. # This setting is also used to inform the interval of auto-updating if # using permissions_cache_active_update. -# Defaults to the same value as permissions_validity_in_ms. +# Defaults to the same value as permissions_validity. # For a longer-running permissions cache, consider setting to update hourly (60000) -# permissions_update_interval_in_ms: 2000 +# permissions_update_interval: 2000ms # If true, cache contents are actively updated by a background task at the -# interval set by permissions_update_interval_in_ms. If false, cache entries +# interval set by permissions_update_interval. If false, cache entries # become eligible for refresh after their update interval. Upon next access, # an async reload is scheduled and the old value returned until it completes. # permissions_cache_active_update: false @@ -227,21 +227,21 @@ permissions_validity_in_ms: 2000 # Defaults to 2000, set to 0 to disable credentials caching. # For a long-running cache using credentials_cache_active_update, consider # setting to something longer such as a daily validation: 86400000 -credentials_validity_in_ms: 2000 +credentials_validity: 2000ms # Refresh interval for credentials cache (if enabled). # After this interval, cache entries become eligible for refresh. Upon next # access, an async reload is scheduled and the old value returned until it -# completes. If credentials_validity_in_ms is non-zero, then this must be +# completes. If credentials_validity is non-zero, then this must be # also. # This setting is also used to inform the interval of auto-updating if # using credentials_cache_active_update. -# Defaults to the same value as credentials_validity_in_ms. +# Defaults to the same value as credentials_validity. # For a longer-running permissions cache, consider setting to update hourly (60000) -# credentials_update_interval_in_ms: 2000 +# credentials_update_interval: 2000ms # If true, cache contents are actively updated by a background task at the -# interval set by credentials_update_interval_in_ms. If false (default), cache entries +# interval set by credentials_update_interval. If false (default), cache entries # become eligible for refresh after their update interval. Upon next access, # an async reload is scheduled and the old value returned until it completes. # credentials_cache_active_update: false diff --git a/src/java/org/apache/cassandra/auth/AuthConfig.java b/src/java/org/apache/cassandra/auth/AuthConfig.java index cc38296..28ee102 100644 --- a/src/java/org/apache/cassandra/auth/AuthConfig.java +++ b/src/java/org/apache/cassandra/auth/AuthConfig.java @@ -56,11 +56,11 @@ public final class AuthConfig // work with PasswordAuthenticator, so log a message if some other authenticator // is in use and non-default values are detected if (!(authenticator instanceof PasswordAuthenticator) - && (conf.credentials_update_interval_in_ms != -1 - || conf.credentials_validity_in_ms != 2000 + && (conf.credentials_update_interval.toMillisecondsAsInt() != 0 + || conf.credentials_validity.toMillisecondsAsInt() != 2000 || conf.credentials_cache_max_entries != 1000)) { - logger.info("Configuration options credentials_update_interval_in_ms, credentials_validity_in_ms and " + + logger.info("Configuration options credentials_update_interval, credentials_validity and " + "credentials_cache_max_entries may not be applicable for the configured authenticator ({})", authenticator.getClass().getName()); } diff --git a/src/java/org/apache/cassandra/auth/AuthenticatedUser.java b/src/java/org/apache/cassandra/auth/AuthenticatedUser.java index ccac0ff..620a1d2 100644 --- a/src/java/org/apache/cassandra/auth/AuthenticatedUser.java +++ b/src/java/org/apache/cassandra/auth/AuthenticatedUser.java @@ -27,7 +27,7 @@ import org.apache.cassandra.dht.Datacenters; * Returned from IAuthenticator#authenticate(), represents an authenticated user everywhere internally. * * Holds the name of the user and the roles that have been granted to the user. The roles will be cached - * for roles_validity_in_ms. + * for roles_validity. */ public class AuthenticatedUser { diff --git a/src/java/org/apache/cassandra/auth/Roles.java b/src/java/org/apache/cassandra/auth/Roles.java index 9d3e232..f18851a 100644 --- a/src/java/org/apache/cassandra/auth/Roles.java +++ b/src/java/org/apache/cassandra/auth/Roles.java @@ -61,7 +61,7 @@ public class Roles * Get detailed info on all the roles granted to the role identified by the supplied RoleResource. * This includes superuser status and login privileges for the primary role and all roles granted directly * to it or inherited. - * The returnred roles may be cached if roles_validity_in_ms > 0 + * The returned roles may be cached if roles_validity > 0 * This method is used where we need to know specific attributes of the collection of granted roles, i.e. * when checking for superuser status which may be inherited from *any* granted role. * diff --git a/src/java/org/apache/cassandra/config/Config.java b/src/java/org/apache/cassandra/config/Config.java index 7602118..172f16b 100644 --- a/src/java/org/apache/cassandra/config/Config.java +++ b/src/java/org/apache/cassandra/config/Config.java @@ -56,17 +56,23 @@ public class Config public String authorizer; public String role_manager; public String network_authorizer; - public volatile int permissions_validity_in_ms = 2000; + @Replaces(oldName = "permissions_validity_in_ms", converter = Converters.MILLIS_DURATION, deprecated = true) + public volatile SmallestDurationMilliseconds permissions_validity = new SmallestDurationMilliseconds("2s"); public volatile int permissions_cache_max_entries = 1000; - public volatile int permissions_update_interval_in_ms = -1; + @Replaces(oldName = "permissions_update_interval_in_ms", converter = Converters.MILLIS_CUSTOM_DURATION, deprecated = true) + public volatile SmallestDurationMilliseconds permissions_update_interval = new SmallestDurationMilliseconds("0ms"); public volatile boolean permissions_cache_active_update = false; - public volatile int roles_validity_in_ms = 2000; + @Replaces(oldName = "roles_validity_in_ms", converter = Converters.MILLIS_DURATION, deprecated = true) + public volatile SmallestDurationMilliseconds roles_validity = new SmallestDurationMilliseconds("2s"); public volatile int roles_cache_max_entries = 1000; - public volatile int roles_update_interval_in_ms = -1; + @Replaces(oldName = "roles_update_interval_in_ms", converter = Converters.MILLIS_CUSTOM_DURATION, deprecated = true) + public volatile SmallestDurationMilliseconds roles_update_interval= new SmallestDurationMilliseconds("0ms"); public volatile boolean roles_cache_active_update = false; - public volatile int credentials_validity_in_ms = 2000; + @Replaces(oldName = "credentials_validity_in_ms", converter = Converters.MILLIS_DURATION, deprecated = true) + public volatile SmallestDurationMilliseconds credentials_validity = new SmallestDurationMilliseconds("2s"); public volatile int credentials_cache_max_entries = 1000; - public volatile int credentials_update_interval_in_ms = -1; + @Replaces(oldName = "credentials_update_interval_in_ms", converter = Converters.MILLIS_CUSTOM_DURATION, deprecated = true) + public volatile SmallestDurationMilliseconds credentials_update_interval= new SmallestDurationMilliseconds("0ms"); public volatile boolean credentials_cache_active_update = false; /* Hashing strategy Random or OPHF */ @@ -75,7 +81,8 @@ public class Config public boolean auto_bootstrap = true; public volatile boolean hinted_handoff_enabled = true; public Set<String> hinted_handoff_disabled_datacenters = Sets.newConcurrentHashSet(); - public volatile int max_hint_window_in_ms = 3 * 3600 * 1000; // three hours + @Replaces(oldName = "max_hint_window_in_ms", converter = Converters.MILLIS_DURATION, deprecated = true) + public volatile SmallestDurationMilliseconds max_hint_window = new SmallestDurationMilliseconds("3h"); public String hints_directory; public boolean hint_window_persistent_enabled = true; diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java index 297e619..978a6dd 100644 --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@ -1282,24 +1282,24 @@ public class DatabaseDescriptor public static int getPermissionsValidity() { - return conf.permissions_validity_in_ms; + return conf.permissions_validity.toMillisecondsAsInt(); } public static void setPermissionsValidity(int timeout) { - conf.permissions_validity_in_ms = timeout; + conf.permissions_validity = SmallestDurationMilliseconds.inMilliseconds(timeout); } public static int getPermissionsUpdateInterval() { - return conf.permissions_update_interval_in_ms == -1 - ? conf.permissions_validity_in_ms - : conf.permissions_update_interval_in_ms; + return conf.permissions_update_interval.toMilliseconds() == 0 + ? conf.permissions_validity.toMillisecondsAsInt() + : conf.permissions_update_interval.toMillisecondsAsInt(); } public static void setPermissionsUpdateInterval(int updateInterval) { - conf.permissions_update_interval_in_ms = updateInterval; + conf.permissions_update_interval = SmallestDurationMilliseconds.inMilliseconds(updateInterval); } public static int getPermissionsCacheMaxEntries() @@ -1324,19 +1324,19 @@ public class DatabaseDescriptor public static int getRolesValidity() { - return conf.roles_validity_in_ms; + return conf.roles_validity.toMillisecondsAsInt(); } public static void setRolesValidity(int validity) { - conf.roles_validity_in_ms = validity; + conf.roles_validity = SmallestDurationMilliseconds.inMilliseconds(validity); } public static int getRolesUpdateInterval() { - return conf.roles_update_interval_in_ms == -1 - ? conf.roles_validity_in_ms - : conf.roles_update_interval_in_ms; + return conf.roles_update_interval.toMillisecondsAsInt() == 0 + ? conf.roles_validity.toMillisecondsAsInt() + : conf.roles_update_interval.toMillisecondsAsInt(); } public static void setRolesCacheActiveUpdate(boolean update) @@ -1351,7 +1351,7 @@ public class DatabaseDescriptor public static void setRolesUpdateInterval(int interval) { - conf.roles_update_interval_in_ms = interval; + conf.roles_update_interval = SmallestDurationMilliseconds.inMilliseconds(interval); } public static int getRolesCacheMaxEntries() @@ -1366,24 +1366,24 @@ public class DatabaseDescriptor public static int getCredentialsValidity() { - return conf.credentials_validity_in_ms; + return conf.credentials_validity.toMillisecondsAsInt(); } public static void setCredentialsValidity(int timeout) { - conf.credentials_validity_in_ms = timeout; + conf.credentials_validity = SmallestDurationMilliseconds.inMilliseconds(timeout); } public static int getCredentialsUpdateInterval() { - return conf.credentials_update_interval_in_ms == -1 - ? conf.credentials_validity_in_ms - : conf.credentials_update_interval_in_ms; + return conf.credentials_update_interval.toMillisecondsAsInt() == 0 + ? conf.credentials_validity.toMillisecondsAsInt() + : conf.credentials_update_interval.toMillisecondsAsInt(); } public static void setCredentialsUpdateInterval(int updateInterval) { - conf.credentials_update_interval_in_ms = updateInterval; + conf.credentials_update_interval = SmallestDurationMilliseconds.inMilliseconds(updateInterval); } public static int getCredentialsCacheMaxEntries() @@ -2618,12 +2618,12 @@ public class DatabaseDescriptor public static void setMaxHintWindow(int ms) { - conf.max_hint_window_in_ms = ms; + conf.max_hint_window = SmallestDurationMilliseconds.inMilliseconds(ms); } public static int getMaxHintWindow() { - return conf.max_hint_window_in_ms; + return conf.max_hint_window.toMillisecondsAsInt(); } public static File getHintsDirectory() diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index 9d6a295..4be4fcf 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -940,7 +940,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE { //only go into hibernate state if replacing the same address (CASSANDRA-8523) logger.warn("Writes will not be forwarded to this node during replacement because it has the same address as " + - "the node to be replaced ({}). If the previous node has been down for longer than max_hint_window_in_ms, " + + "the node to be replaced ({}). If the previous node has been down for longer than max_hint_window, " + "repair must be run after the replacement process in order to make this node consistent.", DatabaseDescriptor.getReplaceAddress()); appStates.put(ApplicationState.STATUS_WITH_PORT, valueFactory.hibernate(true)); diff --git a/test/distributed/org/apache/cassandra/distributed/test/BootstrapBinaryDisabledTest.java b/test/distributed/org/apache/cassandra/distributed/test/BootstrapBinaryDisabledTest.java index 55b6c86..3f50c30 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/BootstrapBinaryDisabledTest.java +++ b/test/distributed/org/apache/cassandra/distributed/test/BootstrapBinaryDisabledTest.java @@ -50,8 +50,8 @@ public class BootstrapBinaryDisabledTest extends TestBaseImpl config.put("authenticator", "org.apache.cassandra.auth.PasswordAuthenticator"); config.put("authorizer", "org.apache.cassandra.auth.CassandraAuthorizer"); config.put("role_manager", "org.apache.cassandra.auth.CassandraRoleManager"); - config.put("permissions_validity_in_ms", 0); - config.put("roles_validity_in_ms", 0); + config.put("permissions_validity", "0ms"); + config.put("roles_validity", "0ms"); int originalNodeCount = 1; int expandedNodeCount = originalNodeCount + 2; diff --git a/test/unit/org/apache/cassandra/db/virtual/CredentialsCacheKeysTableTest.java b/test/unit/org/apache/cassandra/db/virtual/CredentialsCacheKeysTableTest.java index 7039563..ad28c13 100644 --- a/test/unit/org/apache/cassandra/db/virtual/CredentialsCacheKeysTableTest.java +++ b/test/unit/org/apache/cassandra/db/virtual/CredentialsCacheKeysTableTest.java @@ -73,7 +73,7 @@ public class CredentialsCacheKeysTableTest extends CQLTester @AfterClass public static void tearDownClass() { - DatabaseDescriptor.setCredentialsValidity(DatabaseDescriptor.getRawConfig().credentials_validity_in_ms); + DatabaseDescriptor.setCredentialsValidity(DatabaseDescriptor.getRawConfig().credentials_validity.toMillisecondsAsInt()); } @Test diff --git a/test/unit/org/apache/cassandra/db/virtual/JmxPermissionsCacheKeysTableTest.java b/test/unit/org/apache/cassandra/db/virtual/JmxPermissionsCacheKeysTableTest.java index 0f16df2..f670fbd 100644 --- a/test/unit/org/apache/cassandra/db/virtual/JmxPermissionsCacheKeysTableTest.java +++ b/test/unit/org/apache/cassandra/db/virtual/JmxPermissionsCacheKeysTableTest.java @@ -94,7 +94,7 @@ public class JmxPermissionsCacheKeysTableTest extends CQLTester @AfterClass public static void tearDownClass() { - DatabaseDescriptor.setPermissionsValidity(DatabaseDescriptor.getRawConfig().permissions_validity_in_ms); + DatabaseDescriptor.setPermissionsValidity(DatabaseDescriptor.getRawConfig().permissions_validity.toMillisecondsAsInt()); } @Test diff --git a/test/unit/org/apache/cassandra/db/virtual/NetworkPermissionsCacheKeysTableTest.java b/test/unit/org/apache/cassandra/db/virtual/NetworkPermissionsCacheKeysTableTest.java index b8e7617..8f7f82b 100644 --- a/test/unit/org/apache/cassandra/db/virtual/NetworkPermissionsCacheKeysTableTest.java +++ b/test/unit/org/apache/cassandra/db/virtual/NetworkPermissionsCacheKeysTableTest.java @@ -74,7 +74,7 @@ public class NetworkPermissionsCacheKeysTableTest extends CQLTester @AfterClass public static void tearDownClass() { - DatabaseDescriptor.setPermissionsValidity(DatabaseDescriptor.getRawConfig().permissions_validity_in_ms); + DatabaseDescriptor.setPermissionsValidity(DatabaseDescriptor.getRawConfig().permissions_validity.toMillisecondsAsInt()); } @Test diff --git a/test/unit/org/apache/cassandra/db/virtual/PermissionsCacheKeysTableTest.java b/test/unit/org/apache/cassandra/db/virtual/PermissionsCacheKeysTableTest.java index 699dd66..1bfbb0b 100644 --- a/test/unit/org/apache/cassandra/db/virtual/PermissionsCacheKeysTableTest.java +++ b/test/unit/org/apache/cassandra/db/virtual/PermissionsCacheKeysTableTest.java @@ -89,7 +89,7 @@ public class PermissionsCacheKeysTableTest extends CQLTester @AfterClass public static void tearDownClass() { - DatabaseDescriptor.setPermissionsValidity(DatabaseDescriptor.getRawConfig().permissions_validity_in_ms); + DatabaseDescriptor.setPermissionsValidity(DatabaseDescriptor.getRawConfig().permissions_validity.toMillisecondsAsInt()); } @Test diff --git a/test/unit/org/apache/cassandra/db/virtual/RolesCacheKeysTableTest.java b/test/unit/org/apache/cassandra/db/virtual/RolesCacheKeysTableTest.java index 5a4ccf2..6e5131d 100644 --- a/test/unit/org/apache/cassandra/db/virtual/RolesCacheKeysTableTest.java +++ b/test/unit/org/apache/cassandra/db/virtual/RolesCacheKeysTableTest.java @@ -74,7 +74,7 @@ public class RolesCacheKeysTableTest extends CQLTester @AfterClass public static void tearDownClass() { - DatabaseDescriptor.setRolesValidity(DatabaseDescriptor.getRawConfig().roles_validity_in_ms); + DatabaseDescriptor.setRolesValidity(DatabaseDescriptor.getRawConfig().roles_validity.toMillisecondsAsInt()); } @Test --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org