Examples of NiftyClient


Examples of com.facebook.nifty.client.NiftyClient

        this(new ThriftCodecManager());
    }

    public ThriftClientManager(ThriftCodecManager codecManager)
    {
        this(codecManager, new NiftyClient(), ImmutableSet.<ThriftClientEventHandler>of());
    }
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClient

        this.protocolFactory = protocolFactory;
    }

    @Override
    protected void startUp() throws Exception {
        niftyClient = new NiftyClient(nettyClientConfig);
    }
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClient

        this.protocolFactory = protocolFactory;
    }

    @Override
    protected void startUp() throws Exception {
        niftyClient = new NiftyClient(nettyClientConfig);
    }
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClient

    public TNiftyClientChannelTransportPoolConfig(final int bossThreads, final int workerThreads, final Class<? extends TServiceClient> clientClass) {
        this(new NettyClientConfigBuilder().setWorkerThreadCount(workerThreads).setBossThreadCount(bossThreads).build(), clientClass);
    }

    public TNiftyClientChannelTransportPoolConfig(final NettyClientConfig nettyClientConfig, final Class<? extends TServiceClient> clientClass) {
        this(new NiftyClient(nettyClientConfig), clientClass);
    }
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClient

    public ThriftClientConnectionPoolConfig(final int bossThreads, final int workerThreads, final Class<T> clientClass, final Class<U> serviceInterface) {
        this(new NettyClientConfigBuilder().setWorkerThreadCount(workerThreads).setBossThreadCount(bossThreads).build(), clientClass, serviceInterface);
    }

    public ThriftClientConnectionPoolConfig(final NettyClientConfig nettyClientConfig, final Class<T> clientClass, final Class<U> serviceInterface) {
        this(new NiftyClient(nettyClientConfig), clientClass, serviceInterface);
    }
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClient

    private scribe.Client makeNiftyClient()
            throws TTransportException, InterruptedException
    {
        InetSocketAddress address = new InetSocketAddress("localhost", port);
        TBinaryProtocol tp = new TBinaryProtocol(new NiftyClient().connectSync(address));
        return new scribe.Client(tp);
    }
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClient

    @Test(timeOut = 2000)
    public void testSyncConnectTimeout() throws ConnectException, IOException
    {
        ServerSocket serverSocket = new ServerSocket(0);
        int port = serverSocket.getLocalPort();
        final NiftyClient client = new NiftyClient();
        try {
                client.connectSync(new InetSocketAddress(port),
                                   TEST_CONNECT_TIMEOUT,
                                   TEST_READ_TIMEOUT,
                                   TEST_WRITE_TIMEOUT);
        }
        catch (Throwable throwable) {
            if (isTimeoutException(throwable)) {
                return;
            }
            Throwables.propagate(throwable);
        }
        finally {
            client.close();
            serverSocket.close();
        }

        // Should never get here
        fail("Connection succeeded but failure was expected");
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClient

    public void testAsyncConnectTimeout() throws IOException
    {
        ServerSocket serverSocket = new ServerSocket(0);
        int port = serverSocket.getLocalPort();

        final NiftyClient client = new NiftyClient();
        try {
            ListenableFuture<FramedClientChannel> future =
                            client.connectAsync(new FramedClientConnector(new InetSocketAddress(port)),
                                                TEST_CONNECT_TIMEOUT,
                                                TEST_READ_TIMEOUT,
                                                TEST_WRITE_TIMEOUT);
            // Wait while NiftyClient attempts to connect the channel
            future.get();
        }
        catch (Throwable throwable) {
            if (isTimeoutException(throwable)) {
                return;
            }
            Throwables.propagate(throwable);
        }
        finally {
            client.close();
            serverSocket.close();
        }

        // Should never get here
        fail("Connection succeeded but failure was expected");
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClient

    @Test
    public void testServerDisconnect()
            throws Exception
    {
        startServer();
        final NiftyClient niftyClient = new NiftyClient();
        scribe.Client client = makeNiftyClient(niftyClient);
        new Thread()
        {
            @Override
            public void run()
            {
                try {
                    sleep(1000L);
                    bootstrap.stop();
                }
                catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                }
            }
        }.start();

        int max = (int) (Math.random() * 100) + 10;
        int exceptionCount = 0;
        for (int i = 0; i < max; i++) {
            Thread.sleep(100L);
            try {
                client.Log(Arrays.asList(new LogEntry("hello", "world " + i)));
            }
            catch (TException e) {
                log.info("caught expected exception " + e.toString());
                exceptionCount++;
            }
        }
        Assert.assertTrue(exceptionCount > 0);

        niftyClient.close();
    }
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClient

    private scribe.Client makeNiftyClient()
            throws TTransportException, InterruptedException
    {
        InetSocketAddress address = new InetSocketAddress("localhost", port);
        TBinaryProtocol tp = new TBinaryProtocol(new NiftyClient().connectSync(address));
        return new scribe.Client(tp);
    }
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.