adoroszlai commented on code in PR #9771:
URL: https://github.com/apache/ozone/pull/9771#discussion_r2811312941


##########
hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/metrics/TestS3GatewayMetrics.java:
##########
@@ -117,6 +117,14 @@ public void setup() throws Exception {
     metrics = bucketEndpoint.getMetrics();
   }
 
+  @Test
+  public void testMetricsCreateIsIdempotent() {
+    S3GatewayMetrics m1 = S3GatewayMetrics.create(new OzoneConfiguration());
+    S3GatewayMetrics m2 = S3GatewayMetrics.create(new OzoneConfiguration());

Review Comment:
   ```
   Error:  
hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/metrics/TestS3GatewayMetrics.java:[122,55]
 cannot find symbol
   Error:    symbol:   class OzoneConfiguration
   Error:    location: class 
org.apache.hadoop.ozone.s3.metrics.TestS3GatewayMetrics
   ```
   
   
https://github.com/vyalamar/ozone/actions/runs/22034226313/job/63664346554#step:16:22



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/metrics/S3GatewayMetrics.java:
##########
@@ -304,12 +304,17 @@ public void close() {
    * @return S3GatewayMetrics
    */
   public static synchronized S3GatewayMetrics create(OzoneConfiguration conf) {
+    if (!conf.getBoolean(S3GatewayConfigKeys.OZONE_S3G_METRICS_ENABLED,
+        S3GatewayConfigKeys.OZONE_S3G_METRICS_ENABLED_DEFAULT)) {

Review Comment:
   Let's cache the result in a `static Boolean` variable.
   
   ```java
   if (metricsEnabled == null) {
     metricsEnabled = conf.getBoolean(...);
   }
   if (!metricsEnabled) {
     return null;
   }
   ```



-- 
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]

Reply via email to