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

kharekartik 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 66ed9b7167 Allow uploading realtime segments via CLI (#9861)
66ed9b7167 is described below

commit 66ed9b7167241da15c171d667006a3f00a13734c
Author: Kartik Khare <[email protected]>
AuthorDate: Wed Dec 7 15:03:25 2022 +0530

    Allow uploading realtime segments via CLI (#9861)
    
    * Allow uploading realtime segments via CLI
    
    * use tabletype as seperate param
    
    * Allow setting table type
    
    Co-authored-by: Kartik Khare <[email protected]>
---
 .../tools/admin/command/UploadSegmentCommand.java  | 32 ++++++++++++++++------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git 
a/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/UploadSegmentCommand.java
 
b/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/UploadSegmentCommand.java
index 535bc1e958..c721fc3e01 100644
--- 
a/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/UploadSegmentCommand.java
+++ 
b/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/UploadSegmentCommand.java
@@ -20,14 +20,15 @@ package org.apache.pinot.tools.admin.command;
 
 import com.google.common.base.Preconditions;
 import java.io.File;
+import java.io.FileInputStream;
 import java.net.URI;
-import java.util.Collections;
+import java.util.List;
 import org.apache.commons.io.FileUtils;
-import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.Header;
 import org.apache.pinot.common.utils.FileUploadDownloadClient;
 import org.apache.pinot.common.utils.TarGzCompressionUtils;
-import org.apache.pinot.common.utils.http.HttpClient;
 import org.apache.pinot.spi.auth.AuthProvider;
+import org.apache.pinot.spi.config.table.TableType;
 import org.apache.pinot.spi.utils.CommonConstants;
 import org.apache.pinot.spi.utils.NetUtils;
 import org.apache.pinot.tools.Command;
@@ -70,10 +71,13 @@ public class UploadSegmentCommand extends 
AbstractBaseAdminCommand implements Co
   @CommandLine.Option(names = {"-segmentDir"}, required = true, description = 
"Path to segment directory.")
   private String _segmentDir = null;
 
-  // TODO: make this as a required field once we deprecate the table name from 
segment metadata
-  @CommandLine.Option(names = {"-tableName"}, required = false, description = 
"Table name to upload.")
+  @CommandLine.Option(names = {"-tableName"}, required = false, description = 
"Table name to upload")
   private String _tableName = null;
 
+  @CommandLine.Option(names = {"-tableType"}, required = false,
+      description = "Table type to upload. Can be OFFLINE or REALTIME")
+  private TableType _tableType = TableType.OFFLINE;
+
   @CommandLine.Option(names = {"-help", "-h", "--h", "--help"}, required = 
false, help = true,
       description = "Print this message.")
   private boolean _help = false;
@@ -140,6 +144,15 @@ public class UploadSegmentCommand extends 
AbstractBaseAdminCommand implements Co
     return this;
   }
 
+  public UploadSegmentCommand setTableName(String tableName) {
+    _tableName = tableName;
+    return this;
+  }
+
+  public void setTableType(TableType tableType) {
+    _tableType = tableType;
+  }
+
   @Override
   public boolean execute()
       throws Exception {
@@ -173,10 +186,11 @@ public class UploadSegmentCommand extends 
AbstractBaseAdminCommand implements Co
         }
 
         LOGGER.info("Uploading segment tar file: {}", segmentTarFile);
-        fileUploadDownloadClient.uploadSegment(uploadSegmentHttpURI, 
segmentTarFile.getName(), segmentTarFile,
-            makeAuthHeaders(makeAuthProvider(_authProvider, _authTokenUrl, 
_authToken, _user, _password)),
-            Collections.singletonList(new 
BasicNameValuePair(FileUploadDownloadClient.QueryParameters.TABLE_NAME,
-                _tableName)), HttpClient.DEFAULT_SOCKET_TIMEOUT_MS);
+        List<Header> headerList = makeAuthHeaders(_authProvider);
+
+        FileInputStream fileInputStream = new FileInputStream(segmentTarFile);
+        fileUploadDownloadClient.uploadSegment(uploadSegmentHttpURI, 
segmentTarFile.getName(),
+            fileInputStream, headerList, null, _tableName, _tableType);
       }
     } finally {
       // Delete the temporary working directory.


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

Reply via email to