Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ public void close() throws IOException {
if (abfsApacheHttpClient != null) {
abfsApacheHttpClient.close();
}
if (intercept != null) {
IOUtils.cleanupWithLogger(LOG, intercept);
}
if (tokenProvider instanceof Closeable) {
IOUtils.cleanupWithLogger(LOG,
(Closeable) tokenProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

package org.apache.hadoop.fs.azurebfs.services;

import java.io.Closeable;
import java.io.IOException;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -34,7 +37,7 @@

import static org.apache.hadoop.util.Time.now;

class AbfsClientThrottlingAnalyzer {
class AbfsClientThrottlingAnalyzer implements Closeable {

Check failure on line 40 in hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClientThrottlingAnalyzer.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClientThrottlingAnalyzer.java#L40

blanks: end of line
private static final Logger LOG = LoggerFactory.getLogger(
AbfsClientThrottlingAnalyzer.class);
private static final int MIN_ANALYSIS_PERIOD_MS = 1000;
Expand Down Expand Up @@ -172,6 +175,22 @@
return false;
}

/**
* Closes the throttling analyzer and releases associated resources.
* This method cancels the internal timer and cleans up any pending timer tasks.
* It is safe to call this method multiple times.
*

Check failure on line 182 in hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClientThrottlingAnalyzer.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClientThrottlingAnalyzer.java#L182

blanks: end of line
* @throws IOException if an I/O error occurs during cleanup
*/
@Override
public void close() throws IOException {
if (timer != null) {
timer.cancel();
timer.purge();
timer = null;
}
}

@VisibleForTesting
int getSleepDuration() {
return sleepDuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.hadoop.fs.azurebfs.services;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.concurrent.locks.ReentrantLock;

Expand Down Expand Up @@ -223,4 +224,18 @@
}
return contentLength;
}

Check failure on line 227 in hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClientThrottlingIntercept.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClientThrottlingIntercept.java#L227

blanks: end of line
/**
* Closes the throttling intercept and releases associated resources.
* This method closes both the read and write throttling analyzers.
*/
@Override
public void close() throws IOException {
if (readThrottler != null) {
readThrottler.close();
}
if (writeThrottler != null) {
writeThrottler.close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.apache.hadoop.fs.azurebfs.services;

import java.io.IOException;

/**
* Implementation of {@link AbfsThrottlingIntercept} that does not throttle
* the ABFS process.
Expand All @@ -40,4 +42,12 @@ public void updateMetrics(final AbfsRestOperationType operationType,
public void sendingRequest(final AbfsRestOperationType operationType,
final AbfsCounters abfsCounters) {
}

/**
* No-op implementation of close method.
*/
@Override
public void close() throws IOException {
// No resources to clean up in no-op implementation
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
@InterfaceAudience.Private
@InterfaceStability.Unstable
public interface AbfsThrottlingIntercept {
public interface AbfsThrottlingIntercept extends Closable {

/**
* Updates the metrics for successful and failed read and write operations.
Expand All @@ -47,4 +47,11 @@ void updateMetrics(AbfsRestOperationType operationType,
void sendingRequest(AbfsRestOperationType operationType,
AbfsCounters abfsCounters);

/**
* Closes the throttling intercept and releases associated resources.
* @throws IOException if an I/O error occurs during cleanup
*/
@Override
void close() throws IOException;

}