DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
HDDS-1469 introduced a new way to use the classic hadoop configuration. Instead of create java constans and xml fragments which are aligned, it's enough to create a well-annotated Java class.
How to use it?
(1) Create a configuration pojo
First of all, you need a class which can hold the configuration values.
- Annotate the class with @ConfigGroup
- Annotate the setters with @Configuration
@ConfigGroup(prefix = "hdds.scm.replication")
public static class ReplicationManagerConfiguration {
/**
* The frequency in which ReplicationMonitor thread should run.
*/
private long interval = 5 * 60 * 1000;
/**
* Timeout for container replication & deletion command issued by
* ReplicationManager.
*/
private long eventTimeout = 10 * 60 * 1000;
@Config(key = "thread.interval",
type = ConfigType.TIME,
defaultValue = "3s",
tags = {SCM, OZONE},
description = "When a heartbeat from the data node arrives on SCM, "
+ "It is queued for processing with the time stamp of when the "
+ "heartbeat arrived. There is a heartbeat processing thread "
+ "inside "
+ "SCM that runs at a specified interval. ...."
)
public void setInterval(long interval) {
this.interval = interval;
}
//....
Note: the final confiuration key will be the concatenation of @ConfigGroup.prefix and the @Config.key strings.
(2) Use the configuration class instead of OzoneConfiguration
You can retrieve your configuration class which is filled with the real configuration values (or defaults) with the help of good old OzoneConfiguration.
conf.getObject(ReplicationManagerConfiguration.class)
Note: It's a good idea to use the more type-safe, meaningful configuration instances instead of the OzoneConfiguration. It helps to understand what variables are used and you don't need to create a real OzoneConfiguration for a real unit test.
replicationManager = new ReplicationManager( conf.getObject(ReplicationManagerConfiguration.class), containerManager, containerPlacementPolicy, eventQueue, new LockManager<>(conf));
How does it work?
The implementation based on two parts:
- An annotation processor generates the ozone-default.xml fragments which was created manually earlier.
- OzoneConfiguration is extended with