@Test void testExecuteScheduledJobUnknownJob() { String scheduledJobId = "UnknownScheduledJobId"; assertThrows( UnknownEntityException.class, () -> jobExecutor.executeScheduledJob(scheduledJobId)); }
@RunAsSystem public void executeScheduledJob(String scheduledJobId) { ScheduledJob scheduledJob = dataService.findOneById(SCHEDULED_JOB, scheduledJobId, ScheduledJob.class); if (scheduledJob == null) { throw new UnknownEntityException(SCHEDULED_JOB, scheduledJobId); } JobExecution jobExecution = createJobExecution(scheduledJob); Job molgenisJob = saveExecutionAndCreateJob(jobExecution); Progress progress = jobExecutionRegistry.registerJobExecution(jobExecution); try { long callingThreadId = Thread.currentThread().getId(); runJob(jobExecution, molgenisJob, progress, callingThreadId); } catch (Exception ex) { handleJobException(jobExecution, ex); } finally { jobExecutionRegistry.unregisterJobExecution(jobExecution); } }
JobExecutor { @RunAsSystem public void executeScheduledJob(String scheduledJobId) { ScheduledJob scheduledJob = dataService.findOneById(SCHEDULED_JOB, scheduledJobId, ScheduledJob.class); if (scheduledJob == null) { throw new UnknownEntityException(SCHEDULED_JOB, scheduledJobId); } JobExecution jobExecution = createJobExecution(scheduledJob); Job molgenisJob = saveExecutionAndCreateJob(jobExecution); Progress progress = jobExecutionRegistry.registerJobExecution(jobExecution); try { long callingThreadId = Thread.currentThread().getId(); runJob(jobExecution, molgenisJob, progress, callingThreadId); } catch (Exception ex) { handleJobException(jobExecution, ex); } finally { jobExecutionRegistry.unregisterJobExecution(jobExecution); } } }
JobExecutor { @RunAsSystem public void executeScheduledJob(String scheduledJobId) { ScheduledJob scheduledJob = dataService.findOneById(SCHEDULED_JOB, scheduledJobId, ScheduledJob.class); if (scheduledJob == null) { throw new UnknownEntityException(SCHEDULED_JOB, scheduledJobId); } JobExecution jobExecution = createJobExecution(scheduledJob); Job molgenisJob = saveExecutionAndCreateJob(jobExecution); Progress progress = jobExecutionRegistry.registerJobExecution(jobExecution); try { long callingThreadId = Thread.currentThread().getId(); runJob(jobExecution, molgenisJob, progress, callingThreadId); } catch (Exception ex) { handleJobException(jobExecution, ex); } finally { jobExecutionRegistry.unregisterJobExecution(jobExecution); } } JobExecutor(
      DataService dataService,
      EntityManager entityManager,
      ExecutorService executorService,
      JobFactoryRegistry jobFactoryRegistry,
      JobExecutionContextFactory jobExecutionContextFactory,
      JobExecutionRegistry jobExecutionRegistry); }
JobExecutor { @RunAsSystem public void executeScheduledJob(String scheduledJobId) { ScheduledJob scheduledJob = dataService.findOneById(SCHEDULED_JOB, scheduledJobId, ScheduledJob.class); if (scheduledJob == null) { throw new UnknownEntityException(SCHEDULED_JOB, scheduledJobId); } JobExecution jobExecution = createJobExecution(scheduledJob); Job molgenisJob = saveExecutionAndCreateJob(jobExecution); Progress progress = jobExecutionRegistry.registerJobExecution(jobExecution); try { long callingThreadId = Thread.currentThread().getId(); runJob(jobExecution, molgenisJob, progress, callingThreadId); } catch (Exception ex) { handleJobException(jobExecution, ex); } finally { jobExecutionRegistry.unregisterJobExecution(jobExecution); } } JobExecutor(
      DataService dataService,
      EntityManager entityManager,
      ExecutorService executorService,
      JobFactoryRegistry jobFactoryRegistry,
      JobExecutionContextFactory jobExecutionContextFactory,
      JobExecutionRegistry jobExecutionRegistry); @RunAsSystem void executeScheduledJob(String scheduledJobId); CompletableFuture<Void> submit(JobExecution jobExecution); CompletableFuture<Void> submit(
      JobExecution jobExecution, ExecutorService executorService); void cancel(JobExecution jobExecution); }
JobExecutor { @RunAsSystem public void executeScheduledJob(String scheduledJobId) { ScheduledJob scheduledJob = dataService.findOneById(SCHEDULED_JOB, scheduledJobId, ScheduledJob.class); if (scheduledJob == null) { throw new UnknownEntityException(SCHEDULED_JOB, scheduledJobId); } JobExecution jobExecution = createJobExecution(scheduledJob); Job molgenisJob = saveExecutionAndCreateJob(jobExecution); Progress progress = jobExecutionRegistry.registerJobExecution(jobExecution); try { long callingThreadId = Thread.currentThread().getId(); runJob(jobExecution, molgenisJob, progress, callingThreadId); } catch (Exception ex) { handleJobException(jobExecution, ex); } finally { jobExecutionRegistry.unregisterJobExecution(jobExecution); } } JobExecutor(
      DataService dataService,
      EntityManager entityManager,
      ExecutorService executorService,
      JobFactoryRegistry jobFactoryRegistry,
      JobExecutionContextFactory jobExecutionContextFactory,
      JobExecutionRegistry jobExecutionRegistry); @RunAsSystem void executeScheduledJob(String scheduledJobId); CompletableFuture<Void> submit(JobExecution jobExecution); CompletableFuture<Void> submit(
      JobExecution jobExecution, ExecutorService executorService); void cancel(JobExecution jobExecution);  }