HDDS-12133. Define replication metrics task names and descriptions as constants to reuse in CommandHandler#9215
Conversation
… constants to reuse in CommandHandler
|
@yandrey321 please take a look at it |
|
|
||
| public String getMetricsName() { | ||
| return this.metricsName; | ||
| return ECReconstructionCoordinatorTask.METRIC_NAME; |
| public int getQueuedCount() { | ||
| return this.metricsName == null ? 0 : (int) this.supervisor | ||
| .getReplicationQueuedCount(metricsName); | ||
| return (int) this.supervisor.getReplicationQueuedCount(ReconcileContainerTask.METRIC_NAME); |
There was a problem hiding this comment.
why specific task type is hardcoded here instead of task.getMetricName() ?
There was a problem hiding this comment.
This PR replaces the previous approach where handlers needed a task instance to call task.getMetricName(). Instead, I am using static constants from the task classes (TaskClass.METRIC_NAME) so handlers can get metric names without requiring a task instance or null checks. The constants are defined once in each task class and referenced by their respective handlers, eliminating the null checks.
sarvekshayr
left a comment
There was a problem hiding this comment.
Thanks for working on this @sreejasahithi.
Below tests still use hardcoded strings instead of referencing the constants:
TestReconcileContainerCommandHandlerTestReconstructECContainersCommandHandlerTestReplicateContainerCommandHandler
...oop/ozone/container/common/statemachine/commandhandler/ReconcileContainerCommandHandler.java
Outdated
Show resolved
Hide resolved
...zone/container/common/statemachine/commandhandler/ReconstructECContainersCommandHandler.java
Outdated
Show resolved
Hide resolved
...oop/ozone/container/common/statemachine/commandhandler/ReplicateContainerCommandHandler.java
Show resolved
Hide resolved
sadanand48
left a comment
There was a problem hiding this comment.
Thanks @sreejasahithi for the patch, LGTM overall. pending green CI
|
Thanks @sreejasahithi for the contribution , @sarvekshayr , @yandrey321 for the reviews |
What changes were proposed in this pull request?
Currently the commands that go through the replication supervisor are getting the name of the metrics from the task to retrieve from the supervisor, and this may be null if no task has been submitted yet. This results in many null checks in the code.
To solve this the the metrics name and description can be defined as static constants by the task so they can be retrieved directly without null checks.
What is the link to the Apache JIRA
HDDS-12133
How was this patch tested?
Green CI : https://github.com/sreejasahithi/ozone/actions/runs/18874231291