dgriffon commented on code in PR #636:
URL: https://github.com/apache/unomi/pull/636#discussion_r1275176420


##########
persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java:
##########
@@ -1158,6 +1157,45 @@ protected Boolean execute(Object... args) throws 
Exception {
         }
     }
 
+    private void startTaskTracker(AbstractBulkByScrollRequest request, 
TaskSubmissionResponse response) {
+        logger.info("Start tracking submitted task: [{}]. See debug log level 
for more information", response.getTask());
+        if (logger.isDebugEnabled()) {
+            logger.debug("Tracking task [{}]: [{}] using query: [{}]", 
response.getTask(), request.toString(), 
request.getSearchRequest().source().query());
+        }
+        new InClassLoaderExecute<Void>(metricsService, 
this.getClass().getName() + ".taskTracker", 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("Tracking task [{}]: Finished in {} 
{}", taskId,
+                                    seconds >= 1 ? seconds : millis,
+                                    seconds >= 1 ? "seconds" : "milliseconds");
+                            break;
+                        } else {
+                            try {
+                                Thread.sleep(1000);

Review Comment:
   Do we want to make it configurable? 



-- 
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

Reply via email to