當前位置: 首頁>>代碼示例>>Java>>正文


Java TNonblockingServer類代碼示例

本文整理匯總了Java中org.apache.thrift.server.TNonblockingServer的典型用法代碼示例。如果您正苦於以下問題:Java TNonblockingServer類的具體用法?Java TNonblockingServer怎麽用?Java TNonblockingServer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TNonblockingServer類屬於org.apache.thrift.server包,在下文中一共展示了TNonblockingServer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
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");
				}
			}
		});
	}
}
 
開發者ID:cyfonly,項目名稱:ThriftJ,代碼行數:26,代碼來源:ThriftServerTest2.java

示例2: main

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
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");
				}
			}
		});
	}
}
 
開發者ID:cyfonly,項目名稱:ThriftJ,代碼行數:26,代碼來源:ThriftServerTest.java

示例3: createThrift

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
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;
    }
}
 
開發者ID:songbin,項目名稱:frc,代碼行數:22,代碼來源:Application.java

示例4: buildTServer

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
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);
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:26,代碼來源:CustomTNonBlockingServer.java

示例5: setUp

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
@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;
        }
    };
}
 
開發者ID:morimekta,項目名稱:providence,代碼行數:25,代碼來源:RPCThriftNonblockingSocketTest.java

示例6: setUpServer

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
@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);
}
 
開發者ID:morimekta,項目名稱:providence,代碼行數:20,代碼來源:NonblockingSocketClientHandlerTest.java

示例7: buildTServer

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
@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);
}
 
開發者ID:scylladb,項目名稱:scylla-tools-java,代碼行數:27,代碼來源:CustomTNonBlockingServer.java

示例8: nonblockingServer

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
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);
        }
    };
}
 
開發者ID:naver,項目名稱:pinpoint,代碼行數:19,代碼來源:AsyncEchoTestServer.java

示例9: nonblockingServer

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
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);
        }
    };
}
 
開發者ID:naver,項目名稱:pinpoint,代碼行數:19,代碼來源:SyncEchoTestServer.java

示例10: ConcreteServer

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
/**
 *
 */
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);
  }
}
 
開發者ID:hltcoe,項目名稱:concrete-java,代碼行數:25,代碼來源:ConcreteServer.java

示例11: run

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
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();
	}
}
 
開發者ID:jacksonicson,項目名稱:rain,代碼行數:21,代碼來源:ThriftService.java

示例12: ThriftServer

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
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);
	}
 
開發者ID:bulldog2011,項目名稱:luxun,代碼行數:27,代碼來源:ThriftServer.java

示例13: getTNonBlockingServer

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
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);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:11,代碼來源:ThriftServer.java

示例14: startNonblockingServer

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
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);
}
 
開發者ID:Microsoft,項目名稱:thrifty,代碼行數:9,代碼來源:TestServer.java

示例15: getTNonBlockingServer

import org.apache.thrift.server.TNonblockingServer; //導入依賴的package包/類
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);
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:11,代碼來源:ThriftServer.java


注:本文中的org.apache.thrift.server.TNonblockingServer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。