public StaticEurekaClusterResolver(List<ClusterAddress> clusterAddresses) { List<ChangeNotification<ClusterAddress>> addNotifications = new ArrayList<>(clusterAddresses.size()); for (ClusterAddress address : clusterAddresses) { addNotifications.add(new ChangeNotification<ClusterAddress>(Kind.Add, address)); } addNotifications.add(ChangeNotification.<ClusterAddress>bufferSentinel()); this.clusterObserver = Observable.from(addNotifications); }
protected Observable<ChangeNotification<A>> clusterChangeObservable() { ChangeNotification<A> sentinel = ChangeNotification.bufferSentinel(); return Observable.from(clusterAddresses) .concatWith(Observable.just(sentinel)) .concatWith(clusterAddressUpdates); }
@Override public ChangeNotification<Server> call(ChangeNotification<InstanceInfo> notification) { switch (notification.getKind()) { case BufferSentinel: return ChangeNotification.bufferSentinel(); // type change case Add: case Modify: case Delete: Server newServer = instanceInfoToServer(notification.getData()); if (newServer != null) { return new ChangeNotification<>(notification.getKind(), newServer); } break; default: // no-op } return null; }
@Override public ChangeNotification<Server> call(ChangeNotification<InstanceInfo> notification) { switch (notification.getKind()) { case BufferSentinel: return ChangeNotification.bufferSentinel(); // type change case Add: case Modify: case Delete: Server newServer = instanceInfoToServer(notification.getData()); if (newServer != null) { return new ChangeNotification<>(notification.getKind(), newServer); } break; default: // no-op } return null; }
@Override public ChangeNotification<Server> call(ChangeNotification<ClusterAddress> notification) { if (notification.getKind() == Kind.BufferSentinel) { return ChangeNotification.bufferSentinel(); } Server server = new Server( notification.getData().getHostName(), notification.getData().getPortFor(serviceType) ); return new ChangeNotification<Server>(notification.getKind(), server); } });
@Override public ChangeNotification<Server> call(ChangeNotification<ClusterAddress> notification) { if (notification.getKind() == Kind.BufferSentinel) { return ChangeNotification.bufferSentinel(); } ClusterAddress endpoints = notification.getData(); int port = portFunc.call(endpoints); switch (notification.getKind()) { case Add: return new ChangeNotification<>(Kind.Add, new Server(endpoints.getHostName(), port)); case Modify: throw new IllegalStateException("Modify not expected"); case Delete: return new ChangeNotification<>(Kind.Delete, new Server(endpoints.getHostName(), port)); default: //no-op } return null; } }).filter(RxFunctions.filterNullValuesFunc());