jihaozh commented on a change in pull request #4405: [TE] add a thread pool to 
run preview tasks
URL: https://github.com/apache/incubator-pinot/pull/4405#discussion_r301336943
 
 

 ##########
 File path: 
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
 ##########
 @@ -724,13 +735,18 @@ private Response runPreview(long start, long end,
 
       Preconditions.checkNotNull(detectionConfig);
       DetectionPipeline pipeline = this.loader.from(this.provider, 
detectionConfig, start, end);
-      result = pipeline.run();
-
+      future = this.executor.submit(pipeline::run);
+      result = future.get(PREVIEW_TIMEOUT, TimeUnit.MILLISECONDS);
     } catch (IllegalArgumentException e) {
       return processBadRequestResponse(YamlOperations.PREVIEW.name(), 
YamlOperations.RUNNING.name(), payload, e);
     } catch (InvocationTargetException e) {
       responseMessage.put("message", "Failed to run the preview due to " + 
e.getTargetException().getMessage());
       return Response.serverError().entity(responseMessage).build();
+    } catch (TimeoutException e) {
+      // stop the preview
+      future.cancel(true);
 
 Review comment:
   good idea. updated.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to