Client on rsocket client transport.

@param clientSettings client settings
@return client
774335
public static Client rsocket(ClientSettings clientSettings) {
    RSocketClientCodec clientCodec =
        new RSocketClientCodec(
            HeadersCodec.getInstance(clientSettings.contentType()),
            DataCodec.getInstance(clientSettings.contentType()));

    RSocketClientTransport clientTransport =
        new RSocketClientTransport(clientSettings, clientCodec, clientSettings.loopResources());

    return new Client(clientTransport, clientCodec, clientSettings.errorMapper());
  }
342130
@Override
  public ClientSocket open()
  {
    State state = _state;
    
    if (! state.isInit())
      return null;

    ClientSocket stream = openRecycle();

    if (stream != null)
      return stream;

    return connect();
  }
1148195
@Override
	public String getClientID() throws JMSException
    {
    	externalAccessLock.readLock().lock();
    	try
		{
	        if (clientID == null)
	            throw new InvalidClientIDException("Client ID not set");
	        return clientID;
		}
    	finally
    	{
    		externalAccessLock.readLock().unlock();
    	}
    }
919769
protected function clientSettings(array $configs, ContainerBuilder $container)
    {
        foreach($configs as $key => $infos){
            $clientDefinition = new Definition();
            $clientDefinition->setClass($infos['class']);
            
            $hostsSettings = $this->hostSettings($infos);
            $logPathSettings = $this->logPathSettings($infos);
            $logLevelSettings = $this->logLevelSettings($infos);
            
            $options = array(
                            'hosts' => $hostsSettings,
                            'logPath' => $logPathSettings,
                            'logLevel' => $logLevelSettings
                            );
            
            $clientDefinition->setArguments(array($options));
            
            $clientServiceId = 'ushios_elastic_search_client';
            if ($key == 'default'){
                $container->setDefinition($clientServiceId, $clientDefinition);
                $clientServiceId = $clientServiceId.'.default';
            }else{
                $clientServiceId = $clientServiceId.'.'.$key;
            }
    
            $container->setDefinition($clientServiceId, $clientDefinition);
        }
    }
