Java 类org.apache.thrift.server.TNonblockingServer 实例源码

项目:ThriftJ    文件:ThriftServerTest2.java   
public static void main(String[] args){
    ExecutorService es = Executors.newFixedThreadPool(2);
    for(int i=0; i<ports.length; i++){
        final int index = i;
        es.execute(new Runnable() {
            @Override
            public void run() {
                try{
                    TNonblockingServerSocket socket = new TNonblockingServerSocket(ports[index]);
                    TestThriftJ.Processor processor = new TestThriftJ.Processor(new QueryImp());
                    TNonblockingServer.Args arg = new TNonblockingServer.Args(socket);
                    arg.protocolFactory(new TBinaryProtocol.Factory());
                    arg.transportFactory(new TFramedTransport.Factory());
                    arg.processorFactory(new TProcessorFactory(processor));
                    TServer server = new TNonblockingServer (arg);

                    logger.info("127.0.0.1:" + ports[index] + " start");
                    server.serve();
                }catch(Exception e){
                    logger.error("127.0.0.1:" + ports[index] + " error");
                }
            }
        });
    }
}
项目:ThriftJ    文件:ThriftServerTest.java   
public static void main(String[] args){
    ExecutorService es = Executors.newFixedThreadPool(2);
    for(int i=0; i<ports.length; i++){
        final int index = i;
        es.execute(new Runnable() {
            @Override
            public void run() {
                try{
                    TNonblockingServerSocket socket = new TNonblockingServerSocket(ports[index]);
                    TestThriftJ.Processor processor = new TestThriftJ.Processor(new QueryImp());
                    TNonblockingServer.Args arg = new TNonblockingServer.Args(socket);
                    arg.protocolFactory(new TBinaryProtocol.Factory());
                    arg.transportFactory(new TFramedTransport.Factory());
                    arg.processorFactory(new TProcessorFactory(processor));
                    TServer server = new TNonblockingServer(arg);

                    logger.info("127.0.0.1:" + ports[index] + " start");
                    server.serve();
                }catch(Exception e){
                    logger.error("127.0.0.1:" + ports[index] + " error");
                }
            }
        });
    }
}
项目:frc    文件:Application.java   
private static boolean createThrift() {
    String flag = getClassName() + ".createThrift";
    try {
        TProcessor tProcessor = new FrcService.Processor<FrcService.Iface>(theInstance);

        TNonblockingServerSocket tnbSocketTransport = new TNonblockingServerSocket(thrift_port);
        TNonblockingServer.Args tnbArgs = new TNonblockingServer.Args(tnbSocketTransport);
        tnbArgs.maxReadBufferBytes = DefaultValues.THRIFT_MAX_READ_BUF;
        tnbArgs.processor(tProcessor);
        // tnbArgs.transportFactory(new LCQTFramedTransport.Factory());
        tnbArgs.transportFactory(new TFramedTransport.Factory());
        tnbArgs.protocolFactory(new TBinaryProtocol.Factory());

        server = new TNonblockingServer(tnbArgs);
        // server.setServerEventHandler(new LCQTServerEventHandler());
        return true;
    } catch (Exception e) {
        FRCLogger.getInstance().warn(-100, flag, "exception", e);
        return false;
    }
}
项目:cassandra-kmean    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:ACaZoo    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:providence    文件:RPCThriftNonblockingSocketTest.java   
@Before
public void setUp() throws Exception {
    rc = copyResourceTo("/pvdrc", temp.getRoot());
    copyResourceTo("/test.thrift", temp.getRoot());

    impl = Mockito.mock(MyService.Iface.class);

    TNonblockingServerSocket transport = new TNonblockingServerSocket(0);
    server = new TNonblockingServer(new TNonblockingServer.Args(transport).protocolFactory(new TBinaryProtocol.Factory())
                                                                          .processor(new MyService.Processor<>(impl)));

    ExecutorService executor = Executors.newSingleThreadExecutor();
    executor.submit(server::serve);
    Thread.sleep(1);
    port = transport.getPort();

    exitCode = 0;
    rpc = new RPC(console.tty()) {
        @Override
        protected void exit(int i) {
            exitCode = i;
        }
    };
}
项目:providence    文件:NonblockingSocketClientHandlerTest.java   
@BeforeClass
public static void setUpServer() throws Exception {
    setDefaultPollDelay(10, TimeUnit.MILLISECONDS);

    serializer = new TBinaryProtocolSerializer();
    factory = new TBinaryProtocol.Factory();
    port = findFreePort();
    impl = Mockito.mock(Iface.class);

    TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
    server = new TNonblockingServer(
            new TNonblockingServer.Args(transport)
                    .protocolFactory(factory)
                    .processor(new Processor<>(impl)));

    executor = Executors.newSingleThreadExecutor();
    executor.submit(server::serve);
    address = new InetSocketAddress("localhost", port);
}
项目:scylla-tools-java    文件:CustomTNonBlockingServer.java   
@SuppressWarnings("resource")
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:GraphTrek    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:Cassandra-Wasef    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:stratio-cassandra    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:cassandra-cqlMod    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:wso2-cassandra    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:cassandra-trunk    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:pinpoint    文件:AsyncEchoTestServer.java   
public static AsyncEchoTestServer<TNonblockingServer> nonblockingServer(final TestEnvironment environment)
        throws TTransportException {
    TNonblockingServer server = new TNonblockingServer(new TNonblockingServer.Args(
            new TNonblockingServerSocket(environment.getPort())).processor(getAsyncProcessor())
            .inputProtocolFactory(environment.getProtocolFactory())
            .outputProtocolFactory(environment.getProtocolFactory()));
    return new AsyncEchoTestServer<TNonblockingServer>(server, environment) {
        @Override
        public SyncEchoTestClient getSynchronousClient() throws TTransportException {
            return new SyncEchoTestClient.ClientForNonblockingServer(environment);
        }

        @Override
        public AsyncEchoTestClient getAsynchronousClient() throws IOException {
            return new AsyncEchoTestClient.Client(environment);
        }
    };
}
项目:pinpoint    文件:SyncEchoTestServer.java   
public static SyncEchoTestServer<TNonblockingServer> nonblockingServer(final TestEnvironment environment)
        throws TTransportException {
    TNonblockingServer server = new TNonblockingServer(new TNonblockingServer.Args(
            new TNonblockingServerSocket(environment.getPort())).processor(getProcessor())
            .inputProtocolFactory(environment.getProtocolFactory())
            .outputProtocolFactory(environment.getProtocolFactory()));
    return new SyncEchoTestServer<TNonblockingServer>(server, environment) {
        @Override
        public SyncEchoTestClient getSynchronousClient() throws TTransportException {
            return new SyncEchoTestClient.ClientForNonblockingServer(environment);
        }

        @Override
        public AsyncEchoTestClient getAsynchronousClient() throws IOException {
            return new AsyncEchoTestClient.Client(environment);
        }
    };
}
项目:concrete-java    文件:ConcreteServer.java   
/**
 *
 */
