anujmodi2021 commented on code in PR #8050:
URL: https://github.com/apache/hadoop/pull/8050#discussion_r2485181185


##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/ReadBufferManagerV1.java:
##########
@@ -127,7 +127,7 @@ public void queueReadAhead(final AbfsInputStream stream, 
final long requestedOff
       buffer.setRequestedLength(requestedLength);
       buffer.setStatus(ReadBufferStatus.NOT_AVAILABLE);
       buffer.setLatch(new CountDownLatch(1));
-      buffer.setTracingContext(tracingContext);
+      buffer.setTracingContext(new TracingContext(tracingContext));

Review Comment:
   Why this change is needed?
   If its needed, it should now be done in RBMV2 as well.



##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/TestAbfsInputStream.java:
##########
@@ -104,6 +112,9 @@ public class TestAbfsInputStream extends
   private static final int POSITION_INDEX = 9;
   private static final int OPERATION_INDEX = 6;
   private static final int READTYPE_INDEX = 11;
+  private static final String PREFETCH_TRAFFIC_PRIORITY_HEADER = 
"x-ms-request-priority";
+  private static final String PREFETCH_TRAFFIC_PRIORITY_HEADER_VALUE = "7";

Review Comment:
   Request Priority 7 can be used for other requests as well in future. When 
creating constants for this, keep it general.



##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsInputStream.java:
##########
@@ -590,7 +590,7 @@ int readRemote(long position, byte[] b, int offset, int 
length, TracingContext t
       tracingContext.setPosition(String.valueOf(position));
       op = client.read(path, position, b, offset, length,
           tolerateOobAppends ? "*" : eTag, cachedSasToken.get(),
-          contextEncryptionAdapter, tracingContext);
+          contextEncryptionAdapter, new TracingContext(tracingContext));

Review Comment:
   +1



##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/TestAbfsInputStream.java:
##########
@@ -896,6 +907,90 @@ private void 
testReadTypeInTracingContextHeaderInternal(AzureBlobFileSystem fs,
     assertReadTypeInClientRequestId(fs, numOfReadCalls, totalReadCalls, 
readType);
   }
 
+  /*
+   * Test to verify that both conditions of prefetch read and respective config
+   * enabled needs to be true for the priority header to be added
+   */
+  @Test
+  public void testPrefetchReadAddsPriorityHeaderWithDifferentConfigs()
+      throws Exception {
+    Configuration configuration1 = new Configuration(getRawConfiguration());
+    configuration1.set(FS_AZURE_ENABLE_REQUEST_PRIORITY_FOR_PREFETCH, "true");
+
+    Configuration configuration2 = new Configuration(getRawConfiguration());
+    //use the default value for the config: false
+    configuration2.unset(FS_AZURE_ENABLE_REQUEST_PRIORITY_FOR_PREFETCH);
+
+    TracingContext tracingContext1 = mock(TracingContext.class);
+    when(tracingContext1.getReadType()).thenReturn(PREFETCH_READ);
+
+    //Prefetch Read with config enabled
+    executePrefetchReadTest(tracingContext1, configuration1, true);
+    //Prefetch Read with config disabled
+    executePrefetchReadTest(tracingContext1, configuration2, false);
+
+    when(tracingContext1.getReadType()).thenReturn(DIRECT_READ);
+
+    //Non-prefetch read with config disabled
+    executePrefetchReadTest(tracingContext1, configuration2, false);
+    //Non-prefetch read with config enabled
+    executePrefetchReadTest(tracingContext1, configuration1, false);
+  }
+
+  private void executePrefetchReadTest(TracingContext tracingContext,
+      Configuration rawConfig,
+      boolean shouldHaveHeader) throws Exception {
+    AzureBlobFileSystem azureFs = (AzureBlobFileSystem) FileSystem.newInstance(

Review Comment:
   Use try catch for auto-close



##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/TestAbfsInputStream.java:
##########
@@ -104,6 +112,9 @@ public class TestAbfsInputStream extends
   private static final int POSITION_INDEX = 9;
   private static final int OPERATION_INDEX = 6;
   private static final int READTYPE_INDEX = 11;
+  private static final String PREFETCH_TRAFFIC_PRIORITY_HEADER = 
"x-ms-request-priority";
+  private static final String PREFETCH_TRAFFIC_PRIORITY_HEADER_VALUE = "7";

Review Comment:
   This as well



##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/TestAbfsInputStream.java:
##########
@@ -104,6 +112,9 @@ public class TestAbfsInputStream extends
   private static final int POSITION_INDEX = 9;
   private static final int OPERATION_INDEX = 6;
   private static final int READTYPE_INDEX = 11;
+  private static final String PREFETCH_TRAFFIC_PRIORITY_HEADER = 
"x-ms-request-priority";

Review Comment:
   +1



##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/utils/TracingContext.java:
##########
@@ -389,4 +389,11 @@ public void setReadType(ReadType readType) {
       listener.updateReadType(readType);
     }
   }
+
+  /**
+   * Returns the read type for the current operation.
+   */
+  public ReadType getReadType() {

Review Comment:
   If possible, keep it package protected



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