483633
protected synchronized ServerSocket initServerSocket() throws IOException, RetryableChannelException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "ServerSocket called, new ServerSocket needs to be created");
        }
        TCPChannelConfiguration channelConfig = tcpChannel.getConfig();

        IOException bindError = null;
        BindInfo earlyBind = portBoundEarly(channelConfig.getPort());

        if (earlyBind == null) {
            InetSocketAddress socketAddress = null;

            if (channelConfig.getHostname() == null) {
                socketAddress = new InetSocketAddress((InetAddress) null, channelConfig.getPort());
            } else {
                socketAddress = new InetSocketAddress(channelConfig.getHostname(), channelConfig.getPort());
            }

            if (!socketAddress.isUnresolved()) {
                serverSocket = openServerSocket();

                // receieve buffer size for accepted sockets is set on serverSocket,
                // send buffer size is set on individual sockets

                if ((channelConfig.getReceiveBufferSize() >= TCPConfigConstants.RECEIVE_BUFFER_SIZE_MIN)
                    && (channelConfig.getReceiveBufferSize() <= TCPConfigConstants.RECEIVE_BUFFER_SIZE_MAX)) {
                    serverSocket.setReceiveBufferSize(channelConfig.getReceiveBufferSize());
                }
                if (!channelConfig.getSoReuseAddress()) {
                    //Forced re-use==false custom property
                    try {
                        attemptSocketBind(socketAddress, false);
                    } catch (IOException e) {
                        // no FFDC
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "Forced re-use==false bind attempt failed, ioe=" + e);
                        }
                        bindError = e;
                    }
                } else {
                    //re-use==true (default)
                    // try the standard startup attempts
                    try {
                        attemptSocketBind(socketAddress, false);
                        //If we are not on Windows and the bind succeeded, we should set reuseAddr=true
                        //for future binds.
                        if (!TCPFactoryConfiguration.isWindows()) {
                            this.serverSocket.setReuseAddress(true);
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(tc, "ServerSocket reuse set to true to allow for later override");
                            }
                        }
                    } catch (IOException ioe) {
                        // See if we got the error because the port is in waiting to be cleaned up.
                        // If so, no one should be accepting connections on it, and open should fail.
                        // If that's the case, we can set ReuseAddr to expedite the bind process.
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "ServerSocket bind failed on first attempt with IOException: " + ioe.getMessage());
                        }
                        bindError = ioe;
                        try {
                            String hostName = channelConfig.getHostname();
                            if (hostName == null) {
                                hostName = "localhost";
                            }
                            InetSocketAddress testAddr = new InetSocketAddress(hostName, channelConfig.getPort());
                            // PK40741 - test for localhost being resolvable before using it
                            if (!testAddr.isUnresolved()) {
                                SocketChannel testChannel = SocketChannel.open(testAddr);
                                // if we get here, socket opened successfully, which means
                                // someone is really listening
                                // so close connection and don't bother trying to bind again
                                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                    Tr.debug(tc, "attempt to connect to port to check listen status worked, someone else is using the port!");
                                }
                                testChannel.close();
                            } else {
                                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                    Tr.debug(tc, "Test connection addr is unresolvable; " + testAddr);
                                }
                            }
                        } catch (IOException testioe) {
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(tc, "attempt to connect to port to check listen status failed with IOException: " + testioe.getMessage());
                            }
                            try {
                                // open (or close) got IOException, retry with reuseAddr on
                                attemptSocketBind(socketAddress, true);
                                bindError = null;

                            } catch (IOException newioe) {
                                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                    Tr.debug(tc, "ServerSocket bind failed on second attempt with IOException: " + newioe.getMessage());
                                }
                                bindError = newioe;
                            }
                        }
                    }
                }

                if (bindError == null) {
                    // listen port can be different than config port if configed port is '0'
                    listenPort = serverSocket.getLocalPort();
                } else {
                    String displayableHostName = channelConfig.getDisplayableHostname();

                    // add in the exception message to help in problem diagnostics without tracing
                    Tr.error(tc, TCPChannelMessageConstants.BIND_ERROR,
                             new Object[] { channelConfig.getChannelData().getExternalName(), displayableHostName, String.valueOf(channelConfig.getPort()),
                                            bindError.getMessage() });

                    throw new RetryableChannelException(bindError.getMessage());
                }

            } else { // unresolved socket address
                String displayableHostName = channelConfig.getDisplayableHostname();
                Tr.error(tc, TCPChannelMessageConstants.LOCAL_HOST_UNRESOLVED,
                         new Object[] { channelConfig.getChannelData().getExternalName(), displayableHostName, String.valueOf(channelConfig.getPort()) });

                throw new RetryableChannelException(new IOException("local address unresolved"));
            }

        } else {
            // this port was bound earlier by a different service
            Exception e = earlyBind.getBindException();
            if (e == null) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Found early bind, setting serverSocket and listenPort");
                }

                serverSocket = earlyBind.getServerSocket();
                // listen port can be different than config port if configed port is '0'
                listenPort = serverSocket.getLocalPort();
            } else {

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Early Bind generated the following exception: " + e);
                }

                // add in the exception message to help in problem diagnostics without tracing
                Tr.error(tc, TCPChannelMessageConstants.BIND_ERROR,
                         new Object[] { channelConfig.getChannelData().getExternalName(), earlyBind.getHostname(), String.valueOf(earlyBind.getPort()), e.getMessage() });

                if (e instanceof IOException) {
                    throw (IOException) e;
                }
                if (e instanceof RetryableChannelException) {
                    throw (RetryableChannelException) e;
                }
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "new ServerSocket successfully created");
        }

        return this.serverSocket;
    }
181459
public GetStageResult withRouteSettings(java.util.Map<String, RouteSettings> routeSettings) {
        setRouteSettings(routeSettings);
        return this;
    }
