use of org.wildfly.swarm.topology.runtime.Registration in project wildfly-swarm by wildfly-swarm.
the class ServiceWatcher method registrationsForService.
private Set<Registration> registrationsForService(IService service) {
Set<Registration> newEntries = new HashSet<>();
// Only expose the service's default port and anything running on the https port
service.getPorts().stream().filter(servicePort -> servicePort.getPort() == service.getPort() || servicePort.getPort() == DEFAULT_HTTPS_PORT).forEach(servicePort -> {
Registration registration = new Registration(TOPOLOGY_SOURCE_KEY, service.getName(), service.getName(), servicePort.getPort());
if (servicePort.getPort() == DEFAULT_HTTPS_PORT) {
registration.addTags(Collections.singletonList("https"));
} else if (servicePort.getPort() == service.getPort()) {
registration.addTags(Collections.singletonList("http"));
}
newEntries.add(registration);
});
return newEntries;
}
use of org.wildfly.swarm.topology.runtime.Registration in project wildfly-swarm by wildfly-swarm.
the class Advertiser method unadvertise.
public void unadvertise(String name, String address, int port) {
AgentClient client = this.agentClientInjector.getValue();
Registration r = new Registration("consul", name, address, port, "");
this.advertisements.stream().filter(e -> e.equals(r)).forEach(e -> {
String serviceId = serviceId(e);
log.info("Deregister service " + serviceId);
client.deregister(serviceId);
});
this.advertisements.removeIf(e -> e.equals(r));
}
use of org.wildfly.swarm.topology.runtime.Registration in project wildfly-swarm by wildfly-swarm.
the class ConsulTopologyConnector method advertise.
@Override
public void advertise(String name, SocketBinding binding, String... tags) {
Registration registration = new Registration("consul", name, binding.getAddress().getHostAddress(), binding.getAbsolutePort(), tags);
getAdvertiser().advertise(registration);
}
use of org.wildfly.swarm.topology.runtime.Registration in project wildfly-swarm by wildfly-swarm.
the class ServiceCacheListener method notify.
@Override
public void notify(Map<HostAndPort, ServiceHealth> newValues) {
Set<Registration> previousEntries = topologyManager.registrationsForService(this.name);
Set<Registration> newEntries = newValues.values().stream().map(e -> new Registration("consul", this.name, e.getService().getAddress(), e.getService().getPort()).addTags(e.getService().getTags())).collect(Collectors.toSet());
previousEntries.stream().filter(e -> !newEntries.contains(e)).forEach(e -> {
this.topologyManager.unregister(e);
});
newEntries.stream().filter(e -> !previousEntries.contains(e)).forEach(e -> {
this.topologyManager.register(e);
});
}
use of org.wildfly.swarm.topology.runtime.Registration in project wildfly-swarm by wildfly-swarm.
the class JGroupsTopologyConnector method advertise.
public synchronized void advertise(String name, SocketBinding binding, String... tags) throws Exception {
Registration registration = new Registration(sourceKey(this.node), name, binding.getAddress().getHostAddress(), binding.getAbsolutePort(), tags);
this.registrations.put(name + ":" + binding.getName(), registration);
advertise(registration);
}
Aggregations