saxenapranav commented on code in PR #6314:
URL: https://github.com/apache/hadoop/pull/6314#discussion_r1519521701


##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java:
##########
@@ -716,6 +723,10 @@ public synchronized void close() throws IOException {
     }
   }
 
+  public void sendMetric(TracingContext tracingContextMetric) throws 
AzureBlobFileSystemException {

Review Comment:
   usage has been removed. We can remove it.



##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java:
##########
@@ -1693,6 +1732,121 @@ protected AccessTokenProvider getTokenProvider() {
     return tokenProvider;
   }
 
+  /**
+   * Retrieves a TracingContext object configured for metric tracking.
+   * This method creates a TracingContext object with the validated client 
correlation ID,
+   * the host name of the local machine (or "UnknownHost" if unable to 
determine),
+   * the file system operation type set to GET_ATTR, and additional 
configuration parameters
+   * for metric tracking.
+   * The TracingContext is intended for use in tracking metrics related to 
Azure Blob FileSystem (ABFS) operations.
+   *
+   * @return A TracingContext object configured for metric tracking.
+   */
+  private TracingContext getMetricTracingContext() {
+    String hostName;
+    try {
+      hostName = InetAddress.getLocalHost().getHostName();
+    } catch (UnknownHostException e) {
+      hostName = "UnknownHost";
+    }
+    return new TracingContext(TracingContext.validateClientCorrelationID(
+        abfsConfiguration.getClientCorrelationId()),
+        hostName, FSOperationType.GET_ATTR, true,
+        abfsConfiguration.getTracingHeaderFormat(),
+        null, abfsCounters.toString());
+  }
+
+  /**
+   * Synchronized method to suspend or resume timer.
+   * @param timerFunctionality resume or suspend.
+   * @param timerTask The timertask object.
+   * @return true or false.
+   */
+  synchronized boolean timerOrchestrator(TimerFunctionality timerFunctionality,
+      TimerTask timerTask) {
+    switch (timerFunctionality) {
+    case RESUME:
+      if (metricCollectionStopped.get()) {
+        resumeTimer();
+      }
+      break;
+    case SUSPEND:
+      long now = System.currentTimeMillis();
+      long lastExecutionTime = abfsCounters.getLastExecutionTime().get();
+      if (metricCollectionEnabled && (now - lastExecutionTime >= 
metricAnalysisPeriod)) {
+        timerTask.cancel();
+        timer.purge();
+        metricCollectionStopped.set(true);
+        return true;
+      }
+      break;
+    default:
+      break;
+    }
+    return false;
+  }
+
+  private void resumeTimer() {
+    metricCollectionStopped.set(false);
+    timer.schedule(new TimerTaskImpl(),
+        metricIdlePeriod,
+        metricIdlePeriod);
+  }
+
+  /**
+   * Retrieves the metric URL for the Azure Blob FileSystem (ABFS) instance. 
If the metric URL is not
+   * already set and metric configuration has not been checked, it checks the 
configuration settings
+   * to fetch the metric URL.
+   *
+   * @return The metric URL for ABFS.
+   */
+  private String getMetricUrl() {
+    if (abfsMetricUrl == null && !isMetricConfigurationChecked) {

Review Comment:
   Lets have `abfsMetricUrl` final and initialized in the starting of the client



##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AbfsCountersImpl.java:
##########
@@ -63,6 +67,12 @@ public class AbfsCountersImpl implements AbfsCounters {
 
   private final IOStatisticsStore ioStatisticsStore;
 
+  private AtomicReference<AbfsBackoffMetrics> abfsBackoffMetrics = null;
+
+  private AtomicReference<AbfsReadFooterMetrics> abfsReadFooterMetrics = null;

Review Comment:
   This has been taken care in `AbfsRestOperation.updateBackoffTimeMetrics`



##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java:
##########
@@ -695,11 +698,54 @@ public boolean mkdirs(final Path f, final FsPermission 
permission) throws IOExce
     }
   }
 
+  /**
+   * Retrieves an instance of AzureBlobFileSystem configured for metric 
tracking.
+   * This method checks if an instance of AzureBlobFileSystem for metric 
tracking
+   * has already been created. If not, it initializes a new AzureBlobFileSystem
+   * using the provided metric configuration parameters, including the account 
key and URI.
+   * If the metric URI is not provided, or an exception occurs during 
initialization,
+   * the method returns null.
+   *
+   * @return An instance of AzureBlobFileSystem configured for metric 
tracking, or null if the metric URI is not provided or initialization fails.
+   * @throws IOException If an I/O error occurs during filesystem creation.
+   */
+  public AzureBlobFileSystem getMetricFilesystem() throws IOException {

Review Comment:
   usage has been removed. We can remove it.



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