983770
protected function configureClient(Client $client, array $settings)
    {
        $configuredClient = $client ?: new Client();

        // Set authentication, if necessary:
        if (!empty($settings['httpUser']) && !empty($settings['httpPass'])) {
            $configuredClient->setAuth($settings['httpUser'], $settings['httpPass']);
        }

        // Set up assorted client options from $settings array:
        $configuredClient->setOptions($this->getClientOptions($settings));

        return $configuredClient;
    }
796984
public SSLEngine buildServerSSLEngine(SSLContext sslContext) {
        SSLEngine engine = sslContext.createSSLEngine();
        engine.setUseClientMode(false);
        if (needClientAuth) {
            engine.setNeedClientAuth(true);
        } else if (wantClientAuth) {
            engine.setWantClientAuth(true);
        }
        return addCommonConfigs(engine);
    }
413429
public static Server getServer(final Settings settings, final String serverId) {
        if (settings == null || StringUtils.isEmpty(serverId)) {
            return null;
        }
        return settings.getServer(serverId);
    }
1285382
private ServerSocket createServerSocket(int port) throws IOException {
    try {
      ServerSocket sock = new ServerSocket();
      // Prevent 2MSL delay problem on server restarts
      sock.setReuseAddress(true);
      // Bind to listening port
      if (port == 0) {
        sock.bind(null);
        serverPort = sock.getLocalPort();
      } else {
        sock.bind(new InetSocketAddress(port));
      }
      return sock;
    } catch (IOException ioe) {
      throw new IOException("Could not create ServerSocket on port " + port + "." +
                            ioe);
    }
  }
630226
protected void configureCasClient(final Collection<BaseClient> properties) {
        val index = new AtomicInteger();
        pac4jProperties.getCas()
            .stream()
            .filter(cas -> StringUtils.isNotBlank(cas.getLoginUrl()))
            .forEach(cas -> {
                val cfg = new CasConfiguration(cas.getLoginUrl(), CasProtocol.valueOf(cas.getProtocol()));
                cfg.setLogoutHandler(casServerSpecificLogoutHandler);
                val client = new CasClient(cfg);

                val count = index.intValue();
                if (StringUtils.isBlank(cas.getClientName())) {
                    client.setName(client.getClass().getSimpleName() + count);
                }
                client.setCallbackUrlResolver(new PathParameterCallbackUrlResolver());
                configureClient(client, cas);

                index.incrementAndGet();
                LOGGER.debug("Created client [{}]", client);
                properties.add(client);
            });
    }
180087
private SocketStoreClientFactory getFatClientFactory(String[] bootstrapURLs,
                                                         Properties configProps) {

        ClientConfig fatClientConfig = new ClientConfig(configProps);
        logger.info("Using config: " + fatClientConfig);
        fatClientConfig.setBootstrapUrls(bootstrapURLs)
                       .setEnableCompressionLayer(false)
                       .setEnableSerializationLayer(false)
                       .enableDefaultClient(true)
                       .setEnableLazy(false);

        return new SocketStoreClientFactory(fatClientConfig);
    }
764005
public ClientHandshakeFuture handshake() {
        final DefaultClientHandshakeFuture handshakeFuture = new DefaultClientHandshakeFuture();
        try {
            URI uri = new URI(url);

            String scheme = uri.getScheme();
            if (!Constants.WS_SCHEME.equalsIgnoreCase(scheme) && !Constants.WSS_SCHEME.equalsIgnoreCase(scheme)) {
                LOG.error("Only WS(S) is supported.");
                throw new URISyntaxException(url, "WebSocket client supports only WS(S) scheme");
            }

            final String host = uri.getHost() == null ? "127.0.0.1" : uri.getHost();
            final int port = getPort(uri);
            final boolean ssl = Constants.WSS_SCHEME.equalsIgnoreCase(scheme);
            WebSocketClientHandshaker webSocketHandshaker = WebSocketClientHandshakerFactory.newHandshaker(
                    uri, WebSocketVersion.V13, subProtocols, true, headers, maxFrameSize);
            MessageQueueHandler messageQueueHandler = new MessageQueueHandler();
            clientHandshakeHandler = new WebSocketClientHandshakeHandler(webSocketHandshaker, handshakeFuture,
                                                                         messageQueueHandler, ssl, autoRead, url,
                                                                         handshakeFuture);
            Bootstrap clientBootstrap = initClientBootstrap(host, port, handshakeFuture);
            clientBootstrap.connect(uri.getHost(), port).sync();
        } catch (Exception throwable) {
            handleHandshakeError(handshakeFuture, throwable);
        }
        return handshakeFuture;
    }
