adoroszlai commented on code in PR #11912:
URL: https://github.com/apache/ozone/pull/11912#discussion_r4445828593
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/reconfig/TestOmReconfiguration.java:
##########
@@ -275,45 +270,43 @@ void keyLifecycleService() throws
ReconfigurationException {
final OzoneManager om = cluster().getOzoneManager();
final KeyLifecycleService service =
om.getKeyManager().getKeyLifecycleService();
final boolean originalEnabled = service.status().getIsEnabled();
- final String originalEnabledValue =
om.getConfiguration().get(OZONE_KEY_LIFECYCLE_SERVICE_ENABLED);
- final String originalInterval =
om.getConfiguration().get(OZONE_KEY_LIFECYCLE_SERVICE_INTERVAL);
- final String originalWorkers =
om.getConfiguration().get(OZONE_KEY_LIFECYCLE_SERVICE_WORKERS);
+ final String originalEnabledValue =
om.getConfiguration().get(Keys.ENABLED);
+ final String originalInterval = om.getConfiguration().get(Keys.INTERVAL);
+ final String originalWorkers = om.getConfiguration().get(Keys.WORKERS);
// All changed properties are applied together once reconfiguration
completes
- getSubject().reconfigureProperty(OZONE_KEY_LIFECYCLE_SERVICE_ENABLED,
String.valueOf(!originalEnabled));
- getSubject().reconfigureProperty(OZONE_KEY_LIFECYCLE_SERVICE_INTERVAL,
"30s");
- getSubject().reconfigureProperty(OZONE_KEY_LIFECYCLE_SERVICE_WORKERS, "3");
- assertEquals("30s",
om.getConfiguration().get(OZONE_KEY_LIFECYCLE_SERVICE_INTERVAL));
- service.reconfigure(om.getConfiguration());
+ getSubject().reconfigureProperty(Keys.ENABLED,
String.valueOf(!originalEnabled));
+ getSubject().reconfigureProperty(Keys.INTERVAL, "30s");
+ getSubject().reconfigureProperty(Keys.WORKERS, "3");
+ assertEquals("30s", om.getConfiguration().get(Keys.INTERVAL));
+ service.reconfigure(om.getKeyLifecycleServiceConfig());
assertEquals(!originalEnabled, service.status().getIsEnabled());
assertEquals(!originalEnabled,
om.getLifecycleServiceStatus().getIsEnabled());
assertEquals(30000, service.getIntervalMillis());
assertEquals(3, service.getExecutorService().getCorePoolSize());
// Invalid values are rejected and the configuration is left unchanged
- assertThrows(ReconfigurationException.class,
- () ->
getSubject().reconfigureProperty(OZONE_KEY_LIFECYCLE_SERVICE_DELETE_BATCH_SIZE,
"0"));
- assertThrows(ReconfigurationException.class,
- () ->
getSubject().reconfigureProperty(OZONE_KEY_LIFECYCLE_SERVICE_INTERVAL, "-1"));
- assertEquals("30s",
om.getConfiguration().get(OZONE_KEY_LIFECYCLE_SERVICE_INTERVAL));
- service.reconfigure(om.getConfiguration());
+ assertThrows(ReconfigurationException.class, () ->
getSubject().reconfigureProperty(Keys.DELETE_BATCH_SIZE, "0"));
+ assertThrows(ReconfigurationException.class, () ->
getSubject().reconfigureProperty(Keys.INTERVAL, "-1"));
+ assertEquals("30s", om.getConfiguration().get(Keys.INTERVAL));
+ service.reconfigure(om.getKeyLifecycleServiceConfig());
assertEquals(30000, service.getIntervalMillis());
// Unset properties fall back to their defaults
- getSubject().reconfigureProperty(OZONE_KEY_LIFECYCLE_SERVICE_ENABLED,
null);
- getSubject().reconfigureProperty(OZONE_KEY_LIFECYCLE_SERVICE_INTERVAL,
null);
- getSubject().reconfigureProperty(OZONE_KEY_LIFECYCLE_SERVICE_WORKERS,
null);
-
assertNull(om.getConfiguration().get(OZONE_KEY_LIFECYCLE_SERVICE_INTERVAL));
- service.reconfigure(om.getConfiguration());
- assertEquals(OZONE_KEY_LIFECYCLE_SERVICE_ENABLED_DEFAULT,
service.status().getIsEnabled());
-
assertEquals(om.getConfiguration().getTimeDuration(OZONE_KEY_LIFECYCLE_SERVICE_INTERVAL,
- OZONE_KEY_LIFECYCLE_SERVICE_INTERVAL_DEFAULT, MILLISECONDS),
service.getIntervalMillis());
- assertEquals(OZONE_KEY_LIFECYCLE_SERVICE_WORKERS_DEFAULT,
service.getExecutorService().getCorePoolSize());
-
- getSubject().reconfigureProperty(OZONE_KEY_LIFECYCLE_SERVICE_ENABLED,
originalEnabledValue);
- getSubject().reconfigureProperty(OZONE_KEY_LIFECYCLE_SERVICE_INTERVAL,
originalInterval);
- getSubject().reconfigureProperty(OZONE_KEY_LIFECYCLE_SERVICE_WORKERS,
originalWorkers);
- service.reconfigure(om.getConfiguration());
+ getSubject().reconfigureProperty(Keys.ENABLED, null);
+ getSubject().reconfigureProperty(Keys.INTERVAL, null);
+ getSubject().reconfigureProperty(Keys.WORKERS, null);
+ assertNull(om.getConfiguration().get(Keys.INTERVAL));
+ service.reconfigure(om.getKeyLifecycleServiceConfig());
+ assertEquals(KeyLifecycleServiceConfig.Defaults.ENABLED,
service.status().getIsEnabled());
Review Comment:
Using `KeyLifecycleServiceConfig.Keys` (similar to
`KeyLifecycleServiceConfig.Defaults`) would read better and prevent classname
conflicts later.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]