private RequestJob(final EnrichmentContext context) { this.context=context; this.retries=0; this.id=EnrichmentRequestor.this.metrics.createJob(context); }
EnrichmentRequestor(final EnrichmentService service, final Connector connector, final ResolverService resolver) { this.service = service; this.metrics = new RequestorMetrics(); this.worker = new Worker(connector,resolver); final ThreadFactory threadFactory = new ThreadFactoryBuilder(). setNameFormat("EnrichmentRequestor-worker-%d"). setPriority(Thread.MAX_PRIORITY). setUncaughtExceptionHandler( new UncaughtExceptionHandler() { @Override public void uncaughtException(final Thread t, final Throwable e) { LOGGER.error("Requestor thread {} died unexpectedly",t,e); } }). build(); this.executor=MoreExecutors.newMemoizingScheduledExecutorService(2, threadFactory); this.started=false; }
private void completeJob(final RequestJob job, final URI executionResource) { final EnrichmentContext ctx = job.context(); boolean completed=false; try { submitEnrichmentRequest(ctx,UseCase.createRequest(executionResource,ctx)); completed=true; } catch (final Exception e) { LOGGER.error("Could not process {} ({}). Full stacktrace follows",ctx.pendingEnrichment(),executionResource,e); } finally { LOGGER.trace("{} processing job {}",completed?"Completed ":"Failed ",job.description()); EnrichmentRequestor.this.metrics.jobProcessed(job,completed); } }