9aman commented on code in PR #14798:
URL: https://github.com/apache/pinot/pull/14798#discussion_r1932217512


##########
pinot-server/src/main/java/org/apache/pinot/server/api/resources/TablesResource.java:
##########
@@ -955,6 +963,167 @@ public TableLLCSegmentUploadResponse uploadLLCSegmentV2(
     }
   }
 
+  /**
+   * Upload a low level consumer segment to segment store and return the 
segment download url, crc and
+   * other segment metadata. This endpoint is used when segment store copy is 
unavailable for committed
+   * low level consumer segments.
+   * Please note that invocation of this endpoint may cause query performance 
to suffer, since we tar up the segment
+   * to upload it.
+   *
+   * @see <a href="https://tinyurl.com/f63ru4sb></a>
+   * @param realtimeTableNameWithType table name with type.
+   * @param segmentName name of the segment to be uploaded
+   * @param timeoutMs timeout for the segment upload to the deep-store. If 
this is negative, the default timeout
+   *                  would be used.
+   * @return full url where the segment is uploaded, crc, segmentName and 
other segment metadata.
+   * @throws Exception if an error occurred during the segment upload.
+   */
+  @POST
+  
@Path("/segments/{realtimeTableNameWithType}/{segmentName}/uploadLLCSegmentToDeepStore")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Upload a low level consumer segment to segment store 
and return the segment download url,"
+      + "crc and other segment metadata",
+      notes = "Upload a low level consumer segment to segment store and return 
the segment download url, crc "
+          + "and other segment metadata")
+  @ApiResponses(value = {
+      @ApiResponse(code = 200, message = "Success"),
+      @ApiResponse(code = 500, message = "Internal server error", response = 
ErrorInfo.class),
+      @ApiResponse(code = 404, message = "Table or segment not found", 
response = ErrorInfo.class),
+      @ApiResponse(code = 400, message = "Bad request", response = 
ErrorInfo.class)
+  })
+  public String uploadLLCSegmentToDeepStore(
+      @ApiParam(value = "Name of the REALTIME table", required = true) 
@PathParam("realtimeTableNameWithType")
+      String realtimeTableNameWithType,
+      @ApiParam(value = "Name of the segment", required = true) 
@PathParam("segmentName") String segmentName,
+      @QueryParam("uploadTimeoutMs") @DefaultValue("-1") int timeoutMs,
+      @Context HttpHeaders headers)
+      throws Exception {
+    realtimeTableNameWithType = 
DatabaseUtils.translateTableName(realtimeTableNameWithType, headers);
+    LOGGER.info("Received a request to upload low level consumer segment {} 
for table {}", segmentName,
+        realtimeTableNameWithType);
+
+    // Check it's realtime table
+    TableType tableType = 
TableNameBuilder.getTableTypeFromTableName(realtimeTableNameWithType);
+    if (TableType.REALTIME != tableType) {
+      throw new WebApplicationException(
+          String.format("Cannot upload low level consumer segment for a 
non-realtime table: %s",
+              realtimeTableNameWithType), Response.Status.BAD_REQUEST);
+    }
+
+    // Check the segment is low level consumer segment
+    if (!LLCSegmentName.isLLCSegment(segmentName)) {
+      throw new WebApplicationException(String.format("Segment %s is not a low 
level consumer segment", segmentName),
+          Response.Status.BAD_REQUEST);
+    }
+
+    TableDataManager tableDataManager =
+        ServerResourceUtils.checkGetTableDataManager(_serverInstance, 
realtimeTableNameWithType);
+    SegmentDataManager segmentDataManager = 
tableDataManager.acquireSegment(segmentName);
+    if (segmentDataManager == null) {
+      throw new WebApplicationException(
+          String.format("Table %s segment %s does not exist", 
realtimeTableNameWithType, segmentName),
+          Response.Status.NOT_FOUND);
+    }
+    if (!(segmentDataManager instanceof ImmutableSegmentDataManager)) {
+      throw new WebApplicationException(
+          String.format("Table %s segment %s does not exist on the disk", 
realtimeTableNameWithType, segmentName),
+          Response.Status.NOT_FOUND);
+    }
+    ImmutableSegmentDataManager immutableSegmentDataManager = 
(ImmutableSegmentDataManager) segmentDataManager;
+    SegmentMetadataImpl segmentMetadata =
+        (SegmentMetadataImpl) 
immutableSegmentDataManager.getSegment().getSegmentMetadata();
+    SegmentZKMetadata segmentZKMetadata = 
getSegmentZKMetadata(segmentMetadata);

Review Comment:
   Done



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to