anmolanmol1234 commented on code in PR #8137:
URL: https://github.com/apache/hadoop/pull/8137#discussion_r2648018584


##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AggregateMetricsManager.java:
##########
@@ -0,0 +1,175 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.fs.azurebfs.services;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.lang3.StringUtils;
+import 
org.apache.hadoop.fs.azurebfs.contracts.exceptions.InvalidConfigurationValueException;
+import org.apache.hadoop.fs.azurebfs.utils.SimpleRateLimiter;
+
+/**
+ * AggregateMetricsManager manages metrics collection and dispatching
+ * for multiple AbfsClients across different accounts.
+ */
+public final class AggregateMetricsManager {
+
+  // Singleton instance of AggregateMetricsManager.
+  private static volatile AggregateMetricsManager instance;
+
+  // Rate limiter to control the rate of dispatching metrics.
+  private static volatile SimpleRateLimiter rateLimiter;

Review Comment:
   rateLimiter is declared as static but is initialized in the constructor 
using permitsPerSecond.
   
   This means the rate limiter ends up being global to the JVM, even though its 
value comes from instance-level configuration. In practice, whichever code 
initializes the manager first decides the rate, and any later calls to get() 
with different values are silently ignored.
   
   This makes the behavior dependent on initialization order, which is hard to 
reason about and can lead to surprising behavior in tests or when multiple ABFS 
clients are created with different configs.



##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AggregateMetricsManager.java:
##########
@@ -0,0 +1,175 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.fs.azurebfs.services;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.lang3.StringUtils;
+import 
org.apache.hadoop.fs.azurebfs.contracts.exceptions.InvalidConfigurationValueException;
+import org.apache.hadoop.fs.azurebfs.utils.SimpleRateLimiter;
+
+/**
+ * AggregateMetricsManager manages metrics collection and dispatching
+ * for multiple AbfsClients across different accounts.
+ */
+public final class AggregateMetricsManager {
+
+  // Singleton instance of AggregateMetricsManager.
+  private static volatile AggregateMetricsManager instance;
+
+  // Rate limiter to control the rate of dispatching metrics.
+  private static volatile SimpleRateLimiter rateLimiter;

Review Comment:
   rateLimiter is declared as static but is initialized in the constructor 
using permitsPerSecond.
   
   This means the rate limiter ends up being global to the JVM, even though its 
value comes from instance-level configuration. In practice, whichever code 
initializes the manager first decides the rate, and any later calls to get() 
with different values are silently ignored.



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