9aman commented on code in PR #14920: URL: https://github.com/apache/pinot/pull/14920#discussion_r1938852738
########## pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java: ########## @@ -1274,6 +1275,47 @@ public File downloadUntarFileStreamed(URI uri, File dest, AuthProvider authProvi httpHeaders, maxStreamRateInByte); } + /** + * Invokes the server's reIngestSegment API via a POST request with JSON payload, + * using Simple HTTP APIs. + * + * POST http://[serverURL]/reIngestSegment + * { + * "tableNameWithType": [tableName], + * "segmentName": [segmentName] + * } + */ + public void triggerReIngestion(String serverHostPort, String tableNameWithType, String segmentName) + throws IOException, URISyntaxException, HttpErrorStatusException { + String scheme = HTTP; + if (serverHostPort.contains(HTTPS)) { + scheme = HTTPS; + serverHostPort = serverHostPort.replace(HTTPS + "://", ""); + } else if (serverHostPort.contains(HTTP)) { + serverHostPort = serverHostPort.replace(HTTP + "://", ""); + } + + String serverHost = serverHostPort.split(":")[0]; + String serverPort = serverHostPort.split(":")[1]; + + URI reIngestUri = getURI(scheme, serverHost, Integer.parseInt(serverPort), REINGEST_SEGMENT_PATH); + + Map<String, Object> requestJson = new HashMap<>(); + requestJson.put("tableNameWithType", tableNameWithType); + requestJson.put("segmentName", segmentName); + + String jsonPayload = JsonUtils.objectToString(requestJson); + SimpleHttpResponse response = + HttpClient.wrapAndThrowHttpException(_httpClient.sendJsonPostRequest(reIngestUri, jsonPayload)); + + // Check that we got a 2xx response + int statusCode = response.getStatusCode(); + if (statusCode / 100 != 2) { + throw new IOException(String.format("Failed POST to %s, HTTP %d: %s", Review Comment: The above `HttpClient.wrapAndThrowHttpException` would throw an exception and this won't be printed in case of `status codes >= 300`. Either we can catch it here to print the log or print it in the calling function. -- 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