Skip to content

Commit c610262

Browse files
committed
Allow moveToFinalLocation in METADATA push based on config
1 parent 07b3ee6 commit c610262

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public static class CustomHeaders {
7373
public static final String UPLOAD_TYPE = "UPLOAD_TYPE";
7474
public static final String REFRESH_ONLY = "REFRESH_ONLY";
7575
public static final String DOWNLOAD_URI = "DOWNLOAD_URI";
76+
77+
public static final String MOVE_SEGMENT_TO_DEEP_STORE = "MOVE_SEGMENT_TO_DEEP_STORE";
7678
public static final String SEGMENT_ZK_METADATA_CUSTOM_MAP_MODIFIER = "Pinot-SegmentZKMetadataCustomMapModifier";
7779
public static final String CRYPTER = "CRYPTER";
7880
}

pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentUploadDownloadRestletResource.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,15 @@ private SuccessResponse uploadSegment(@Nullable String tableName, TableType tabl
256256
throw new ControllerApplicationException(LOGGER, "Download URI is required for METADATA upload mode",
257257
Response.Status.BAD_REQUEST);
258258
}
259-
moveSegmentToFinalLocation = false;
259+
// override moveSegmentToFinalLocation if override provided in headers:moveSegmentToDeepStore
260+
// else set to false for backward compatibility
261+
String moveSegmentToDeepStore =
262+
extractHttpHeader(headers, FileUploadDownloadClient.CustomHeaders.MOVE_SEGMENT_TO_DEEP_STORE);
263+
if (moveSegmentToDeepStore != null) {
264+
moveSegmentToFinalLocation = Boolean.parseBoolean(moveSegmentToDeepStore);
265+
} else {
266+
moveSegmentToFinalLocation = false;
267+
}
260268
createSegmentFileFromMultipart(multiPart, destFile);
261269
try {
262270
URI segmentURI = new URI(downloadURI);

pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/SegmentPushUtils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ public static void sendSegmentUriAndMetadata(SegmentGenerationJobSpec spec, Pino
264264
headers.add(new BasicHeader(FileUploadDownloadClient.CustomHeaders.DOWNLOAD_URI, segmentUriPath));
265265
headers.add(new BasicHeader(FileUploadDownloadClient.CustomHeaders.UPLOAD_TYPE,
266266
FileUploadDownloadClient.FileUploadType.METADATA.toString()));
267+
if (spec.getPushJobSpec() != null) {
268+
headers.add(new BasicHeader(FileUploadDownloadClient.CustomHeaders.MOVE_SEGMENT_TO_DEEP_STORE,
269+
String.valueOf(spec.getPushJobSpec().getMoveToDeepStoreForMetadataPush())));
270+
}
267271
headers.addAll(AuthProviderUtils.toRequestHeaders(authProvider));
268272

269273
SimpleHttpResponse response = FILE_UPLOAD_DOWNLOAD_CLIENT

pinot-spi/src/main/java/org/apache/pinot/spi/ingestion/batch/spec/PushJobSpec.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public class PushJobSpec implements Serializable {
4141
*/
4242
private long _pushRetryIntervalMillis = 1000;
4343

44+
/**
45+
* Applicable for URI and METADATA push types.
46+
* If true, and if segment was not already in the deep store, move it to deep store.
47+
*/
48+
private boolean _moveToDeepStoreForMetadataPush;
4449
/**
4550
* Used in SegmentUriPushJobRunner, which is used to composite the segment uri to send to pinot controller.
4651
* The URI sends to controller is in the format ${segmentUriPrefix}${segmentPath}${segmentUriSuffix}
@@ -121,4 +126,12 @@ public int getPushParallelism() {
121126
public void setPushParallelism(int pushParallelism) {
122127
_pushParallelism = pushParallelism;
123128
}
129+
130+
public boolean getMoveToDeepStoreForMetadataPush() {
131+
return _moveToDeepStoreForMetadataPush;
132+
}
133+
134+
public void setMoveToDeepStoreForMetadataPush(boolean moveToDeepStoreForMetadataPush) {
135+
_moveToDeepStoreForMetadataPush = moveToDeepStoreForMetadataPush;
136+
}
124137
}

0 commit comments

Comments
 (0)