Package com.facebook.swift.service

Examples of com.facebook.swift.service.ThriftClientManager


     * An example that manually creates a {@link ThriftClientManager} and a {@link ThriftClient}
     * but lets the {@link ClientExampleHelper} open the connection
     */
    private static void thriftClientFactoryExample() throws ExecutionException, InterruptedException
    {
        try (ThriftClientManager clientManager = new ThriftClientManager())
        {
            ThriftClient<ExampleService> thriftClient = new ThriftClient<>(clientManager, ExampleService.class);
            new ClientExampleHelper(thriftClient, "thriftClientFactoryExample").execute();
        }
    }
View Full Code Here


        injector.destroy();
    }

    private static void collectCounters() throws ExecutionException, InterruptedException
    {
        try (ThriftClientManager clientManager = new ThriftClientManager();
             Fb303 rawClient = clientManager.createClient(ClientExampleHelper.getConnector(), Fb303.class).get())
        {
            LOGGER.info("fb303 counters:\n{}", Joiner.on("\n").join(new TreeMap<>(rawClient.getCounters()).entrySet()));
        }
    }
View Full Code Here

        }
    }

    private static void shutdownServer() throws ExecutionException, InterruptedException
    {
        try (ThriftClientManager clientManager = new ThriftClientManager();
             Fb303 rawClient = clientManager.createClient(ClientExampleHelper.getConnector(), Fb303.class).get())
        {
            rawClient.shutdown();
        }
    }
View Full Code Here

    @BeforeMethod(alwaysRun = true)
    public void setup()
            throws IllegalAccessException, InstantiationException, TException
    {
        codecManager = new ThriftCodecManager();
        clientManager = new ThriftClientManager(codecManager);
        syncServer = createSyncServer();
    }
View Full Code Here

    private void setup() throws Exception
    {
        InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());

        codecManager = new ThriftCodecManager();
        clientManager = new ThriftClientManager(codecManager);
        syncServer = createTargetServer(TARGET_SERVER_THREAD_COUNT);
        asyncServer = createAsyncServer(PROXY_SERVER_THREAD_COUNT, clientManager, syncServer);
    }
View Full Code Here

    @Test
    public void testUnframedSyncMethod()
            throws Exception
    {
        TestServerInfo info = startServer();
        ThriftClientManager clientManager = new ThriftClientManager();

        try (Scribe client = createUnframedClient(clientManager, Scribe.class, info.port).get()) {
            ResultCode result = client.log(Lists.newArrayList(
                    new LogEntry("testCategory", "testMessage")));
            assertEquals(result, ResultCode.OK);
View Full Code Here

    @Test
    public void testUnframedAsyncMethod()
            throws Exception
    {
        TestServerInfo info = startServer();
        ThriftClientManager clientManager = new ThriftClientManager();
        final CountDownLatch latch = new CountDownLatch(1);
        final ResultCode[] resultHolder = new ResultCode[1];

        ListenableFuture<AsyncScribe> clientFuture = createUnframedClient(clientManager, AsyncScribe.class, info.port);
        Futures.addCallback(clientFuture, new FutureCallback<AsyncScribe>()
View Full Code Here

        ThriftServiceProcessor processor = new ThriftServiceProcessor(new ThriftCodecManager(), ImmutableList.<ThriftEventHandler>of(), puma);

        // create server and client
        try (
                ThriftServer server = new ThriftServer(processor).start();
                ThriftClientManager clientManager = new ThriftClientManager();
                PumaReadService pumaClient = clientManager.createClient(
                        new FramedClientConnector(fromParts("localhost", server.getPort())),
                        PumaReadService.class).get()
        ) {
            // invoke puma
            List<ReadResultQueryInfoTimeString> results = pumaClient.getResultTimeString(PUMA_REQUEST);
View Full Code Here

        puma.setException(exception);

        NiftyProcessor processor = new ThriftServiceProcessor(new ThriftCodecManager(), ImmutableList.<ThriftEventHandler>of(), puma);
        try (
                ThriftServer server = new ThriftServer(processor).start();
                ThriftClientManager clientManager = new ThriftClientManager();
                PumaReadService pumaClient = clientManager.createClient(
                        new FramedClientConnector(HostAndPort.fromParts("localhost", server.getPort())),
                        PumaReadService.class).get()
        ) {
            pumaClient.getResultTimeString(PUMA_REQUEST);
            fail("Expected ReadSemanticException");
View Full Code Here

    {
        ThriftCodecManager codecManager = new ThriftCodecManager();
        ThriftServiceProcessor processor = new ThriftServiceProcessor(codecManager, ImmutableList.<ThriftEventHandler>of(), new GenericService());

        try (ThriftServer server = new ThriftServer(processor, new ThriftServerConfig()).start();
             ThriftClientManager clientManager = new ThriftClientManager(codecManager)) {
            ThriftClient<GenericInterface.Client> clientOpener = new ThriftClient<>(clientManager, GenericInterface.Client.class);
            try (GenericInterface.Client client = clientOpener.open(new FramedClientConnector(HostAndPort.fromParts("localhost", server.getPort()))).get()) {
                GenericStruct<String> original = new GenericStruct<>();
                original.genericField = "original.genericField";
                GenericStruct<String> copy = client.echo(original);
View Full Code Here

TOP

Related Classes of com.facebook.swift.service.ThriftClientManager

Copyright © 2018 www.massapicom. 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.