Example usage for org.apache.thrift.server TThreadPoolServer serve

List of usage examples for org.apache.thrift.server TThreadPoolServer serve

Introduction

In this page you can find the example usage for org.apache.thrift.server TThreadPoolServer serve.

Prototype

public void serve() 

Source Link

Usage

From source file:com.facebook.infrastructure.service.CassandraServer.java

License:Apache License

public static void main(String[] args) throws Throwable {
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread t, Throwable e) {
            logger_.error("Fatal exception in thread " + t, e);
        }/*from w  w  w. j a va  2s.com*/
    });

    try {
        CassandraServer server = new CassandraServer();
        server.start();
        TThreadPoolServer threadPoolServer = thriftEngine(server);
        threadPoolServer.serve();
    } catch (Throwable x) {
        logger_.error("Fatal error; exiting", x);
        System.exit(1);
    }

}

From source file:tech.aroma.application.service.server.TcpServer.java

License:Apache License

public static void main(String[] args) throws TTransportException, SocketException {
    Injector injector = Guice.createInjector(new AromaServicesProvider(),
            new ModuleApplicationServiceOperations(), new ModuleApplicationService(),
            new ModuleCassandraDataRepositories(), new ModuleCassandraDevCluster());

    ApplicationService.Iface applicationService = injector.getInstance(ApplicationService.Iface.class);
    ApplicationService.Processor processor = new ApplicationService.Processor<>(applicationService);

    TServerSocket socket = new TServerSocket(PORT);
    socket.getServerSocket().setSoTimeout((int) SECONDS.toMillis(30));

    TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(socket)
            .protocolFactory(new TBinaryProtocol.Factory()).processor(processor).requestTimeout(60)
            .requestTimeoutUnit(SECONDS).minWorkerThreads(5).maxWorkerThreads(100);

    LOG.info("Starting Application Service at port {}", PORT);

    TThreadPoolServer server = new TThreadPoolServer(serverArgs);
    server.serve();
    server.stop();//from   www . j  a  v a2 s .co  m
}

From source file:tech.aroma.authentication.service.server.TcpServer.java

License:Apache License

public static void main(String[] args) throws TTransportException, SocketException {
    int port = getPortFromArgs(args);

    Injector injector = Guice.createInjector(new ModuleAuthenticationOperations(),
            new ModuleAuthenticationService(), new ModuleCassandraDataRepositories(),
            new ModuleCassandraDevCluster());

    AuthenticationService.Iface authenticationService = injector.getInstance(AuthenticationService.Iface.class);
    AuthenticationService.Processor processor = new AuthenticationService.Processor<>(authenticationService);

    TServerSocket socket = new TServerSocket(port);
    socket.getServerSocket().setSoTimeout((int) SECONDS.toMillis(30));

    TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(socket)
            .protocolFactory(new TBinaryProtocol.Factory()).processor(processor).requestTimeout(60)
            .requestTimeoutUnit(SECONDS).minWorkerThreads(5).maxWorkerThreads(100);

    LOG.info("Starting Authentication Service at port {}", port);

    TThreadPoolServer server = new TThreadPoolServer(serverArgs);
    server.serve();
    server.stop();/*from  w w  w.  j a  v  a  2s.c  o m*/
}

From source file:tech.aroma.service.server.TcpServer.java

License:Apache License

public static void main(String[] args) throws TTransportException, SocketException {
    Injector injector = Guice.createInjector(new ModuleAromaService(), new ModuleCassandraDataRepositories(),
            new ModuleCassandraDevCluster(), new ModuleEncryptionMaterialsDev(), new RestOfDependencies());

    AromaService.Iface aromaService = injector.getInstance(AromaService.Iface.class);
    AromaService.Processor processor = new AromaService.Processor<>(aromaService);

    TServerSocket socket = new TServerSocket(PORT);
    socket.getServerSocket().setSoTimeout((int) SECONDS.toMillis(30));

    TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(socket)
            .protocolFactory(new TBinaryProtocol.Factory()).processor(processor).requestTimeout(60)
            .requestTimeoutUnit(SECONDS).minWorkerThreads(5).maxWorkerThreads(100);

    LOG.info("Starting Aroma Service at port {}", PORT);

    TThreadPoolServer server = new TThreadPoolServer(serverArgs);
    server.serve();
    server.stop();//  w  w  w .  j  a va2s.co  m
}