super.start(context); SSLContext sslContext = this.sslContext.getOptionalValue(); if (sslContext == null) { SecurityRealm realm = securityRealm.getOptionalValue(); if (realm != null) { sslContext = realm.getSSLContext(); final XnioWorker worker = workerInjectedValue.getValue(); if(sslContext == null) { modClusterBuilder = ModCluster.builder(worker); final SocketBinding advertiseBinding = advertiseSocketBinding.getOptionalValue(); if (advertiseBinding != null) { InetAddress multicastAddress = advertiseBinding.getMulticastAddress(); if (multicastAddress == null) { throw UndertowLogger.ROOT_LOGGER.advertiseSocketBindingRequiresMulticastAddress(); .setAdvertiseAddress(advertiseBinding.getSocketAddress().getAddress().getHostAddress()) .setAdvertiseGroup(multicastAddress.getHostAddress()) .setAdvertisePort(advertiseBinding.getMulticastPort()) .setAdvertiseFrequency(advertiseFrequency) .setPath(advertisePath) builder.setManagementHost(managementSocketBinding.getValue().getSocketAddress().getHostString()); builder.setManagementPort(managementSocketBinding.getValue().getSocketAddress().getPort());
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; } }
protected void unregisterBinding() { final SocketBinding binding = this.binding.getValue(); binding.getSocketBindings().getNamedRegistry().unregisterBinding(binding.getName()); }
@Override public void accept(MPING protocol) { SocketBinding binding = this.binding.get(); protocol.setMcastAddr(binding.getMulticastAddress()); protocol.setMcastPort(binding.getMulticastPort()); } }
final SocketBinding socketBinding = iiopSocketBindingInjector.getOptionalValue(); final SocketBinding sslSocketBinding = this.iiopSSLSocketBindingInjector.getOptionalValue(); InetSocketAddress address = this.iiopSocketBindingInjector.getValue().getSocketAddress(); properties.setProperty(ORBConstants.SERVER_HOST_PROPERTY, address.getAddress().getHostAddress()); properties.setProperty(ORBConstants.SERVER_PORT_PROPERTY, String.valueOf(address.getPort())); properties.setProperty(ORBConstants.PERSISTENT_SERVER_PORT_PROPERTY, String.valueOf(address.getPort())); InetSocketAddress address = this.iiopSSLSocketBindingInjector.getValue().getSocketAddress(); properties.setProperty(ORBConstants.SERVER_HOST_PROPERTY, address.getAddress().getHostAddress()); properties.setProperty(Constants.ORB_SSL_PORT, String.valueOf(address.getPort())); final String sslSocket = new StringBuilder().append(Constants.SSL_SOCKET_TYPE).append(':') properties.setProperty(ORBConstants.LISTEN_SOCKET_PROPERTY, sslSocket); if (!properties.containsKey(Constants.ORB_ADDRESS)) { properties.setProperty(Constants.ORB_ADDRESS, address.getAddress().getHostAddress());
throw MessagingLogger.ROOT_LOGGER.failedToFindConnectorSocketBinding(tc.getName()); binding.getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(binding)); InetSocketAddress socketAddress = binding.getSocketAddress(); tc.getParams().put(HOST, socketAddress.getAddress().getHostAddress()); tc.getParams().put(PORT, socketAddress.getPort()); binding.getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(binding)); newConfigs.add(BroadcastGroupAdd.createBroadcastGroupConfiguration(name, config, binding)); binding.get().getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(binding.get())); mbs, securityManager); if (ServerDefinition.CLUSTER_PASSWORD.getDefaultValue().asString().equals(server.getConfiguration().getClusterPassword())) { server.getConfiguration().setClusterPassword(java.util.UUID.randomUUID().toString());
private static void configureMulticastSocket(Introspector introspector, org.jgroups.conf.ProtocolConfiguration config, String addressProperty, String portProperty, SocketBinding binding) { try { InetSocketAddress mcastSocketAddress = binding.getMulticastSocketAddress(); setSocketBindingProperty(introspector, config, addressProperty, mcastSocketAddress.getAddress().getHostAddress()); setSocketBindingProperty(introspector, config, portProperty, String.valueOf(mcastSocketAddress.getPort())); } catch (IllegalStateException e) { ROOT_LOGGER.couldNotSetAddressAndPortNoMulticastSocket(e, config.getProtocolName(), addressProperty, config.getProtocolName(), portProperty, binding.getName()); } }
final SocketBinding socketBinding = iiopSocketBindingInjector.getOptionalValue(); final SocketBinding sslSocketBinding = this.iiopSSLSocketBindingInjector.getOptionalValue(); InetSocketAddress address = this.iiopSocketBindingInjector.getValue().getSocketAddress(); properties.setProperty(ORBConstants.SERVER_HOST_PROPERTY, address.getAddress().getHostAddress()); properties.setProperty(ORBConstants.SERVER_PORT_PROPERTY, String.valueOf(address.getPort())); properties.setProperty(ORBConstants.PERSISTENT_SERVER_PORT_PROPERTY, String.valueOf(address.getPort())); socketBinding.getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(socketBinding)); InetSocketAddress address = this.iiopSSLSocketBindingInjector.getValue().getSocketAddress(); properties.setProperty(ORBConstants.SERVER_HOST_PROPERTY, address.getAddress().getHostAddress()); properties.setProperty(Constants.ORB_SSL_PORT, String.valueOf(address.getPort())); final String sslSocket = new StringBuilder().append(Constants.SSL_SOCKET_TYPE).append(':') properties.setProperty(ORBConstants.LISTEN_SOCKET_PROPERTY, sslSocket); if (!properties.containsKey(Constants.ORB_ADDRESS)) { properties.setProperty(Constants.ORB_ADDRESS, address.getAddress().getHostAddress()); sslSocketBinding.getSocketBindings().getNamedRegistry().registerBinding(ManagedBinding.Factory.createSimpleManagedBinding(sslSocketBinding));
SocketBinding connectorSocketBindingValue = connectorSocketBinding.getValue(); String connectorAddress = connectorSocketBindingValue.getAddress().getHostAddress(); String connectorPort = String.valueOf(connectorSocketBindingValue.getAbsolutePort()); if (connectorAddress.equals("0.0.0.0") || connectorAddress.equals("::/128")) { connectorAddress = InetAddress.getLocalHost().getCanonicalHostName(); msglog.infoBrokerBindingToSocket(connectorAddress, connectorPort); SocketBinding discoverySocketBindingValue = discoverySocketBinding.getValue(); String discoveryAddress = discoverySocketBindingValue.getMulticastAddress().getHostAddress(); String discoveryPort = String.valueOf(discoverySocketBindingValue.getMulticastPort()); customConfigProperties.put(BrokerSubsystemExtension.BROKER_DISCOVERY_ADDRESS_SYSPROP, discoveryAddress); customConfigProperties.put(BrokerSubsystemExtension.BROKER_DISCOVERY_PORT_SYSPROP, discoveryPort); msglog.infoBrokerDiscoveryEndpoint(discoveryAddress, discoveryPort); ServerEnvironment env = envServiceValue.getValue(); BrokerConfigurationSetup configSetup = new BrokerConfigurationSetup(configurationFile, customConfigProperties, env);
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); }
/** * Get the socket address. * * @return the socket address */ public InetSocketAddress getSocketAddress() { int port = calculatePort(); return new InetSocketAddress(getAddress(), port); }
private void configureBindAddress(ProtocolConfiguration protocol, org.jgroups.conf.ProtocolConfiguration config, SocketBinding binding) { this.setPropertyNoOverride(protocol, config, "bind_addr", binding.getSocketAddress().getAddress().getHostAddress()); }
final SocketBinding recoveryBinding = recoveryBindingInjector.getValue(); recoveryEnvironmentBean.setRecoveryInetAddress(recoveryBinding.getSocketAddress().getAddress()); recoveryEnvironmentBean.setRecoveryPort(recoveryBinding.getSocketAddress().getPort()); final SocketBinding statusBinding = statusBindingInjector.getValue(); recoveryEnvironmentBean.setTransactionStatusManagerInetAddress(statusBinding.getSocketAddress().getAddress()); recoveryEnvironmentBean.setTransactionStatusManagerPort(statusBinding.getSocketAddress().getPort()); recoveryEnvironmentBean.setRecoveryListener(recoveryListener); bindingManager.getValue().getNamedRegistry().registerBinding(binding);
@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()); } }
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); }
@Override public void unadvertise(String name, SocketBinding binding) { this.advertiser.unadvertise(name, binding.getAddress().getHostAddress(), binding.getAbsolutePort() ); }
private int getDestinationPort() { final SocketBinding localDestinationSocketBinding = this.localDestinationSocketBindingInjectedValue.getValue(); // instead of directly using SocketBinding.getPort(), we go via the SocketBinding.getSocketAddress() // since the getPort() method doesn't take into account whether the port is a fixed port or whether an offset // needs to be added. Alternatively, we could introduce a getAbsolutePort() in the SocketBinding class. final InetSocketAddress socketAddress = localDestinationSocketBinding.getSocketAddress(); return socketAddress.getPort(); }
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; } }
private URL getConnectionURL() throws StartException { SocketBinding socketBinding = injectedHttpSocketBinding.getValue(); InetAddress address = socketBinding.getNetworkInterfaceBinding().getAddress(); URL result; try { String hostAddress = NetworkUtils.formatPossibleIpv6Address(address.getHostAddress()); result = new URL(socketBinding.getName() + "://" + hostAddress + ":" + socketBinding.getPort()); } catch (MalformedURLException ex) { throw new StartException(ex); } return result; }
@Override public void accept(T protocol) { InetSocketAddress socketAddress = this.getSocketBinding().getSocketAddress(); protocol.setBindAddress(socketAddress.getAddress()); protocol.setBindPort(socketAddress.getPort()); protocol.setThreadFactory(new ClassLoaderThreadFactory(new DefaultThreadFactory("jgroups", false, true), JChannelFactory.class.getClassLoader())); protocol.setThreadPool(this.threadPoolFactory.get().apply(protocol.getThreadFactory())); protocol.setInternalThreadPoolThreadFactory(new ClassLoaderThreadFactory(new DefaultThreadFactory("jgroups-int", false, false), JChannelFactory.class.getClassLoader())); // Because we provide the transport with a thread pool, TP.init() won't auto-create the internal thread pool // So create one explicitly matching the logic in TP.init() but with our thread factory QueuelessThreadPoolFactory factory = new QueuelessThreadPoolFactory() .setMaxThreads(Math.max(4, Runtime.getRuntime().availableProcessors())) .setKeepAliveTime(30000) ; protocol.setInternalThreadPool(factory.apply(protocol.getInternalThreadPoolThreadFactory())); protocol.setValue("enable_diagnostics", this.diagnosticsSocketBinding != null); if (this.diagnosticsSocketBinding != null) { InetSocketAddress address = this.diagnosticsSocketBinding.get().getSocketAddress(); protocol.setValue("diagnostics_addr", address.getAddress()); protocol.setValue("diagnostics_port", address.getPort()); } }