Source:
private static <T> void runAntiEntropy( final Injector injector, final Clock clock, final Class<? extends JobRepository<T>> repositoryType, final OrganizationRepository organizationRepository, final ActorRef jobExecutorRegion, final PeriodicMetrics periodicMetrics, final ActorRef coordinator) { try { LOGGER.debug() .setMessage("starting anti-entropy") .addData("repositoryType", repositoryType) .log(); final Instant startTime = clock.instant(); final JobRepository<T> repo = injector.getInstance(repositoryType); final Iterable<? extends Organization> allOrgs = organizationRepository.query(organizationRepository.createQuery()).values(); for (final Organization organization : allOrgs) { final Iterator<? extends Job<T>> allJobs = getAllJobs(repo, organization); allJobs.forEachRemaining(job -> { final JobRef<T> ref = new JobRef.Builder<T>() .setRepositoryType(repositoryType) .setOrganization(organization) .setId(job.getId()) .build(); jobExecutorRegion.tell( new JobExecutorActor.Reload.Builder<T>() .setJobRef(ref) .setETag(job.getETag().orElse(null)) .build(), coordinator); }); } periodicMetrics.recordTimer( "jobs/coordinator/anti_entropy/latency", ChronoUnit.NANOS.between(startTime, clock.instant()), Optional.of(NANOS)); periodicMetrics.recordCounter("jobs/coordinator/anti_entropy/success", 1); LOGGER.debug() .setMessage("finished anti-entropy") .addData("repositoryType", repositoryType) .addData("elapsedTimeSec", ChronoUnit.NANOS.between(startTime, clock.instant())) .log(); } catch (final RuntimeException e) { periodicMetrics.recordCounter("jobs/coordinator/anti_entropy/success", 0); } finally { coordinator.tell(AntiEntropyFinished.INSTANCE, coordinator); } }

Target:
private static <T> void runAntiEntropy( final Injector injector, final Clock clock, final Class<? extends JobRepository<T>> repositoryType, final OrganizationRepository organizationRepository, final ActorRef jobExecutorRegion, final PeriodicMetrics periodicMetrics, final ActorRef coordinator) { try { LOGGER.debug() .setMessage("starting anti-entropy") .addData("repositoryType", repositoryType) .log(); final Instant startTime = clock.instant(); final JobRepository<T> repo = injector.getInstance(repositoryType); final Iterable<? extends Organization> allOrgs = organizationRepository.query(organizationRepository.createQuery()).values(); for (final Organization organization : allOrgs) { final Iterator<? extends Job<T>> allJobs = getAllJobs(repo, organization); allJobs.forEachRemaining(job -> { final JobRef<T> ref = new JobRef.Builder<T>() .setRepositoryType(repositoryType) .setOrganization(organization) .setId(job.getId()) .build(); jobExecutorRegion.tell( new JobExecutorActor.Reload.Builder<T>() .setJobRef(ref) .setETag(job.getETag().orElse(null)) .build(), coordinator); }); } periodicMetrics.recordTimer( "jobs/coordinator/anti_entropy/latency", ChronoUnit.NANOS.between(startTime, clock.instant()), Optional.of(NANOS)); periodicMetrics.recordCounter("jobs/coordinator/anti_entropy/success", 1); LOGGER.debug() .setMessage("finished anti-entropy") .addData("repositoryType", repositoryType) .addData("elapsedTimeSec", ChronoUnit.NANOS.between(startTime, clock.instant())) .log(); } catch (final RuntimeException e) { periodicMetrics.recordCounter("jobs/coordinator/anti_entropy/success", 0); throw e; } finally { coordinator.tell(AntiEntropyFinished.INSTANCE, coordinator); } }