public ConcreteServer(AnnotateCommunicationService.Iface impl, int port) throws ServerException {
  try {
    this.serverXport = new TNonblockingServerSocket(port);
    // TODO: eval HaHs server?
    final TNonblockingServer.Args args = new TNonblockingServer.Args(this.serverXport);
    args.protocolFactory(new TCompactProtocol.Factory());
    // TODO: eval FastFramedTransport?
    final TFramedTransport.Factory transFactory = new TFramedTransport.Factory(Integer.MAX_VALUE);
    args.transportFactory(transFactory);
    // legitimately do not know type bound here - guessing Iface
    AnnotateCommunicationService.Processor<Iface> proc = new AnnotateCommunicationService.Processor<>(impl);
    args.processorFactory(new TProcessorFactory(proc));
    args.maxReadBufferBytes = Long.MAX_VALUE;

    this.args = args;
    // final TNonblockingServer server = new TNonblockingServer(args);
    this.server = new TNonblockingServer(this.args);
  } catch (TTransportException e) {
    throw new ServerException(e);
  }
}
项目:cassandra-1.2.16    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:rain    文件:ThriftService.java   
public void run() {
    setName("Thrift Service");

    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);

        AsyncRainServiceImpl service = new AsyncRainServiceImpl(scenario);
        RainService.Processor<RainService.Iface> processor = new RainService.Processor<RainService.Iface>(
                service);

        TNonblockingServer.Args args = new TNonblockingServer.Args(serverTransport);
        args.processor(processor);

        // Server (connects transport and processor)
        server = new TNonblockingServer(args);
        server.serve();
    } catch (TTransportException e) {
        e.printStackTrace();
    }
}
项目:luxun    文件:ThriftServer.java   
public ThriftServer(QueueService.Iface queueService, ServerConfig serverConfig, ThriftServerStats stats) throws TTransportException {
        this.queueService = queueService;
        this.serverConfig = serverConfig;
        this.stats = stats;

        // assemble thrift server
        TProcessor tprocessor = new QueueService.Processor(this.queueService);
        TNonblockingServerSocket tnbSocketTransport = new TNonblockingServerSocket(serverConfig.getPort());
        TNonblockingServer.Args tnbArgs = new TNonblockingServer.Args(tnbSocketTransport);
        tnbArgs.processor(tprocessor);
        // Nonblocking server mode must use TFramedTransport
        tnbArgs.transportFactory(new TFramedTransport.Factory());
        tnbArgs.protocolFactory(new TBinaryProtocol.Factory());

        this.server = new TNonblockingServer(tnbArgs);

//        THsHaServer.Args thhArgs = new THsHaServer.Args(tnbSocketTransport);
//        thhArgs.processor(tprocessor);
//        // Nonblocking server mode must use TFramedTransport
//        thhArgs.transportFactory(new TFramedTransport.Factory());
//        thhArgs.protocolFactory(new TBinaryProtocol.Factory());
//
//        this.server = new THsHaServer(thhArgs);

        this.serverThread = new ServerThread(this.server);
    }
