if(metadataProps.isAddPorts()) { Map<String, String> ports = s.getPorts().stream() .filter(port -> !StringUtils.isEmpty(port.getName())) .collect(toMap(EndpointPort::getName, port -> Integer.toString(port.getPort()))); Map<String, String> portMetadata = getMapWithPrefixedKeys(ports, metadataProps.getPortsPrefix());
for (EndpointPort port : subset.getPorts()) { if (Utils.isNullOrEmpty(portName) || portName.endsWith(port.getName())) { for (EndpointAddress address : subset.getAddresses()) { result.add(new Server(address.getIp(), port.getPort()));
if (Utils.isNullOrEmpty(portName) || portName.endsWith(port.getName())) { for (EndpointAddress address : subset.getAddresses()) { result.add(new Server(address.getIp(), port.getPort()));
@Override public ServiceInstance getLocalServiceInstance() { String podName = System.getenv(HOSTNAME); return client.endpoints().withName(localServiceId).get().getSubsets() .stream() .filter(s -> s.getAddresses().iterator().next().getIp().equals(podName)) .map(s -> new KubernetesServiceInstance(localServiceId, s.getPorts().iterator().next().getName(), s, false)) .findFirst().get(); }
@Override public List<ServiceInstance> getInstances(String serviceId) { return client.endpoints().withName(serviceId).get() .getSubsets() .stream().map(s -> new KubernetesServiceInstance(serviceId, s.getPorts().iterator().next().getName(), s, false)) .collect(Collectors.toList()); }
@Override public int getPort() { if (subset.getPorts().isEmpty()) { throw new IllegalStateException("Endpoint subset has no ports."); } else if (isNullOrEmpty(portName) && subset.getPorts().size() == 1) { return subset.getPorts().get(0).getPort(); } else if (isNotNullOrEmpty(portName)) { for (EndpointPort port : subset.getPorts()) { if (portName.endsWith(port.getName())) { return port.getPort(); } } } throw new IllegalStateException("Endpoint subset has no matching ports."); }
@Override public List<ServiceDefinition> getServices(String name) { LOG.debug("Discovering endpoints from namespace: {} with name: {}", this.namespace, name); Endpoints endpoints = client.endpoints().inNamespace(this.namespace).withName(name).get(); List<ServiceDefinition> result = new ArrayList<>(); if (endpoints != null) { if (LOG.isDebugEnabled()) { LOG.debug("Found {} endpoints in namespace: {} for name: {} and portName: {}", endpoints.getSubsets().size(), this.namespace, name, this.portName); } for (EndpointSubset subset : endpoints.getSubsets()) { if (subset.getPorts().size() == 1) { addServers(name, result, subset.getPorts().get(0), subset); } else { final List<EndpointPort> ports = subset.getPorts(); final int portSize = ports.size(); EndpointPort port; for (int p = 0; p < portSize; p++) { port = ports.get(p); if (ObjectHelper.isEmpty(this.portName) || this.portName.endsWith(port.getName())) { addServers(name, result, port, subset); } } } } } return result; }
public EndpointPortBuilder(EndpointPortFluent<?> fluent,EndpointPort instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withName(instance.getName()); fluent.withPort(instance.getPort()); fluent.withProtocol(instance.getProtocol()); this.validationEnabled = validationEnabled; } public EndpointPortBuilder(EndpointPort instance){
public EndpointPortBuilder( EndpointPortFluent<?> fluent , EndpointPort instance ){ this.fluent = fluent; fluent.withName(instance.getName()); fluent.withPort(instance.getPort()); fluent.withProtocol(instance.getProtocol()); } public EndpointPortBuilder( EndpointPort instance ){
public EndpointPortFluentImpl(EndpointPort instance){ this.withName(instance.getName()); this.withPort(instance.getPort()); this.withProtocol(instance.getProtocol()); }
public EndpointPortBuilder(EndpointPort instance,Boolean validationEnabled){ this.fluent = this; this.withName(instance.getName()); this.withPort(instance.getPort()); this.withProtocol(instance.getProtocol()); this.validationEnabled = validationEnabled; }
public EndpointPortBuilder( EndpointPort instance ){ this.fluent = this; this.withName(instance.getName()); this.withPort(instance.getPort()); this.withProtocol(instance.getProtocol()); }
public EndpointPortBuilder( EndpointPort instance ){ this.fluent = this; this.withName(instance.getName()); this.withPort(instance.getPort()); this.withProtocol(instance.getProtocol()); }
public EndpointPortBuilder( EndpointPortFluent<?> fluent , EndpointPort instance ){ this.fluent = fluent; fluent.withName(instance.getName()); fluent.withPort(instance.getPort()); fluent.withProtocol(instance.getProtocol()); } public EndpointPortBuilder( EndpointPort instance ){
if (Utils.isNullOrEmpty(portName) || portName.endsWith(port.getName())) { for (EndpointAddress address : subset.getAddresses()) { result.add(new Server(address.getIp(), port.getPort()));