Skip to content

Commit b75ced1

Browse files
committed
HADOOP-17836. Improve logging on ABFS error reporting (apache#3281)
Contributed by Steve Loughran.
1 parent e12bc4e commit b75ced1

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/contracts/exceptions/InvalidAbfsRestOperationException.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
import org.apache.hadoop.fs.azurebfs.contracts.services.AzureServiceErrorCode;
2525

2626
/**
27-
* Exception to wrap invalid Azure service error responses.
27+
* Exception to wrap invalid Azure service error responses and exceptions
28+
* raised on network IO.
2829
*/
2930
@InterfaceAudience.Public
3031
@InterfaceStability.Evolving
@@ -34,7 +35,9 @@ public InvalidAbfsRestOperationException(
3435
super(
3536
AzureServiceErrorCode.UNKNOWN.getStatusCode(),
3637
AzureServiceErrorCode.UNKNOWN.getErrorCode(),
37-
"InvalidAbfsRestOperationException",
38+
innerException != null
39+
? innerException.toString()
40+
: "InvalidAbfsRestOperationException",
3841
innerException);
3942
}
4043
}

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsHttpOperation.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,9 @@ public void processResponse(final byte[] buffer, final int offset, final int len
409409
}
410410
}
411411
} catch (IOException ex) {
412-
LOG.error("UnexpectedError: ", ex);
412+
LOG.warn("IO/Network error: {} {}: {}",
413+
method, getMaskedUrl(), ex.getMessage());
414+
LOG.debug("IO Error: ", ex);
413415
throw ex;
414416
} finally {
415417
if (this.isTraceEnabled) {

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsRestOperation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,15 @@ private boolean executeHttpOperation(final int retryCount,
303303
} catch (UnknownHostException ex) {
304304
String hostname = null;
305305
hostname = httpOperation.getHost();
306-
LOG.warn("Unknown host name: %s. Retrying to resolve the host name...",
306+
LOG.warn("Unknown host name: {}. Retrying to resolve the host name...",
307307
hostname);
308308
if (!client.getRetryPolicy().shouldRetry(retryCount, -1)) {
309309
throw new InvalidAbfsRestOperationException(ex);
310310
}
311311
return false;
312312
} catch (IOException ex) {
313313
if (LOG.isDebugEnabled()) {
314-
LOG.debug("HttpRequestFailure: {}, {}", httpOperation.toString(), ex);
314+
LOG.debug("HttpRequestFailure: {}, {}", httpOperation, ex);
315315
}
316316

317317
if (!client.getRetryPolicy().shouldRetry(retryCount, -1)) {
@@ -323,7 +323,7 @@ private boolean executeHttpOperation(final int retryCount,
323323
intercept.updateMetrics(operationType, httpOperation);
324324
}
325325

326-
LOG.debug("HttpRequest: {}: {}", operationType, httpOperation.toString());
326+
LOG.debug("HttpRequest: {}: {}", operationType, httpOperation);
327327

328328
if (client.getRetryPolicy().shouldRetry(retryCount, httpOperation.getStatusCode())) {
329329
return false;

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/ReadBufferManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ ReadBuffer getNextBlockToRead() throws InterruptedException {
455455
*/
456456
void doneReading(final ReadBuffer buffer, final ReadBufferStatus result, final int bytesActuallyRead) {
457457
if (LOGGER.isTraceEnabled()) {
458-
LOGGER.trace("ReadBufferWorker completed file {} for offset {} bytes {}",
459-
buffer.getStream().getPath(), buffer.getOffset(), bytesActuallyRead);
458+
LOGGER.trace("ReadBufferWorker completed read file {} for offset {} outcome {} bytes {}",
459+
buffer.getStream().getPath(), buffer.getOffset(), result, bytesActuallyRead);
460460
}
461461
synchronized (this) {
462462
// If this buffer has already been purged during

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/ReadBufferWorker.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.IOException;
2222
import java.util.concurrent.CountDownLatch;
2323

24+
import org.apache.hadoop.fs.PathIOException;
2425
import org.apache.hadoop.fs.azurebfs.contracts.services.ReadBufferStatus;
2526

2627
class ReadBufferWorker implements Runnable {
@@ -73,8 +74,11 @@ public void run() {
7374
buffer.getTracingContext());
7475

7576
bufferManager.doneReading(buffer, ReadBufferStatus.AVAILABLE, bytesRead); // post result back to ReadBufferManager
77+
} catch (IOException ex) {
78+
buffer.setErrException(ex);
79+
bufferManager.doneReading(buffer, ReadBufferStatus.READ_FAILED, 0);
7680
} catch (Exception ex) {
77-
buffer.setErrException(new IOException(ex));
81+
buffer.setErrException(new PathIOException(buffer.getStream().getPath(), ex));
7882
bufferManager.doneReading(buffer, ReadBufferStatus.READ_FAILED, 0);
7983
}
8084
}

0 commit comments

Comments
 (0)