项目:ditb    文件:ThriftServer.java   
private static TServer getTNonBlockingServer(TProtocolFactory protocolFactory, TProcessor processor,
    TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) throws TTransportException {
  TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
  log.info("starting HBase Nonblocking Thrift server on " + inetSocketAddress.toString());
  TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  return new TNonblockingServer(serverArgs);
}
项目:thrifty    文件:TestServer.java   
private TServer startNonblockingServer(TProcessor processor, TProtocolFactory protocolFactory) {
    TNonblockingServerTransport nonblockingTransport = (TNonblockingServerTransport) serverTransport;
    TNonblockingServer.Args args = new TNonblockingServer.Args(nonblockingTransport)
            .processor(processor)
            .protocolFactory(protocolFactory);

    return new TNonblockingServer(args);
}
项目:LCIndex-HBase-0.94.16    文件:ThriftServer.java   
private static TServer getTNonBlockingServer(TProtocolFactory protocolFactory, THBaseService.Processor processor,
    TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) throws TTransportException {
  TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
  log.info("starting HBase Nonblocking Thrift server on " + inetSocketAddress.toString());
  TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  return new TNonblockingServer(serverArgs);
}
项目:haogrgr-projects    文件:ServerMain.java   
public static void simple(Calculator.Processor<CalculatorHandler> processor) throws Exception {
        TNonblockingServerSocket serverTransport = new TNonblockingServerSocket(9090);
        TServer server = new TNonblockingServer(new TNonblockingServer.Args(serverTransport).processor(processor));

//      TServerTransport serverTransport = new TServerSocket(9090);
//      TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));

        // Use this for a multithreaded server
        // TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));

        System.out.println("Starting the simple server...");
        server.serve();
    }
