@Override @Nullable public <T> Object invoke(CentralDogmaBeanMethodHandler<T> handler, Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { if (handler.watcher.initialValueFuture().isDone()) { return handler.watcher.latest().revision(); } else { return null; } } }
@Override @Nullable public <T> Object invoke(CentralDogmaBeanMethodHandler<T> handler, Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { if (handler.watcher.initialValueFuture().isDone()) { return handler.watcher.latest().revision(); } else { return null; } } }
@Override @Nullable public <T> Object invoke(CentralDogmaBeanMethodHandler<T> handler, Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { if (handler.watcher.initialValueFuture().isDone()) { return handler.watcher.latest().revision(); } else { return null; } } }
private void notifyListeners() { if (isStopped()) { // Do not notify after stopped. return; } final Latest<T> latest = this.latest; for (BiConsumer<? super Revision, ? super T> listener : updateListeners) { listener.accept(latest.revision(), latest.value()); } }
private void notifyListeners() { if (isStopped()) { // Do not notify after stopped. return; } final Latest<T> latest = this.latest; for (BiConsumer<? super Revision, ? super T> listener : updateListeners) { listener.accept(latest.revision(), latest.value()); } }
private void notifyListeners() { if (isStopped()) { // Do not notify after stopped. return; } final Latest<T> latest = this.latest; for (BiConsumer<? super Revision, ? super T> listener : updateListeners) { listener.accept(latest.revision(), latest.value()); } }
@Override public void watch(BiConsumer<? super Revision, ? super T> listener) { requireNonNull(listener, "listener"); checkState(!isStopped(), "watcher closed"); updateListeners.add(listener); if (latest != null) { // Perform initial notification so that the listener always gets the initial value. try { executor.execute(() -> { final Latest<T> latest = this.latest; listener.accept(latest.revision(), latest.value()); }); } catch (RejectedExecutionException e) { handleEventLoopShutdown(e); } } }
@Override public void watch(BiConsumer<? super Revision, ? super T> listener) { requireNonNull(listener, "listener"); checkState(!isStopped(), "watcher closed"); updateListeners.add(listener); if (latest != null) { // Perform initial notification so that the listener always gets the initial value. try { executor.execute(() -> { final Latest<T> latest = this.latest; listener.accept(latest.revision(), latest.value()); }); } catch (RejectedExecutionException e) { handleEventLoopShutdown(e); } } }
@Override public void watch(BiConsumer<? super Revision, ? super T> listener) { requireNonNull(listener, "listener"); checkState(!isStopped(), "watcher closed"); updateListeners.add(listener); if (latest != null) { // Perform initial notification so that the listener always gets the initial value. try { executor.execute(() -> { final Latest<T> latest = this.latest; listener.accept(latest.revision(), latest.value()); }); } catch (RejectedExecutionException e) { handleEventLoopShutdown(e); } } }
final Revision lastKnownRevision = latest != null ? latest.revision() : Revision.INIT; final CompletableFuture<Latest<T>> f = doWatch(client, projectName, repositoryName, lastKnownRevision, WATCH_TIMEOUT_MILLIS); latest = newLatest; logger.debug("watcher noticed updated file {}/{}{}: rev={}", projectName, repositoryName, pathPattern, newLatest.revision()); notifyListeners(); if (oldLatest == null) {
final Revision lastKnownRevision = latest != null ? latest.revision() : Revision.INIT; final CompletableFuture<Latest<T>> f = doWatch(client, projectName, repositoryName, lastKnownRevision, WATCH_TIMEOUT_MILLIS); latest = newLatest; logger.debug("watcher noticed updated file {}/{}{}: rev={}", projectName, repositoryName, pathPattern, newLatest.revision()); notifyListeners(); if (oldLatest == null) {
final Revision lastKnownRevision = latest != null ? latest.revision() : Revision.INIT; final CompletableFuture<Latest<T>> f = doWatch(client, projectName, repositoryName, lastKnownRevision, WATCH_TIMEOUT_MILLIS); latest = newLatest; logger.debug("watcher noticed updated file {}/{}{}: rev={}", projectName, repositoryName, pathPattern, newLatest.revision()); notifyListeners(); if (oldLatest == null) {
final long elapsedMillis = System.nanoTime() - t0; logger.debug("Initial value of {} obtained in {} ms: rev={}", settings, elapsedMillis, latest.revision());
final long elapsedMillis = System.nanoTime() - t0; logger.debug("Initial value of {} obtained in {} ms: rev={}", settings, elapsedMillis, latest.revision());
final long elapsedMillis = System.nanoTime() - t0; logger.debug("Initial value of {} obtained in {} ms: rev={}", settings, elapsedMillis, latest.revision());