public void unadvertise(String name, String address, int port) { this.advertisements.removeIf( e->e.getName().equals( name) && e.getAddress().equals( address ) && e.getPort() == port ); }
@Override public List<Server> getInitialListOfServers() { String tag = ( this.isSecure ? "https" : "http" ); return TopologyManager.INSTANCE.registrationsForService(this.appName, tag) .stream() .map( reg-> new Server( reg.getAddress(), reg.getPort() )) .collect(Collectors.toList()); }
@Override public List<Server> getUpdatedListOfServers() { String tag = ( this.isSecure ? "https" : "http" ); return TopologyManager.INSTANCE.registrationsForService(this.appName, tag) .stream() .map( reg-> new Server( reg.getAddress(), reg.getPort() )) .collect(Collectors.toList()); } }
@Override public List<Server> getInitialListOfServers() { String tag = (this.isSecure ? "https" : "http"); return TopologyManager.INSTANCE.registrationsForService(this.appName, tag) .stream() .map(reg -> new Server(reg.getAddress(), reg.getPort())) .collect(Collectors.toList()); }
@Override public List<Server> getUpdatedListOfServers() { String tag = (this.isSecure ? "https" : "http"); return TopologyManager.INSTANCE.registrationsForService(this.appName, tag) .stream() .map(reg -> new Server(reg.getAddress(), reg.getPort())) .collect(Collectors.toList()); }
@Override public List<Server> getInitialListOfServers() { String tag = (this.isSecure ? "https" : "http"); return TopologyManager.INSTANCE.registrationsForService(this.appName, tag) .stream() .map(reg -> new Server(reg.getAddress(), reg.getPort())) .collect(Collectors.toList()); }
@Override public List<Server> getUpdatedListOfServers() { String tag = (this.isSecure ? "https" : "http"); return TopologyManager.INSTANCE.registrationsForService(this.appName, tag) .stream() .map(reg -> new Server(reg.getAddress(), reg.getPort())) .collect(Collectors.toList()); }
private String serviceId(Registration registration) { return registration.getName() + ":" + registration.getAddress() + ":" + registration.getPort(); } }
public void advertise(Registration registration) { if (this.advertisements.contains(registration)) { return; } AgentClient client = this.agentClientInjector.getValue(); com.orbitz.consul.model.agent.Registration consulReg = ImmutableRegistration.builder() .address(registration.getAddress()) .port(registration.getPort()) .id(serviceId(registration)) .name(registration.getName()) .addTags(registration.getTags().toArray(new String[]{})) .check(com.orbitz.consul.model.agent.Registration.RegCheck.ttl(3L)) .build(); client.register(consulReg); this.advertisements.add(registration); }