dgriffon commented on code in PR #636: URL: https://github.com/apache/unomi/pull/636#discussion_r1275756448
########## persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java: ########## @@ -1158,6 +1167,51 @@ protected Boolean execute(Object... args) throws Exception { } } + private void waitForTaskComplete(AbstractBulkByScrollRequest request, TaskSubmissionResponse response) { + if (logger.isDebugEnabled()) { + logger.debug("Waiting task [{}]: [{}] using query: [{}], polling every {}ms with a timeout configured to {}ms", + response.getTask(), request.toString(), request.getSearchRequest().source().query(), taskWaitingPollingInterval, taskWaitingTimeout); + } + long start = System.currentTimeMillis(); + new InClassLoaderExecute<Void>(metricsService, this.getClass().getName() + ".waitForTask", this.bundleContext, this.fatalIllegalStateErrors, throwExceptions) { + protected Void execute(Object... args) throws Exception { + + TaskId taskId = new TaskId(response.getTask()); + while (true){ + Optional<GetTaskResponse> getTaskResponseOptional = client.tasks().get(new GetTaskRequest(taskId.getNodeId(), taskId.getId()), RequestOptions.DEFAULT); + if (getTaskResponseOptional.isPresent()) { + GetTaskResponse getTaskResponse = getTaskResponseOptional.get(); + if (getTaskResponse.isCompleted()) { + long millis = getTaskResponse.getTaskInfo().getRunningTimeNanos() / 1_000_000; + long seconds = millis / 1000; + + logger.info("Waiting task [{}]: Finished in {} {}", taskId, Review Comment: This log should be in debug as we can have that information using the task ID by querying ES. We can also add a debug log at the start of the while(true) clause to get the current execution in case of a trouble for one executing (not finished) task. -- 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: dev-unsubscr...@unomi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org