private void logCancelledRequestJobs(final List<RequestJob> pendingJobs) { if(LOGGER.isTraceEnabled()) { final List<URI> executionIds=Lists.newArrayList(); for(final RequestJob job:pendingJobs) { if(!job.requiresTermination()) { executionIds.add(job.context().targetExecution().executionId()); } } if(!executionIds.isEmpty()) { LOGGER.trace("Cancelled {} pending execution enrichment request jobs ({})",pendingJobs.size(),executionIds); } else { LOGGER.trace("All execution enrichment jobs were executed"); } } }
private void logAbortedRequestJobs(final List<Runnable> unfinished) { if(LOGGER.isTraceEnabled()) { final List<URI> aborted=Lists.newArrayList(); for(final Runnable runnable:unfinished) { final RequestJob job=this.executor.unwrap(runnable,RequestJob.class); if(job!=null && !job.requiresTermination()) { aborted.add(job.context().targetExecution().executionId()); } } if(!aborted.isEmpty()) { LOGGER.trace("Aborted {} pending execution enrichment requests ({})",aborted.size(),aborted); } else { LOGGER.trace("All scheduled pending execution enrichment requests were queued."); } } }
private void processJobs() { while(!this.terminated) { try { final RequestJob job=this.queue.take(); if(!job.requiresTermination()) { processJob(job); } } catch (final InterruptedException e) { // Ignore interruption. Worker can only be terminated via // the triggerTermination method LOGGER.trace("Interrupted while waiting for job",e); Thread.currentThread().interrupt(); } } cancelPendingJobs(); }
void queueJob(final RequestJob job) { if(!job.requiresTermination() && this.terminated) { LOGGER.info("Rejected request job {} for execution {}",job.description(),job.context().targetExecution().executionId()); return; } while(true) { try { this.queue.put(job); LOGGER.trace("Queued job {}",job.description()); break; } catch (final InterruptedException e) { LOGGER.info("Enrichment Requestor interrupted while awaiting for enqueueing job {}",job.description(),e); } } }