[ https://issues.apache.org/jira/browse/GRIFFIN-240?focusedWorklogId=221139&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-221139 ]
ASF GitHub Bot logged work on GRIFFIN-240: ------------------------------------------ Author: ASF GitHub Bot Created on: 01/Apr/19 07:37 Start Date: 01/Apr/19 07:37 Worklog Time Spent: 10m Work Description: RodionGork commented on pull request #489: GRIFFIN-240 Return JobInstanceBean in response to a call Trigger job by id URL: https://github.com/apache/griffin/pull/489#discussion_r270744266 ########## File path: service/src/main/java/org/apache/griffin/core/job/JobServiceImpl.java ########## @@ -666,9 +668,31 @@ public void triggerJobById(Long id) throws SchedulerException { .forJob(jobKey) .startNow() .build(); - scheduler.scheduleJob(trigger); + TriggerKey key = trigger.getKey(); + CountDownLatch latch = new CountDownLatch(1); + String listenerName = "listenerJob_" + jobKey.toString(); + try { + scheduler.getListenerManager().addTriggerListener( + new CountDownTriggerListener(latch, listenerName) + , key::equals); + + scheduler.scheduleJob(trigger); + + try { + latch.await(0, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + LOGGER.warn("CountDownLatch awaiting is interrupted"); + } + List<JobInstanceBean> instanceBeans = instanceRepo.findByTriggerKey(key.toString()); Review comment: We probably can slightly change this API to become properly asynchronous - we can return triggerKey from the `/trigger` request and then client can send further requests with this key to find the instance as in this line. ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 221139) Time Spent: 3h 40m (was: 3.5h) > [Service] Return JobInstance in response to a call Trigger job by id > --------------------------------------------------------------------- > > Key: GRIFFIN-240 > URL: https://issues.apache.org/jira/browse/GRIFFIN-240 > Project: Griffin (Incubating) > Issue Type: Improvement > Reporter: Aleksandr Borgatin > Priority: Major > Time Spent: 3h 40m > Remaining Estimate: 0h > > The proposal is following: in response of method "/jobs/trigger/\{id}" to > return JobInstance > {code:java} > @RequestMapping(value = "/jobs/trigger/{id}", method = RequestMethod.POST) > @ResponseStatus(HttpStatus.OK) > public JobInstanceBean triggerJob(@PathVariable("id") Long id) throws > SchedulerException > { return jobService.triggerJobById(id); }{code} > Now this method looks like this > {code:java} > @RequestMapping(value = "/jobs/trigger/{id}", method = RequestMethod.POST) > @ResponseStatus(HttpStatus.NO_CONTENT) > public void triggerJob(@PathVariable("id") Long id) throws > SchedulerException { > jobService.triggerJobById(id); > } > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)