Skip to content
Merged
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 @@ -20,14 +20,15 @@

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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -140,6 +144,15 @@ public UploadSegmentCommand setAuthProvider(AuthProvider authProvider) {
return this;
}

public UploadSegmentCommand setTableName(String tableName) {
_tableName = tableName;
return this;
}

public void setTableType(TableType tableType) {
_tableType = tableType;
}

@Override
public boolean execute()
throws Exception {
Expand Down Expand Up @@ -173,10 +186,11 @@ public boolean execute()
}

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.
Expand Down