This is an automated email from the ASF dual-hosted git repository.

jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new b1a98eeac83 Add auth for revert replace segment (#16434)
b1a98eeac83 is described below

commit b1a98eeac8361214f50f8cb3cf87b29435572883
Author: Hongkun Xu <[email protected]>
AuthorDate: Tue Jul 29 06:47:02 2025 +0800

    Add auth for revert replace segment (#16434)
---
 .../common/utils/FileUploadDownloadClient.java     | 24 +++++++++++++++++++++-
 .../local/utils/ConsistentDataPushUtils.java       |  3 ++-
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git 
a/pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java
 
b/pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java
index fab48220fd2..543f6c80f74 100644
--- 
a/pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java
+++ 
b/pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java
@@ -517,6 +517,13 @@ public class FileUploadDownloadClient implements 
AutoCloseable {
     return requestBuilder.build();
   }
 
+  private static ClassicHttpRequest getRevertReplaceSegmentRequest(URI uri, 
@Nullable AuthProvider authProvider) {
+    ClassicRequestBuilder requestBuilder = 
ClassicRequestBuilder.post(uri).setVersion(HttpVersion.HTTP_1_1)
+        .setHeader(HttpHeaders.CONTENT_TYPE, HttpClient.JSON_CONTENT_TYPE);
+    
AuthProviderUtils.toRequestHeaders(authProvider).forEach(requestBuilder::addHeader);
+    return requestBuilder.build();
+  }
+
   private static ClassicHttpRequest getSegmentCompletionProtocolRequest(URI 
uri, @Nullable List<Header> headers,
       @Nullable List<NameValuePair> parameters) {
     ClassicRequestBuilder requestBuilder = 
ClassicRequestBuilder.get(uri).setVersion(HttpVersion.HTTP_1_1);
@@ -1174,7 +1181,22 @@ public class FileUploadDownloadClient implements 
AutoCloseable {
    */
   public SimpleHttpResponse revertReplaceSegments(URI uri)
       throws IOException, HttpErrorStatusException {
-    return 
HttpClient.wrapAndThrowHttpException(_httpClient.sendRequest(getRevertReplaceSegmentRequest(uri)));
+    return revertReplaceSegments(uri, null);
+  }
+
+  /**
+   * Revert replace segments with default settings.
+   *
+   * @param uri URI
+   * @param authProvider auth provider
+   * @return Response
+   * @throws IOException
+   * @throws HttpErrorStatusException
+   */
+  public SimpleHttpResponse revertReplaceSegments(URI uri, @Nullable 
AuthProvider authProvider)
+      throws IOException, HttpErrorStatusException {
+    return HttpClient.wrapAndThrowHttpException(_httpClient.sendRequest(
+        getRevertReplaceSegmentRequest(uri, authProvider)));
   }
 
   /**
diff --git 
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/ConsistentDataPushUtils.java
 
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/ConsistentDataPushUtils.java
index 798d839c9eb..f7a07083fc8 100644
--- 
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/ConsistentDataPushUtils.java
+++ 
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/ConsistentDataPushUtils.java
@@ -197,12 +197,13 @@ public class ConsistentDataPushUtils {
     if (uriToLineageEntryIdMap != null) {
       LOGGER.error("Exception when pushing segments. Marking segment lineage 
entry to 'REVERTED'.", exception);
       String rawTableName = spec.getTableSpec().getTableName();
+      AuthProvider authProvider = 
AuthProviderUtils.makeAuthProvider(spec.getAuthToken());
       for (Map.Entry<URI, String> entry : uriToLineageEntryIdMap.entrySet()) {
         String segmentLineageEntryId = entry.getValue();
         try {
           URI uri = 
FileUploadDownloadClient.getRevertReplaceSegmentsURI(entry.getKey(), 
rawTableName,
               TableType.OFFLINE.name(), segmentLineageEntryId, true);
-          SimpleHttpResponse response = 
FILE_UPLOAD_DOWNLOAD_CLIENT.revertReplaceSegments(uri);
+          SimpleHttpResponse response = 
FILE_UPLOAD_DOWNLOAD_CLIENT.revertReplaceSegments(uri, authProvider);
           LOGGER.info("Got response {}: {} while sending revert replace 
segment request for table: {}, uploadURI: {}",
               response.getStatusCode(), response.getResponse(), rawTableName, 
entry.getKey());
         } catch (URISyntaxException | HttpErrorStatusException | IOException 
e) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to