Skip to content

Commit

Permalink
refactoring file upload download client
Browse files Browse the repository at this point in the history
  • Loading branch information
KKCorps committed Jan 17, 2025
1 parent c836009 commit 7974ab9
Showing 1 changed file with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1301,25 +1301,13 @@ public void triggerReIngestion(String serverHostPort, String tableNameWithType,

URI reIngestUri = getURI(scheme, serverHost, Integer.parseInt(serverPort), REINGEST_SEGMENT_PATH);

// Build the JSON payload
Map<String, Object> requestJson = new HashMap<>();
requestJson.put("tableNameWithType", tableNameWithType);
requestJson.put("segmentName", segmentName);

// Convert the request payload to JSON string
String jsonPayload = JsonUtils.objectToString(requestJson);
// Prepare a POST request with Simple HTTP
ClassicRequestBuilder requestBuilder = ClassicRequestBuilder
.post(reIngestUri)
.setVersion(HttpVersion.HTTP_1_1)
.setHeader("Content-Type", "application/json")
.setHeader("Accept", "application/json")
.setEntity(new StringEntity(jsonPayload, ContentType.APPLICATION_JSON));

// Send the request using your custom HttpClient wrapper.
// (Adjust the timeout as needed in your environment)
SimpleHttpResponse response = HttpClient.wrapAndThrowHttpException(
_httpClient.sendRequest(requestBuilder.build(), HttpClient.DEFAULT_SOCKET_TIMEOUT_MS));
SimpleHttpResponse response =
HttpClient.wrapAndThrowHttpException(_httpClient.sendJsonPostRequest(reIngestUri, jsonPayload));

// Check that we got a 2xx response
int statusCode = response.getStatusCode();
Expand Down

0 comments on commit 7974ab9

Please sign in to comment.