@Override public Observable<ChangeNotification<InstanceInfo>> forInterest(Interest<InstanceInfo> interest, Source.SourceMatcher sourceMatcher) { return eurekaRegistry.forInterest(interest, sourceMatcher); }
@Override public Observable<ChangeNotification<InstanceInfo>> forInterest(Interest<InstanceInfo> interest) { return eurekaRegistry.forInterest(interest); }
@Override protected void before() throws Throwable { when(registry.forInterest(any(Interest.class))).thenAnswer(new Answer<Observable<ChangeNotification<InstanceInfo>>>() { @Override public Observable<ChangeNotification<InstanceInfo>> answer(InvocationOnMock invocation) throws Throwable { return getInterestSubject((Interest) invocation.getArguments()[0]); } }); fullRegistrySubject = ReplaySubject.create(); }
@Override public Observable<ChangeNotification<T>> forCompositeInterest( MultipleInterests<T> interest, SourcedEurekaRegistry<T> registry ) { List<Observable<ChangeNotification<T>>> indexes = new ArrayList<>(); for (Interest<T> atomicInterest : interest.flatten()) { indexes.add(registry.forInterest(atomicInterest)); } return Observable.merge(indexes); }
private Observable<RegistryFetch> getLatestFullFetch() { if (fullFetchWithDeltaView.get() == null) { synchronized (fullFetchWithDeltaView) { if (fullFetchWithDeltaView.get() == null) { Eureka2FullFetchWithDeltaView newView = new Eureka2FullFetchWithDeltaView( registry.forInterest(Interests.forFullRegistry()), refreshIntervalMs, scheduler ); fullFetchWithDeltaView.set(newView); } } } return fullFetchWithDeltaView.get().latestCopy(); }
private void subscribeToInterest(Interest<InstanceInfo> newInterest) { BreakerSwitchOperator<ChangeNotification<InstanceInfo>> breaker = new BreakerSwitchOperator<>(); upgrades.onNext(eurekaRegistry.forInterest(newInterest).lift(breaker)); subscriptionBreakers.put(newInterest, breaker); }
@Override public Observable<Void> call(final ReplicationChannel channel) { return registry.forInterest(Interests.forFullRegistry(), Source.matcherFor(Source.Origin.LOCAL)) .flatMap(new Func1<ChangeNotification<InstanceInfo>, Observable<Void>>() {// TODO concatMap once backpressure is properly working @Override public Observable<Void> call(ChangeNotification<InstanceInfo> notification) { switch (notification.getKind()) { case Add: return channel.register(notification.getData()); case Modify: return channel.register(notification.getData()); case Delete: return channel.unregister(notification.getData().getId()); default: logger.warn("Unrecognised notification kind {}", notification); return Observable.empty(); } } }); } }
.mergeWith(registry.forInterest(interest)) .doOnUnsubscribe(new Action0() { @Override
public Observable<com.netflix.appinfo.InstanceInfo> findInstance(String instanceId) { return registry.forInterest(Interests.forInstance(Operator.Equals, instanceId)) .compose(ChangeNotifications.<InstanceInfo>delineatedBuffers()) .compose(ChangeNotifications.<InstanceInfo>snapshots()) .flatMap(new Func1<LinkedHashSet<InstanceInfo>, Observable<com.netflix.appinfo.InstanceInfo>>() { @Override public Observable<com.netflix.appinfo.InstanceInfo> call(LinkedHashSet<InstanceInfo> latestSnapshot) { if (latestSnapshot.isEmpty()) { return Observable.empty(); } InstanceInfo instanceInfo = latestSnapshot.iterator().next(); if (latestSnapshot.size() > 1) { logger.error("Data consistency issue; two instances found with the same instance id {}", instanceInfo.getId()); } return Observable.just(toEureka1xInstanceInfo(latestSnapshot.iterator().next())); } }); }
@PostConstruct public void start() { String redirectTarget = context.getConfig().getReadClusterVipAddress(); if (redirectTarget == null || redirectTarget.isEmpty()) { logger.warn("Not starting Eureka1RedirectRequestHandler, redirect target not available"); return; } subscription = context.getLocalRegistry() .forInterest(Interests.forVips(redirectTarget)) .compose(ChangeNotifications.<InstanceInfo>delineatedBuffers()) .compose(ChangeNotifications.<InstanceInfo>snapshots()) .subscribe(new Subscriber<Set<InstanceInfo>>() { @Override public void onCompleted() { logger.info("Read server subscription completed"); } @Override public void onError(Throwable e) { logger.info("Read server stream terminated with an error", e); } @Override public void onNext(Set<InstanceInfo> instanceInfos) { logger.info("Updating read server cluster to: {}", instanceInfos); readServers = new ArrayList<InstanceInfo>(instanceInfos); } }); }