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."); } } }
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); } } }
private void retryJob(final RequestJob job) { final long retries = job.retry(5,TimeUnit.SECONDS); LOGGER. trace( "Retrying job #{} ({}): could not resolve resource for execution {} ", job.id(), retries, job.context().targetExecution().executionId()); }
private void processCompletedEnrichment(final EnrichmentContext context, final Set<URI> executions) { final CompletedEnrichment completed=this.completedRepository.completedEnrichmentOfExecution(context.targetExecution().executionId()); if(completed!=null) { LOGGER.trace("{} enrichment is already completed (#{})",context,completed.id()); return; } final ExecutionEnrichment enrichment=context.enrichment(); final List<CompletedEnrichment> potentialEnrichments=this.completedRepository.findCompletedEnrichments(enrichment.repositoryResource().orNull(),enrichment.branchResource().orNull(),enrichment.commitResource().orNull()); if(!potentialEnrichments.isEmpty()) { final CompletedEnrichment delegate = potentialEnrichments.get(0); delegate.executions().addAll(executions); LOGGER.trace("{} enrichment is now completed by enrichment #{}",context,delegate.id()); return; } final CompletedEnrichment newCompleted=CompletedEnrichment.newInstance(enrichment.repositoryResource().orNull(),enrichment.branchResource().orNull(),enrichment.commitResource().orNull()); newCompleted.executions().addAll(executions); this.completedRepository.add(newCompleted); LOGGER.trace("{} enrichment is completed by {}",context,newCompleted); }
private void processJob(final RequestJob job) { final URI executionResource = this.resolver. resolveExecution( job.context().targetExecution()); if(executionResource==null) { retryJob(job); } else { completeJob(job, executionResource); } }
private void processPendingEnrichment(final EnrichmentContext context) { final PendingEnrichment pending=this.pendingRepository.pendingEnrichmentOfExecution(context.targetExecution().executionId()); if(pending!=null) { LOGGER.trace("{} enrichment request is already being undertaken by pending enrichment #{}",context,pending.id()); return; } final List<PendingEnrichment> potentialEnrichments=this.pendingRepository.findPendingEnrichments(context.repositoryLocation(),context.branchName(),context.commitId()); if(!potentialEnrichments.isEmpty()) { final PendingEnrichment delegate = potentialEnrichments.get(0); delegate.executions().add(context.targetExecution().executionId()); LOGGER.trace("{} enrichment request joins to pending enrichment #{}",context,delegate.id()); return; } final PendingEnrichment newPending=PendingEnrichment.newInstance(context.repositoryLocation(),context.branchName(),context.commitId()); newPending.executions().add(context.targetExecution().executionId()); this.pendingRepository.add(newPending); LOGGER.trace("{} creates {}",context,newPending); context.setPendingEnrichment(newPending); this.requestor.enqueueRequest(context); }
final Execution execution = this.executionRepository.executionOfId(context.targetExecution().executionId());