@Override public ServerResolver withDnsName(String dnsName) { return ServerResolvers.fromDnsName(dnsName).withPort(port); } }
public static WriteServerResolverSet forDnsName(String bootstrapHostname, int registrationPort, int discoveryPort) { return new WriteServerResolverSet( ServerResolvers.forDnsName(bootstrapHostname, registrationPort), ServerResolvers.forDnsName(bootstrapHostname, discoveryPort) ); }
@Override public ServerResolver withPort(final int port) { return ServerResolvers.from(new Server(hostname, port)); } }
public void connectToCluster(String host, int registrationPort, int discoveryPort, String readClusterVip) { eurekaClient = Eureka.newClientBuilder( ServerResolvers.fromWriteServer(ServerResolvers.just(host, discoveryPort), readClusterVip), ServerResolvers.just(host, registrationPort) ).withCodec(context.getCodec()).build(); mode = Mode.ReadWrite; }
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; }
public ServerResolver getDiscoveryResolver() { return ServerResolvers.just("localhost", discoveryPort); } }
public void connectToRegister(String host, int port) { ServerResolver serverResolver; if(host.indexOf('.') == -1) { serverResolver = ServerResolvers.fromHostname(host).withPort(port); } else { serverResolver = ServerResolvers.fromDnsName(host).withPort(port); } registrationClient = Eurekas.newRegistrationClientBuilder() .withTransportConfig(context.getTransportConfig()) .withServerResolver(serverResolver) .build(); mode = Mode.Write; }
public void run() throws InterruptedException { .withServerResolver(fromDnsName(writeServerDns).withPort(writeRegistrationPort)) .build(); fromEureka( fromDnsName(writeServerDns).withPort(writeInterestPort) ).forInterest(forVips(readServerVip));
public ServerResolver getInterestResolver() { return ServerResolvers.fromHostname("localhost").withPort(discoveryPort); } }
public ServerResolver interestResolver() { return ServerResolvers.fromServerSource(clusterChangeObservable()); }
/** * 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; }
/** * Creates a new {@link EurekaClientBuilder} using the passed resolver instance for write, and construct * the read resolver from reading write server data. * * @param writeResolverSet {@link WriteServerResolverSet} for the write servers. * @param readServerVip the vip address for the read cluster * * @return A new {@link EurekaClientBuilder}. */ public static EurekaClientBuilder newClientBuilder(WriteServerResolverSet writeResolverSet, String readServerVip) { ServerResolver readResolver = ServerResolvers.fromWriteServer(writeResolverSet.forDiscovery(), readServerVip); return newClientBuilder(readResolver, writeResolverSet.forRegistration()); }
@Override public ServerResolver getInterestResolver() { return ServerResolvers.fromHostname("localhost").withPort(getDiscoveryPort()); }
private ServerResolver getServerResolver(final Func1<ClusterAddress, Integer> portFunc) { Observable<ChangeNotification<Server>> serverSource = clusterChangeObservable().map(new Func1<ChangeNotification<ClusterAddress>, ChangeNotification<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()); return ServerResolvers.fromServerSource(serverSource); }
if (readClusterSize > 0) { discoveryPort = readCluster.getServer(0).getDiscoveryPort(); readClusterResolver = ServerResolvers.fromEureka(writeCluster.interestResolver()).forInterest(forVips(readCluster.getVip())); } else { discoveryPort = writeCluster.getServer(0).getDiscoveryPort();
public ServerResolver getDiscoveryResolver() { return ServerResolvers.just("localhost", getDiscoveryPort()); }
@Override public ServerResolver withHostname(final String hostname) { return ServerResolvers.from(new Server(hostname, port)); }
@Override public EurekaInterestClient get() { logger.info("Subscribing to Eureka2 server {}:{}", discoveryDNS, port); return Eurekas.newInterestClientBuilder() .withServerResolver(ServerResolvers.fromDnsName(discoveryDNS).withPort(port)) .build(); } }
@Override public ServerResolver getInterestResolver() { return ServerResolvers.fromHostname("localhost").withPort(getDiscoveryPort()); }