saxenapranav commented on code in PR #6314: URL: https://github.com/apache/hadoop/pull/6314#discussion_r1522432071
########## hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java: ########## @@ -208,6 +240,8 @@ public AbfsClient(final URL baseUrl, final SharedKeyCredentials sharedKeyCredent @Override public void close() throws IOException { + runningTimerTask.cancel(); Review Comment: Lets add a null check in case runningTimerTask is not spawned before client close. ########## hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java: ########## @@ -1693,6 +1734,106 @@ 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) { + this.runningTimerTask = timerTask; Review Comment: lets set `runningTaskTimer` in the constructor of `TimerTask`. Reason being, this method would be called after an initTime given in `timer.schedule`, and client may get closed before it. ########## hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java: ########## @@ -1411,6 +1448,97 @@ protected AccessTokenProvider getTokenProvider() { return tokenProvider; } + public AzureBlobFileSystem getMetricFilesystem() throws IOException { + if (metricFs == null) { + try { + Configuration metricConfig = abfsConfiguration.getRawConfiguration(); + String metricAccountKey = metricConfig.get(FS_AZURE_METRIC_ACCOUNT_KEY); + final String abfsMetricUrl = metricConfig.get(FS_AZURE_METRIC_URI); + if (abfsMetricUrl == null) { + return null; + } + metricConfig.set(FS_AZURE_ACCOUNT_KEY_PROPERTY_NAME, metricAccountKey); + metricConfig.set(AZURE_CREATE_REMOTE_FILESYSTEM_DURING_INITIALIZATION, "false"); + URI metricUri; + metricUri = new URI(FileSystemUriSchemes.ABFS_SCHEME, abfsMetricUrl, null, null, null); + metricFs = (AzureBlobFileSystem) FileSystem.newInstance(metricUri, metricConfig); + } catch (AzureBlobFileSystemException | URISyntaxException ex) { + //do nothing + } + } + return metricFs; + } + + 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, Review Comment: Looks like you have taken comment in `AbfsClientThrottlingAnalyser` :). This comment was more for this PR change, great you have taken at other place as well, but we can think if want that file change in this scope. -- 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: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org