public static Interest<InstanceInfo> forVips(String... vips) { return forVips(Operator.Equals, vips); }
@Override protected void subscribeToInterest(Session activeSession, String[] args) { activeSession.forInterest(Interests.forVips(Operator.Like, args)); } };
@Override protected void subscribeToInterest(Session activeSession, String[] args) { activeSession.forInterest(Interests.forVips(Operator.Like, args)); } };
@Override public Observable<ChangeNotification<InstanceInfo>> forVips(String... vips) { return forInterest(Interests.forVips(vips)); }
@Override public Interest<InstanceInfo> build() { return Interests.forVips(SampleInstanceInfo.ZuulServer.build().getVipAddress()); } },
@Override public Interest<InstanceInfo> build() { return Interests.forVips(SampleInstanceInfo.ZuulServer.build().getVipAddress()); } },
@Override public Interest<InstanceInfo> build() { return Interests.forVips(SampleInstanceInfo.DiscoveryServer.build().getVipAddress()); } },
@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); } }); }
/** * Create a {@link EurekaInterestClient} instance to do interest discovery with any instance in a read cluster, * using the canonical method to first discover the read cluster from the write cluster */ public EurekaInterestClient cannonicalInterestClient() { EurekaInterestClient interestClient = Eurekas.newInterestClientBuilder() .withTransportConfig(transportConfig) .withServerResolver(ServerResolvers.fromEureka(getWriteCluster().interestResolver()) .forInterest(forVips(getReadCluster().getVip()))) .build(); connectedInterestClients.add(interestClient); return interestClient; }
fromEureka( fromDnsName(writeServerDns).withPort(writeInterestPort) ).forInterest(forVips(readServerVip));
public void connectToCluster(String host, int registrationPort, int interestPort, String readClusterVip) { registrationClient = Eurekas.newRegistrationClientBuilder() .withTransportConfig(context.getTransportConfig()) .withServerResolver(ServerResolvers.fromHostname(host).withPort(registrationPort)) .build(); interestClient = Eurekas.newInterestClientBuilder() .withTransportConfig(context.getTransportConfig()) .withServerResolver(ServerResolvers.fromEureka( ServerResolvers.fromDnsName(host).withPort(interestPort)) .forInterest(Interests.forVips(readClusterVip)) ) .build(); mode = Mode.ReadWrite; }
if (readClusterSize > 0) { discoveryPort = readCluster.getServer(0).getDiscoveryPort(); readClusterResolver = ServerResolvers.fromEureka(writeCluster.interestResolver()).forInterest(forVips(readCluster.getVip())); } else { discoveryPort = writeCluster.getServer(0).getDiscoveryPort();