@Override public synchronized Map<String, List<Entry>> asMap() { Map<String, List<Entry>> map = new HashMap<>(); for (Registration registration : this.registrations) { List<Entry> list = map.get(registration.getName()); if (list == null) { list = new ArrayList<>(); map.put(registration.getName(), list); } list.add(registration); } return map; }
@Override public synchronized Map<String, List<Entry>> asMap() { Map<String, List<Entry>> map = new HashMap<>(); for (Registration registration : this.registrations) { List<Entry> list = map.get(registration.getName()); if (list == null) { list = new ArrayList<>(); map.put(registration.getName(), list); } list.add(registration); } return map; }
@Override public synchronized Map<String, List<Entry>> asMap() { Map<String, List<Entry>> map = new HashMap<>(); for (Registration registration : this.registrations) { List<Entry> list = map.get(registration.getName()); if (list == null) { list = new ArrayList<>(); map.put(registration.getName(), list); } list.add(registration); } return map; }
public synchronized Set<Registration> registrationsForService(String name) { Set<Registration> result = Collections.unmodifiableSet( this.registrations.stream() .filter(e -> e.getName().equals(name)) .collect(Collectors.toSet()) ); return result; }
public synchronized Set<Registration> registrationsForService(String name) { Set<Registration> result = Collections.unmodifiableSet( this.registrations.stream() .filter(e -> e.getName().equals(name)) .collect(Collectors.toSet()) ); return result; }
public synchronized Set<Registration> registrationsForService(String name) { Set<Registration> result = Collections.unmodifiableSet( this.registrations.stream() .filter(e -> e.getName().equals(name)) .collect(Collectors.toSet()) ); return result; }
public synchronized Set<Registration> registrationsForService(String name, String tag) { Set<Registration> result = Collections.unmodifiableSet( this.registrations.stream() .filter(e -> e.getName().equals(name) && e.hasTag(tag)) .collect(Collectors.toSet()) ); return result; }
public synchronized Set<Registration> registrationsForService(String name, String tag) { Set<Registration> result = Collections.unmodifiableSet( this.registrations.stream() .filter(e -> e.getName().equals(name) && e.hasTag(tag)) .collect(Collectors.toSet()) ); return result; }
public synchronized Set<Registration> registrationsForService(String name, String tag) { Set<Registration> result = Collections.unmodifiableSet( this.registrations.stream() .filter(e -> e.getName().equals(name) && e.hasTag( tag ) ) .collect(Collectors.toSet()) ); return result; }
public synchronized void unregisterAll(String sourceKey, String name) { boolean removed = this.registrations.removeIf(e -> e.getSourceKey().equals(sourceKey) && e.getName().equals(name)); if (removed) { fireListeners(); } }
public synchronized void unregisterAll(String sourceKey, String name) { boolean removed = this.registrations.removeIf(e -> e.getSourceKey().equals(sourceKey) && e.getName().equals(name)); if (removed) { fireListeners(); } }
public synchronized void unregisterAll(String sourceKey, String name) { boolean removed = this.registrations.removeIf(e -> e.getSourceKey().equals(sourceKey) && e.getName().equals(name)); if (removed) { fireListeners(); } }
public void unadvertise(String name, String address, int port) { this.advertisements.removeIf( e->e.getName().equals( name) && e.getAddress().equals( address ) && e.getPort() == port ); }
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); }