List<ClientMapping> getClientMappings() { final List<ClientMapping> ret = new ArrayList<>(); RemotingConnectorBindingInfoService.RemotingConnectorInfo info = this.remotingConnectorInfo.get(); if (info.getSocketBinding().getClientMappings() != null && !info.getSocketBinding().getClientMappings().isEmpty()) { ret.addAll(info.getSocketBinding().getClientMappings()); } else { // TODO: We use the textual form of IP address as the destination address for now. // This needs to be configurable (i.e. send either host name or the IP address). But // since this is a corner case (i.e. absence of any client-mappings for a socket binding), // this should be OK for now final String destinationAddress = info.getSocketBinding().getAddress().getHostAddress(); final InetAddress clientNetworkAddress; try { clientNetworkAddress = InetAddress.getByName("::"); } catch (UnknownHostException e) { throw new RuntimeException(e); } final ClientMapping defaultClientMapping = new ClientMapping(clientNetworkAddress, 0, destinationAddress, info.getSocketBinding().getAbsolutePort()); ret.add(defaultClientMapping); } return ret; } }
/** * Get the socket address. * * @return the socket address */ public InetSocketAddress getSocketAddress() { int port = calculatePort(); return new InetSocketAddress(getAddress(), port); }
/** * Get the socket address. * * @return the socket address */ public InetSocketAddress getSocketAddress() { int port = calculatePort(); return new InetSocketAddress(getAddress(), port); }
/** * Get the socket address. * * @return the socket address */ public InetSocketAddress getSocketAddress() { int port = calculatePort(); return new InetSocketAddress(getAddress(), port); }
@Override public InetAddress getAddress() { return address == null ? this.listener.getSocketBinding().getAddress() : address; }
protected String getBaseUrl() { final String address = injectedSocketBinding.getValue().getAddress().getHostAddress(); final int port = injectedSocketBinding.getValue().getAbsolutePort(); if (injectedSocketBinding.getValue().getAddress() instanceof Inet4Address) { return "http://" + address + ":" + port; } else { return "http://[" + address + "]:" + port; } }
@Override public void start(StartContext context) throws StartException { for (String key : _socketBindings.keySet()) { SocketBinding binding = _socketBindings.get(key).getValue(); SocketAddr addr = new SocketAddr(binding.getAddress().getHostAddress(), binding.getPort()); LOG.trace("Injecting socket binding '" + addr + "'"); _injectedValues.put(key, addr.toString()); } }
@Override public void start(StartContext context) throws StartException { for (String key : _socketBindings.keySet()) { SocketBinding binding = _socketBindings.get(key).getValue(); SocketAddr addr = new SocketAddr(binding.getAddress().getHostAddress(), binding.getPort()); LOG.trace("Injecting socket binding '" + addr + "'"); _injectedValues.put(key, addr.toString()); } }
@Override public void unadvertise(String name, SocketBinding binding) { this.advertiser.unadvertise(name, binding.getAddress().getHostAddress(), binding.getAbsolutePort() ); }
@Override public void advertise(String name, SocketBinding binding, String...tags) { Registration registration = new Registration("consul", name, binding.getAddress().getHostAddress(), binding.getAbsolutePort(), tags ); this.advertiser.advertise(registration); }
List<ClientMapping> getClientMappings() { if (this.remotingServer == null) { return Collections.emptyList(); } final SocketBinding socketBinding = this.remotingServer.getSocketBinding(); final List<ClientMapping> clientMappings = socketBinding.getClientMappings(); if (clientMappings != null && !clientMappings.isEmpty()) { return clientMappings; } // TODO: We use the textual form of IP address as the destination address for now. // This needs to be configurable (i.e. send either host name or the IP address). But // since this is a corner case (i.e. absence of any client-mappings for a socket binding), // this should be OK for now final String destinationAddress = socketBinding.getAddress().getHostAddress(); final InetAddress clientNetworkAddress; try { clientNetworkAddress = InetAddress.getByName("::"); } catch (UnknownHostException e) { throw new RuntimeException(e); } final ClientMapping defaultClientMapping = new ClientMapping(clientNetworkAddress, 0, destinationAddress, socketBinding.getAbsolutePort()); return Collections.singletonList(defaultClientMapping); }
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); }
public synchronized void advertise(String name, SocketBinding binding, String... tags) { Registration registration = new Registration(sourceKey(this.node), name, binding.getAddress().getHostAddress(), binding.getAbsolutePort(), tags); this.registrations.put(name + ":" + binding.getName(), registration); advertise(registration); }
if (listener.getBinding().getValue() != null) { port = listener.getBinding().getValue().getPort(); if (listener.getBinding().getValue().getAddress() != null) { hostname = listener.getBinding().getValue().getAddress().getHostName();
if (listener.getBinding().getValue() != null) { port = listener.getBinding().getValue().getPort(); if (listener.getBinding().getValue().getAddress() != null) { hostname = listener.getBinding().getValue().getAddress().getHostName();
String connectorAddress = connectorSocketBindingValue.getAddress().getHostAddress(); String connectorPort = String.valueOf(connectorSocketBindingValue.getAbsolutePort()); if (connectorAddress.equals("0.0.0.0") || connectorAddress.equals("::/128")) {
public static DiscoveryGroupConfiguration createDiscoveryGroupConfiguration(final String name, final DiscoveryGroupConfiguration config, final SocketBinding socketBinding) throws Exception { final String localAddress = socketBinding.getAddress().getHostAddress(); final String groupAddress = socketBinding.getMulticastAddress().getHostAddress(); final int groupPort = socketBinding.getMulticastPort(); final long refreshTimeout = config.getRefreshTimeout(); final long initialWaitTimeout = config.getDiscoveryInitialWaitTimeout(); final BroadcastEndpointFactory endpointFactory = new UDPBroadcastEndpointFactory() .setGroupAddress(groupAddress) .setGroupPort(groupPort) .setLocalBindAddress(localAddress) .setLocalBindPort(-1); return new DiscoveryGroupConfiguration() .setName(name) .setRefreshTimeout(refreshTimeout) .setDiscoveryInitialWaitTimeout(initialWaitTimeout) .setBroadcastEndpointFactory(endpointFactory); }
public static DiscoveryGroupConfiguration createDiscoveryGroupConfiguration(final String name, final DiscoveryGroupConfiguration config, final SocketBinding socketBinding) throws Exception { final String localAddress = socketBinding.getAddress().getHostAddress(); final String groupAddress = socketBinding.getMulticastAddress().getHostAddress(); final int groupPort = socketBinding.getMulticastPort(); final long refreshTimeout = config.getRefreshTimeout(); final long initialWaitTimeout = config.getDiscoveryInitialWaitTimeout(); final BroadcastEndpointFactory endpointFactory = new UDPBroadcastEndpointFactory() .setGroupAddress(groupAddress) .setGroupPort(groupPort) .setLocalBindAddress(localAddress) .setLocalBindPort(-1); return new DiscoveryGroupConfiguration() .setName(name) .setRefreshTimeout(refreshTimeout) .setDiscoveryInitialWaitTimeout(initialWaitTimeout) .setBroadcastEndpointFactory(endpointFactory); }
static BroadcastGroupConfiguration createBroadcastGroupConfiguration(final String name, final BroadcastGroupConfiguration config, final SocketBinding socketBinding) throws Exception { final String localAddress = socketBinding.getAddress().getHostAddress(); final String groupAddress = socketBinding.getMulticastAddress().getHostAddress(); final int localPort = socketBinding.getPort(); final int groupPort = socketBinding.getMulticastPort(); final long broadcastPeriod = config.getBroadcastPeriod(); final List<String> connectorRefs = config.getConnectorInfos(); final BroadcastEndpointFactory endpointFactory = new UDPBroadcastEndpointFactory() .setGroupAddress(groupAddress) .setGroupPort(groupPort) .setLocalBindAddress(localAddress) .setLocalBindPort(localPort); return new BroadcastGroupConfiguration() .setName(name) .setBroadcastPeriod(broadcastPeriod) .setConnectorInfos(connectorRefs) .setEndpointFactory(endpointFactory); }
static BroadcastGroupConfiguration createBroadcastGroupConfiguration(final String name, final BroadcastGroupConfiguration config, final SocketBinding socketBinding) throws Exception { final String localAddress = socketBinding.getAddress().getHostAddress(); final String groupAddress = socketBinding.getMulticastAddress().getHostAddress(); final int localPort = socketBinding.getPort(); final int groupPort = socketBinding.getMulticastPort(); final long broadcastPeriod = config.getBroadcastPeriod(); final List<String> connectorRefs = config.getConnectorInfos(); final BroadcastEndpointFactory endpointFactory = new UDPBroadcastEndpointFactory() .setGroupAddress(groupAddress) .setGroupPort(groupPort) .setLocalBindAddress(localAddress) .setLocalBindPort(localPort); return new BroadcastGroupConfiguration() .setName(name) .setBroadcastPeriod(broadcastPeriod) .setConnectorInfos(connectorRefs) .setEndpointFactory(endpointFactory); }