/** * 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();