Examples of NiftyClientChannel


Examples of com.facebook.nifty.client.NiftyClientChannel

     * @throws IllegalArgumentException if the client is not a Swift client or is not connected
     * through an internet socket
     */
    public HostAndPort getRemoteAddress(Object client)
    {
        NiftyClientChannel niftyChannel = getNiftyChannel(client);

        try {
            Channel nettyChannel = niftyChannel.getNettyChannel();
            SocketAddress address = nettyChannel.getRemoteAddress();
            InetSocketAddress inetAddress = (InetSocketAddress) address;
            return HostAndPort.fromParts(inetAddress.getHostName(), inetAddress.getPort());
        }
        catch (NullPointerException | ClassCastException e) {
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClientChannel

            final Duration writeTimeout,
            final int maxFrameSize,
            final String clientName,
            HostAndPort socksProxy)
    {
        NiftyClientChannel channel = null;
        try {
            final SettableFuture<T> clientFuture = SettableFuture.create();
            ListenableFuture<C> connectFuture =
                    niftyClient.connectAsync(connector,
                                             connectTimeout,
                                             readTimeout,
                                             writeTimeout,
                                             maxFrameSize,
                                             this.toSocksProxyAddress(socksProxy));
            Futures.addCallback(connectFuture, new FutureCallback<C>()
            {
                @Override
                public void onSuccess(C result)
                {
                    NiftyClientChannel channel = result;

                    if (readTimeout.toMillis() > 0) {
                        channel.setReceiveTimeout(readTimeout);
                    }
                    if (writeTimeout.toMillis() > 0) {
                        channel.setSendTimeout(writeTimeout);
                    }
                    clientFuture.set(createClient(channel, type, Strings.isNullOrEmpty(clientName) ? connector.toString() : clientName));
                }

                @Override
                public void onFailure(Throwable t)
                {
                    clientFuture.setException(t);
                }
            });
            return clientFuture;
        }
        catch (RuntimeException | Error e) {
            if (channel != null) {
                channel.close();
            }
            throw e;
        }
    }
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClientChannel

     * @throws IllegalArgumentException if the client is not a Swift client or is not connected
     * through an internet socket
     */
    public HostAndPort getRemoteAddress(Object client)
    {
        NiftyClientChannel niftyChannel = getNiftyChannel(client);

        try {
            Channel nettyChannel = niftyChannel.getNettyChannel();
            SocketAddress address = nettyChannel.getRemoteAddress();
            InetSocketAddress inetAddress = (InetSocketAddress) address;
            return HostAndPort.fromParts(inetAddress.getHostName(), inetAddress.getPort());
        }
        catch (NullPointerException | ClassCastException e) {
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClientChannel

     * @throws IllegalArgumentException if the client is not a Swift client or is not connected
     * through an internet socket
     */
    public HostAndPort getRemoteAddress(Object client)
    {
        NiftyClientChannel niftyChannel = getNiftyChannel(client);

        try {
            Channel nettyChannel = niftyChannel.getNettyChannel();
            SocketAddress address = nettyChannel.getRemoteAddress();
            InetSocketAddress inetAddress = (InetSocketAddress) address;
            return HostAndPort.fromParts(inetAddress.getHostString(), inetAddress.getPort());
        }
        catch (NullPointerException | ClassCastException e) {
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClientChannel

                public void onSuccess(ClientWrapper result)
                {
                    logger.trace("Worker connected");

                    clientWrapper = result;
                    NiftyClientChannel channel = clientManager.getNiftyChannel(clientWrapper.getClient());

                    // Thrift clients are not thread-safe, and for maximum efficiency, new requests are made
                    // on the channel thread, as the pipeline starts to clear out. So we either need to
                    // synchronize on "sendRequest" or make the initial calls to fill the pipeline on the
                    // channel thread as well.
                    channel.executeInIoThread(new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            fillRequestPipeline(clientWrapper);
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClientChannel

     * @throws IllegalArgumentException if the client is not a Swift client or is not connected
     * through an internet socket
     */
    public HostAndPort getRemoteAddress(Object client)
    {
        NiftyClientChannel niftyChannel = getNiftyChannel(client);

        try {
            Channel nettyChannel = niftyChannel.getNettyChannel();
            SocketAddress address = nettyChannel.getRemoteAddress();
            InetSocketAddress inetAddress = (InetSocketAddress) address;
            return HostAndPort.fromParts(inetAddress.getHostString(), inetAddress.getPort());
        }
        catch (NullPointerException | ClassCastException e) {
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClientChannel

                    throw new TTransportException(channel.getError());
                }

                SocketAddress remoteAddress = null;
                try {
                    NiftyClientChannel niftyClientChannel = (NiftyClientChannel)channel;
                    remoteAddress = niftyClientChannel.getNettyChannel().getRemoteAddress();
                }
                catch (ClassCastException e) {
                    throw new IllegalArgumentException("The swift client uses a channel that is not a NiftyClientChannel", e);
                }
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClientChannel

            final Duration readTimeout,
            final Duration writeTimeout,
            final String clientName,
            HostAndPort socksProxy)
    {
        NiftyClientChannel channel = null;
        try {
            final SettableFuture<T> clientFuture = SettableFuture.create();
            ListenableFuture<C> connectFuture =
                    niftyClient.connectAsync(connector,
                                             connectTimeout,
                                             readTimeout,
                                             writeTimeout,
                                             this.toSocksProxyAddress(socksProxy));
            Futures.addCallback(connectFuture, new FutureCallback<C>()
            {
                @Override
                public void onSuccess(C result)
                {
                    NiftyClientChannel channel = result;

                    if (readTimeout.toMillis() > 0) {
                        channel.setReceiveTimeout(readTimeout);
                    }
                    if (writeTimeout.toMillis() > 0) {
                        channel.setSendTimeout(writeTimeout);
                    }
                    clientFuture.set(createClient(channel, type, Strings.isNullOrEmpty(clientName) ? connector.toString() : clientName));
                }

                @Override
                public void onFailure(Throwable t)
                {
                    clientFuture.setException(t);
                }
            });
            return clientFuture;
        }
        catch (RuntimeException | Error e) {
            if (channel != null) {
                channel.close();
            }
            throw e;
        }
    }
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClientChannel

     * @throws IllegalArgumentException if the client is not a Swift client or is not connected
     * through an internet socket
     */
    public HostAndPort getRemoteAddress(Object client)
    {
        NiftyClientChannel niftyChannel = getNiftyChannel(client);

        try {
            Channel nettyChannel = niftyChannel.getNettyChannel();
            SocketAddress address = nettyChannel.getRemoteAddress();
            InetSocketAddress inetAddress = (InetSocketAddress) address;
            return HostAndPort.fromParts(inetAddress.getHostString(), inetAddress.getPort());
        }
        catch (NullPointerException | ClassCastException e) {
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClientChannel

     * @throws IllegalArgumentException if the client is not a Swift client or is not connected
     * through an internet socket
     */
    public HostAndPort getRemoteAddress(Object client)
    {
        NiftyClientChannel niftyChannel = getNiftyChannel(client);

        try {
            Channel nettyChannel = niftyChannel.getNettyChannel();
            SocketAddress address = nettyChannel.getRemoteAddress();
            InetSocketAddress inetAddress = (InetSocketAddress) address;
            return HostAndPort.fromParts(inetAddress.getHostString(), inetAddress.getPort());
        }
        catch (NullPointerException | ClassCastException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.