jsinovassin commented on code in PR #697:
URL: https://github.com/apache/unomi/pull/697#discussion_r1793139986
##########
tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/utils/MigrationUtils.java:
##########
@@ -281,6 +283,23 @@ public static void waitForYellowStatus(CloseableHttpClient
httpClient, String es
}
+ public static void waitForTaskToFinish(CloseableHttpClient httpClient,
String esAddress, String taskId, MigrationContext migrationContext) throws
IOException {
+ while (true) {
+ final JSONObject status = new JSONObject(
+ HttpUtils.executeGetRequest(httpClient, esAddress +
"/_tasks/" + taskId + "?wait_for_completion=true&timeout=10s",
+ null));
+ if (status.has("completed") && status.getBoolean("completed")) {
+ migrationContext.printMessage("Task is completed");
+ break;
+ }
+ if (status.has("error")) {
+ final JSONObject error = status.getJSONObject("error");
+ throw new IOException("Task error: " + error.getString("type")
+ " - " + error.getString("reason"));
+ }
+ migrationContext.printMessage("Waiting for Task " + taskId + " to
complete");
Review Comment:
Every 20-30 secondes is a good option I think
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]