项目:Java-KMeans-Coreset    文件:CoresetServiceHandler.java   
/**
 * @param args
 * @throws TTransportException
 */
public static void main(String[] args) throws TTransportException {
    // Read socket number from command line argument
    final TNonblockingServerTransport socket = new TNonblockingServerSocket(Integer.valueOf(args[0]));

    final Processor<CoresetServiceHandler> serverProcessor = new Processor<>(new CoresetServiceHandler());
    final TServer server = new TNonblockingServer(new TNonblockingServer.Args(socket)
            .processor(serverProcessor));

    server.serve();
}
项目:Java-KMeans-Coreset    文件:CoresetExternalServer.java   
private CoresetExternalServer(final int... portNums) throws TTransportException {
    // Read socket number from command line argument
    latch = new CountDownLatch(portNums.length);
    executors = Executors.newFixedThreadPool(portNums.length);
    for (int portNum : portNums) {
        log.info("Creating server with port number {}", portNum);
        final TNonblockingServerTransport socket = new TNonblockingServerSocket(portNum);

        final CoresetService.Processor<StreamingCoresetHandler> serverProcessor = new CoresetService.Processor<>(new StreamingCoresetHandler());
        coresetServers.add(new TNonblockingServer(new TNonblockingServer.Args(socket)
                .processor(serverProcessor)));

    }

}
项目:HIndex    文件:ThriftServer.java   
private static TServer getTNonBlockingServer(TProtocolFactory protocolFactory, THBaseService.Processor processor,
    TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) throws TTransportException {
  TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
  log.info("starting HBase Nonblocking Thrift server on " + inetSocketAddress.toString());
  TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  return new TNonblockingServer(serverArgs);
}
项目:IRIndex    文件:ThriftServer.java   
private static TServer getTNonBlockingServer(TProtocolFactory protocolFactory, THBaseService.Processor processor,
    TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) throws TTransportException {
  TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
  log.info("starting HBase Nonblocking Thrift server on " + inetSocketAddress.toString());
  TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  return new TNonblockingServer(serverArgs);
}
项目:IsoBlockProjector    文件:IsoBlockProjector.java   
@EventHandler
  public void onFMLServerStartedEvent(FMLServerStartedEvent e) {
    log.info("Starting BlockTransfer server on port 9090");

IsoBlockProjectorServiceHandler handler = new IsoBlockProjectorServiceHandler();
Processor processor = new IsoBlockProjectorService.Processor(handler);

try {
    TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(
            9090);
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport);
    serverArgs.processor(processor);
    serverArgs.transportFactory(new TFramedTransport.Factory());
    serverArgs.protocolFactory(new TBinaryProtocol.Factory(true, true));
    IBPserver = new TIsoBlockProjectorServer(serverArgs);
    IBPserverthread = new Thread() {
        public void run() {
            IBPserver.serve();
        }
    };
    IBPserverthread.start();
} catch (Exception ex) {
    throw new RuntimeException("Unable to start BlockTransfer server",ex);
}
      MinecraftForge.EVENT_BUS.register(this);
      FMLCommonHandler.instance().bus().register(this);
  }