1374024
public Client newClient(String clientName, JaxRsFeatureGroup feature, JaxRsFeatureGroup... moreFeatures) {
        return newBuilder(clientName, feature, moreFeatures).build();
    }
772017
public static Client using(final Configuration configuration, final ClientConsumerType type, final int poolSize) throws Exception {
    return new Client(configuration, type, poolSize);
  }
787401
public StoredChannel setClientToken(String clientToken) {
    lock.lock();
    try {
      this.clientToken = clientToken;
    } finally {
      lock.unlock();
    }
    return this;
  }
1102777
private void initConnectionSettings(Configuration conf,
      ClientConfiguration clientConf) throws IOException {
    clientConf.setMaxConnections(Utils.getInt(conf, FS_COS, FS_ALT_KEYS,
        MAXIMUM_CONNECTIONS, DEFAULT_MAXIMUM_CONNECTIONS));
    clientConf.setClientExecutionTimeout(Utils.getInt(conf, FS_COS, FS_ALT_KEYS,
        CLIENT_EXEC_TIMEOUT, DEFAULT_CLIENT_EXEC_TIMEOUT));
    clientConf.setMaxErrorRetry(Utils.getInt(conf, FS_COS, FS_ALT_KEYS,
        MAX_ERROR_RETRIES, DEFAULT_MAX_ERROR_RETRIES));
    clientConf.setConnectionTimeout(Utils.getInt(conf, FS_COS, FS_ALT_KEYS,
        ESTABLISH_TIMEOUT, DEFAULT_ESTABLISH_TIMEOUT));
    clientConf.setSocketTimeout(Utils.getInt(conf, FS_COS, FS_ALT_KEYS,
        SOCKET_TIMEOUT, DEFAULT_SOCKET_TIMEOUT));
    clientConf.setRequestTimeout(Utils.getInt(conf, FS_COS, FS_ALT_KEYS,
        REQUEST_TIMEOUT, DEFAULT_REQUEST_TIMEOUT));
    int sockSendBuffer = Utils.getInt(conf, FS_COS, FS_ALT_KEYS,
        SOCKET_SEND_BUFFER, DEFAULT_SOCKET_SEND_BUFFER);
    int sockRecvBuffer = Utils.getInt(conf, FS_COS, FS_ALT_KEYS,
        SOCKET_RECV_BUFFER, DEFAULT_SOCKET_RECV_BUFFER);
    clientConf.setSocketBufferSizeHints(sockSendBuffer, sockRecvBuffer);
    String signerOverride = Utils.getTrimmed(conf, FS_COS, FS_ALT_KEYS,
        SIGNING_ALGORITHM, "");
    if (!signerOverride.isEmpty()) {
      LOG.debug("Signer override = {}", signerOverride);
      clientConf.setSignerOverride(signerOverride);
    }

    String userAgentPrefix = Utils.getTrimmed(conf, FS_COS, FS_ALT_KEYS,
        USER_AGENT_PREFIX, DEFAULT_USER_AGENT_PREFIX);
    String userAgentName = singletoneInitTimeData.getUserAgentName();
    if (!userAgentPrefix.equals(DEFAULT_USER_AGENT_PREFIX)) {
      userAgentName = userAgentPrefix + " " + userAgentName;
    }
    clientConf.setUserAgentPrefix(userAgentName);
  }