jkevan commented on code in PR #636: URL: https://github.com/apache/unomi/pull/636#discussion_r1276002434
########## 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: thx for the review, I will move this log to debug. But I'm not sure for adding a log each execution, a soon as we have the info on the task started we can track it in ES side, and logging every 1sec will make this difficult to read. -- 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