项目:hbase    文件:ThriftServer.java   
private static TServer getTNonBlockingServer(TProtocolFactory protocolFactory,
    TProcessor processor, TTransportFactory transportFactory, InetSocketAddress inetSocketAddress)
        throws TTransportException {
  TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
  log.info("starting HBase Nonblocking Thrift server on " + inetSocketAddress.toString());
  TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  return new TNonblockingServer(serverArgs);
}
项目:osgi-bundle-frontapi    文件:ThriftUtils.java   
public static TServer createNonBlockingServer(TProcessorFactory processorFactory, int port,
        int clientTimeoutMillisecs, int maxFrameSize, long maxReadBufferSize)
        throws TTransportException {
    TNonblockingServerTransport transport = new TNonblockingServerSocket(port,
            clientTimeoutMillisecs);
    TProtocolFactory protocolFactory = new TBinaryProtocol.Factory();
    TTransportFactory transportFactory = new TFramedTransport.Factory(maxFrameSize);
    TNonblockingServer.Args args = new TNonblockingServer.Args(transport)
            .processorFactory(processorFactory).protocolFactory(protocolFactory)
            .transportFactory(transportFactory);
    args.maxReadBufferBytes = maxReadBufferSize;
    TNonblockingServer server = new TNonblockingServer(args);
    return server;
}
项目:Cassandra-Wasef    文件:CustomTHsHaServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets (hsha). Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is NIO selector service but the invocation will be Multi-Threaded with the Executor service.
    ExecutorService executorService = new JMXEnabledThreadPoolExecutor(DatabaseDescriptor.getRpcMinThreads(),
                                                                       DatabaseDescriptor.getRpcMaxThreads(),
                                                                       60L,
                                                                       TimeUnit.SECONDS,
                                                                       new SynchronousQueue<Runnable>(),
                                                                       new NamedThreadFactory("RPC-Thread"), "RPC-THREAD-POOL");
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                       .outputTransportFactory(args.outTransportFactory)
                                                                       .inputProtocolFactory(args.tProtocolFactory)
                                                                       .outputProtocolFactory(args.tProtocolFactory)
                                                                       .processor(args.processor);
    // Check for available processors in the system which will be equal to the IO Threads.
    return new CustomTHsHaServer(serverArgs, executorService, FBUtilities.getAvailableProcessors());
}
项目:lucida    文件:QADaemon.java   
public static void main(String [] args) 
        throws TTransportException, IOException, InterruptedException { 
    connectToCMD();

    TProcessor proc = new LucidaService.AsyncProcessor(
            new QAServiceHandler.AsyncQAServiceHandler());
    TNonblockingServerTransport transport = new TNonblockingServerSocket(8083);
    TNonblockingServer.Args arguments = new TNonblockingServer.Args(transport)
    .processor(proc)    
    .protocolFactory(new TBinaryProtocol.Factory())
    .transportFactory(new TFramedTransport.Factory());
    final TNonblockingServer server = new TNonblockingServer(arguments);
    System.out.println("QA at port 8083");
    server.serve();
}
项目:PyroDB    文件:ThriftServer.java   
private static TServer getTNonBlockingServer(TProtocolFactory protocolFactory, THBaseService.Processor processor,
    TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) throws TTransportException {
  TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
  log.info("starting HBase Nonblocking Thrift server on " + inetSocketAddress.toString());
  TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  return new TNonblockingServer(serverArgs);
}
项目:wso2-cassandra    文件:CustomTHsHaServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets (hsha). Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is NIO selector service but the invocation will be Multi-Threaded with the Executor service.
    ExecutorService executorService = new JMXEnabledThreadPoolExecutor(DatabaseDescriptor.getRpcMinThreads(),
                                                                       DatabaseDescriptor.getRpcMaxThreads(),
                                                                       60L,
                                                                       TimeUnit.SECONDS,
                                                                       new SynchronousQueue<Runnable>(),
                                                                       new NamedThreadFactory("RPC-Thread"), "RPC-THREAD-POOL");
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                       .outputTransportFactory(args.outTransportFactory)
                                                                       .inputProtocolFactory(args.tProtocolFactory)
                                                                       .outputProtocolFactory(args.tProtocolFactory)
                                                                       .processor(args.processor);
    // Check for available processors in the system which will be equal to the IO Threads.
    return new CustomTHsHaServer(serverArgs, executorService, FBUtilities.getAvailableProcessors());
}
项目:concrete-java    文件:ConcreteZipArchiveFetchServiceThread.java   
public ConcreteZipArchiveFetchServiceThread(FetchCommunicationService.Iface impl, int port) throws TException {
    serverTransport = new TNonblockingServerSocket(port);
    serverArgs = new TNonblockingServer.Args(serverTransport);
    serverArgs.protocolFactory(new TCompactProtocol.Factory());
    serverArgs.transportFactory(new TFramedTransport.Factory(Integer.MAX_VALUE));
    serverArgs.processorFactory(new TProcessorFactory(new FetchCommunicationService.Processor<>(impl)));
    serverArgs.maxReadBufferBytes = Long.MAX_VALUE;
    server = new TNonblockingServer(serverArgs);
}
项目:concrete-java    文件:SearchServiceWrapper.java   
/**
 * @param impl
 * @param port
 * @throws TException
 */
