Examples of NiftyClient


Examples of com.facebook.nifty.client.NiftyClient

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

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

    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_SEND_TIMEOUT,
                                   TEST_MAX_FRAME_SIZE);
        }
        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_RECEIVE_TIMEOUT,
                                                TEST_READ_TIMEOUT,
                                                TEST_SEND_TIMEOUT,
                                                TEST_MAX_FRAME_SIZE);
            // 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
    {
        try (ScopedNiftyServer server = makeServer()) {
            final NiftyClient niftyClient = new NiftyClient();
            scribe.Client client = makeNiftyClient(niftyClient, server);
            new Thread()
            {
                @Override
                public void run()
                {
                    try {
                        sleep(1000L);
                        server.close();
                    }
                    catch (InterruptedException e) {
                        Thread.currentThread().interrupt();
                    } catch (Exception e) {
                        Throwables.propagate(e);
                    }
                }
            }.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

Examples of com.facebook.nifty.client.NiftyClient

    }

    public ThriftClientManager(ThriftCodecManager codecManager)
    {
        this.codecManager = codecManager;
        this.niftyClient = new NiftyClient();
    }
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClient

    }

    public ThriftClientManager(ThriftCodecManager codecManager)
    {
        this.codecManager = codecManager;
        this.niftyClient = new NiftyClient();
    }
View Full Code Here

Examples of com.facebook.nifty.client.NiftyClient

        this.configuration = configuration;
    }

    @Override
    protected void startUp() throws Exception {
        niftyClient = new NiftyClient(configuration.clientConfig());
    }
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.