public SearchServiceWrapper(SearchService.Iface impl, int port) throws TException {
  this.serverXport = new TNonblockingServerSocket(port);
  final TNonblockingServer.Args args = new TNonblockingServer.Args(this.serverXport);
  args.protocolFactory(new TCompactProtocol.Factory());
  final TFramedTransport.Factory transFactory = new TFramedTransport.Factory(Integer.MAX_VALUE);
  args.transportFactory(transFactory);
  SearchService.Processor<Iface> proc = new SearchService.Processor<>(impl);
  args.processorFactory(new TProcessorFactory(proc));
  args.maxReadBufferBytes = Long.MAX_VALUE;

  this.servArgs = args;
  this.server = new TNonblockingServer(this.servArgs);
}
项目:concrete-java    文件:FetchServiceWrapper.java   
public FetchServiceWrapper(FetchCommunicationService.Iface impl, int port) throws TException {
  this.serverXport = new TNonblockingServerSocket(port);
  final TNonblockingServer.Args args = new TNonblockingServer.Args(this.serverXport);
  args.protocolFactory(new TCompactProtocol.Factory());
  final TFramedTransport.Factory transFactory = new TFramedTransport.Factory(Integer.MAX_VALUE);
  args.transportFactory(transFactory);
  FetchCommunicationService.Processor<Iface> proc = new FetchCommunicationService.Processor<>(impl);
  args.processorFactory(new TProcessorFactory(proc));
  args.maxReadBufferBytes = Long.MAX_VALUE;

  this.servArgs = args;
  this.server = new TNonblockingServer(this.servArgs);
}
项目:concrete-java    文件:SummarizationServiceWrapper.java   
public SummarizationServiceWrapper(SummarizationService.Iface impl, int port) throws TException {
  this.serverXport = new TNonblockingServerSocket(port);
  final TNonblockingServer.Args args = new TNonblockingServer.Args(this.serverXport);
  args.protocolFactory(new TCompactProtocol.Factory());
  final TFramedTransport.Factory transFactory = new TFramedTransport.Factory(Integer.MAX_VALUE);
  args.transportFactory(transFactory);
  SummarizationService.Processor<SummarizationService.Iface> proc = new SummarizationService.Processor<>(impl);
  args.processorFactory(new TProcessorFactory(proc));
  args.maxReadBufferBytes = Long.MAX_VALUE;

  this.servArgs = args;
  this.server = new TNonblockingServer(this.servArgs);
}
项目:concrete-java    文件:StoreServiceWrapper.java   
public StoreServiceWrapper(StoreCommunicationService.Iface impl, int port) throws TException {
  this.serverXport = new TNonblockingServerSocket(port);
  final TNonblockingServer.Args args = new TNonblockingServer.Args(this.serverXport);
  args.protocolFactory(new TCompactProtocol.Factory());
  final TFramedTransport.Factory transFactory = new TFramedTransport.Factory(Integer.MAX_VALUE);
  args.transportFactory(transFactory);
  StoreCommunicationService.Processor<Iface> proc = new StoreCommunicationService.Processor<>(impl);
  args.processorFactory(new TProcessorFactory(proc));
  args.maxReadBufferBytes = Long.MAX_VALUE;

  this.servArgs = args;
  this.server = new TNonblockingServer(this.servArgs);
}