当前位置: 首页>>代码示例>>Java>>正文


Java TServerTransport类代码示例

本文整理汇总了Java中org.apache.thrift.transport.TServerTransport的典型用法代码示例。如果您正苦于以下问题:Java TServerTransport类的具体用法?Java TServerTransport怎么用?Java TServerTransport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TServerTransport类属于org.apache.thrift.transport包,在下文中一共展示了TServerTransport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: poolServer

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
@Bean(name = "pool-server")
public TServer poolServer() throws Exception {
	TServerTransport transport = new TServerSocket(this.port());

	TThreadPoolServer.Args args = new TThreadPoolServer.Args(transport);
	args.transportFactory(new TTransportFactory());
	args.protocolFactory(new TBinaryProtocol.Factory());

	args.processor(this.processor());
	args.executorService(new ThreadPoolExecutor(env.getProperty(
			"rpc.server.min.worker.threads", Integer.class, 512), env
			.getProperty("rpc.server.max.worker.threads", Integer.class,
					65535), env.getProperty(
			"rpc.server.thread.keep.alive.time", Long.class, 600l),
			TimeUnit.SECONDS, new SynchronousQueue<Runnable>()));

	return new TThreadPoolServer(args);
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:19,代码来源:HelloServerConfig.java

示例2: getSSLServerTransport

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
private TServerTransport getSSLServerTransport() {
  try {
    TServerTransport transport;
    TSSLTransportFactory.TSSLTransportParameters params =
            new TSSLTransportFactory.TSSLTransportParameters();

    params.setKeyStore(keystore, keystorePassword, getkeyManagerAlgorithm(), keystoreType);
    transport = TSSLTransportFactory.getServerSocket(
            port, 120000, InetAddress.getByName(bindAddress), params);

    ServerSocket serverSock = ((TServerSocket) transport).getServerSocket();
    if (serverSock instanceof SSLServerSocket) {
      SSLServerSocket sslServerSock = (SSLServerSocket) serverSock;
      List<String> enabledProtocols = new ArrayList<String>();
      for (String protocol : sslServerSock.getEnabledProtocols()) {
        if (!excludeProtocols.contains(protocol)) {
          enabledProtocols.add(protocol);
        }
      }
      sslServerSock.setEnabledProtocols(enabledProtocols.toArray(new String[0]));
    }
    return transport;
  } catch (Throwable throwable) {
    throw new FlumeException("Cannot start Thrift source.", throwable);
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:27,代码来源:ThriftSource.java

示例3: ServerThread

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
ServerThread() throws TTransportException {
   TMultiplexedProcessor processor = new TMultiplexedProcessor();
   for (String beanName : serviceMap.keySet()) {
      IThriftServerService serverService = (IThriftServerService) serviceMap.getService(beanName);
      String processorName = serverService.getName();
      TProcessor tProcessor = serverService.getProcessor(serverService);
      processor.registerProcessor(processorName, tProcessor);
      logger.info("Register a processorName {} processorImpl {}", processorName, tProcessor);
   }

   logger.info("init default TServerTransport in addr {} port {}", applicationProperties.getAddr(), applicationProperties.getPort());
   TServerTransport tServerTransport = new TServerSocket(new InetSocketAddress(applicationProperties.getAddr(),
           applicationProperties.getPort()));
   TThreadPoolServer.Args args = new TThreadPoolServer.Args(tServerTransport);
   args.processor(processor);
   args.protocolFactory(tProtocolFactory);
   server = new TThreadPoolServer(args);
}
 
开发者ID:somewhereMrli,项目名称:albedo-thrift,代码行数:19,代码来源:ThriftServer.java

示例4: getTThreadPoolServer

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
private static TServer getTThreadPoolServer(TProtocolFactory protocolFactory,
                                            TProcessor processor,
                                            TTransportFactory transportFactory,
                                            int workerThreads,
                                            InetSocketAddress inetSocketAddress,
                                            int backlog,
                                            int clientTimeout)
    throws TTransportException {
  TServerTransport serverTransport = new TServerSocket(
                                         new TServerSocket.ServerSocketTransportArgs().
                                             bindAddr(inetSocketAddress).backlog(backlog).
                                             clientTimeout(clientTimeout));
  log.info("starting HBase ThreadPool Thrift server on " + inetSocketAddress.toString());
  TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  if (workerThreads > 0) {
    serverArgs.maxWorkerThreads(workerThreads);
  }
  return new TThreadPoolServer(serverArgs);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:ThriftServer.java

示例5: start

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
/**
 * Server initialization.
 *
 * @throws Exception error
 */
public void start() throws Exception {
    log.info("initializing thrift server {}", getServerName());
    final ThreadFactory threadFactory = new ThreadFactoryBuilder()
        .setNameFormat(threadPoolNameFormat)
        .setUncaughtExceptionHandler((t, e) -> log.error("Uncaught exception in thread: {}", t.getName(), e))
        .build();
    final ExecutorService executorService = new ThreadPoolExecutor(
        Math.min(2, config.getThriftServerMaxWorkerThreads()),
        config.getThriftServerMaxWorkerThreads(),
        60L,
        TimeUnit.SECONDS,
        new SynchronousQueue<>(),
        threadFactory
    );
    RegistryUtil.registerThreadPool(registry, threadPoolNameFormat, (ThreadPoolExecutor) executorService);
    final int timeout = config.getThriftServerSocketClientTimeoutInSeconds() * 1000;
    final TServerTransport serverTransport = new TServerSocket(portNumber, timeout);
    startServing(executorService, serverTransport);
}
 
开发者ID:Netflix,项目名称:metacat,代码行数:25,代码来源:AbstractThriftServer.java

示例6: main

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
public static void main(String[] args) {
    try {
        userProfileServerHandler = new UserProfileServerHandler();
        userProfileProcessor = new UserProfileService.Processor(userProfileServerHandler);

        TMultiplexedProcessor airavataServerProcessor = new TMultiplexedProcessor();

        airavataServerProcessor.registerProcessor("UserProfileService", userProfileProcessor);

        TServerTransport serverTransport = new TServerSocket(9190);

        TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(airavataServerProcessor));

        System.out.println("Starting User Profile server...");
        server.serve();

    } catch (Exception x) {
        x.printStackTrace();
    }
}
 
开发者ID:SciGaP,项目名称:allocateme,代码行数:21,代码来源:UserProfileServer.java

示例7: HadoopThriftServer

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
/**
 * Constrcts a server object
 */
public HadoopThriftServer(String [] args) {

  if (args.length > 0) {
    serverPort = new Integer(args[0]);
  }
  try {
    ServerSocket ssock = createServerSocket(serverPort);
    TServerTransport serverTransport = new TServerSocket(ssock);
    Iface handler = new HadoopThriftHandler("hdfs-thrift-dhruba");
    ThriftHadoopFileSystem.Processor processor = new ThriftHadoopFileSystem.Processor(handler);
    TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport);
    serverArgs.minWorkerThreads = 10;
    serverArgs.processor(processor);
    serverArgs.transportFactory(new TTransportFactory());
    serverArgs.protocolFactory(new TBinaryProtocol.Factory());
    server = new TThreadPoolServer(serverArgs);
    System.out.println("Starting the hadoop thrift server on port [" + serverPort + "]...");
    HadoopThriftHandler.LOG.info("Starting the hadoop thrift server on port [" +serverPort + "]...");
    System.out.flush();

  } catch (Exception x) {
    x.printStackTrace();
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:28,代码来源:HadoopThriftServer.java

示例8: startServer2

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
public void startServer2() throws Exception
{
    AwesomeService.Processor<AwesomeService.Iface> processor = new AwesomeService.Processor<>(referenceServer);
    TServerTransport serverTransport = new TServerSocket(9090);
    TServer server = new TSimpleServer(new TSimpleServer.Args(serverTransport).processor(processor));

    ServerRunner serverRunner = new ServerRunner(server);
    Thread serverThread = new Thread(serverRunner);

    serverThread.start();
    logger.info("Started binary interface");

    joinMethods.add(() -> {
        try {
            serverThread.join();
        } catch (InterruptedException ignored) {
        }
    });
}
 
开发者ID:coveord,项目名称:Blitz-2015,代码行数:20,代码来源:ReferenceMain.java

示例9: main

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
public static void main(String[] args) {
	try {
		handler = new CalculatorHandler();
		processor = new Calculator.Processor(handler);

		try {
			TServerTransport serverTransport = new TServerSocket(9090);
			TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));

			System.out.println("Starting the  server...");
			server.serve();
		} catch (TTransportException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	} catch (Exception x) {
		x.printStackTrace();
	}
}
 
开发者ID:git5hub43,项目名称:springside-engine,代码行数:21,代码来源:StandardBIOServer.java

示例10: main

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
public static void main(String[] args) 
       throws TTransportException, UnsupportedEncodingException {
    final String msg = "Hello Thrift!\n";
    final String stop_cmd = "STOP";
    final int buf_size = 1024*8;
    byte[] buf = new byte[buf_size];
    final int port = 9090;

    TServerTransport acceptor = new TServerSocket(9090);
    acceptor.listen();
    System.out.println("[Server] listening on port: " + port);
    
    String input;
    do {
        TTransport trans = acceptor.accept();
        int len = trans.read(buf, 0, buf_size);
        input = new String(buf, 0, len,"UTF-8");
        System.out.println("[Server] handling request: " + input);
        trans.write(msg.getBytes());
        trans.flush();
        trans.close();
    } while (! stop_cmd.regionMatches(0, input, 0, 4)); 

    System.out.println("[Server] exiting");
    acceptor.close();
}
 
开发者ID:RandyAbernethy,项目名称:ThriftBook,代码行数:27,代码来源:ServerTrans.java

示例11: main

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
public static void main(String[] args) {
    int port = 9090;

    try {
        TServerTransport serverTransport = new TServerSocket(port);

        Args processor = new TThreadPoolServer.Args(serverTransport)
                .inputTransportFactory(new TFramedTransport.Factory())
                .outputTransportFactory(new TFramedTransport.Factory())
                .processor(new Processor<>(new TestThriftServiceHandler()));
        //            processor.maxWorkerThreads = 20;
        TThreadPoolServer server = new TThreadPoolServer(processor);

        System.out.println("Starting the server...");
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:aloha-app,项目名称:thrift-client-pool-java,代码行数:20,代码来源:TestThriftServiceStarter.java

示例12: setUp

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
    int port = 9090;

    try {
        TServerTransport serverTransport = new TServerSocket(port);

        Args processor = new TThreadPoolServer.Args(serverTransport)
                .inputTransportFactory(new TFramedTransport.Factory())
                .outputTransportFactory(new TFramedTransport.Factory())
                .processor(new Processor<>(new TestThriftServiceHandler()));
        //            processor.maxWorkerThreads = 20;
        TThreadPoolServer server = new TThreadPoolServer(processor);

        logger.info("Starting test server...");
        new Thread(server::serve).start();
        Thread.sleep(1000); // waiting server init
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:aloha-app,项目名称:thrift-client-pool-java,代码行数:22,代码来源:TestThriftClientPool.java

示例13: createServerSocket

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
/**
 * Creates the server socket.
 *
 * @return the t server transport
 * @throws TTransportException the t transport exception
 */
public TServerTransport createServerSocket() throws TTransportException {
  return new TServerSocket(
      new InetSocketAddress(getNodeConfig().getThriftHost(), getNodeConfig().getThriftPort())) {
    @Override
    protected TSocket acceptImpl() throws TTransportException {
      ServerSocket serverSocket = getServerSocket();
      if (serverSocket == null) {
        throw new TTransportException(
            TTransportException.NOT_OPEN,
            "No underlying server socket."
        );
      }
      try {
        Socket result = serverSocket.accept();
        TSocketWrapper result2 = new TSocketWrapper(result);
        result2.setTimeout(0);
        openedSockets.add(result2);
        return result2;
      } catch (IOException iox) {
        throw new TTransportException(iox);
      }
    }
  };
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:31,代码来源:KaaNodeInitializationService.java

示例14: testKaaNodeInitializationServiceStart

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
/**
 * Test kaa node initialization service start.
 *
 * @throws Exception the exception
 */
@Test
public void testKaaNodeInitializationServiceStart() throws Exception {
  KaaNodeInitializationService kaaNodeInitializationService = kaaNodeInitializationServiceSpy();

  TThreadPoolServer server = Mockito.mock(TThreadPoolServer.class);
  Mockito.doNothing().when(server).serve();

  Mockito.doReturn(server).when(kaaNodeInitializationService).createServer(Mockito.any(TServerTransport.class),
      Mockito.any(TMultiplexedProcessor.class));

  kaaNodeInitializationService.start();

  Mockito.verify(controlInitializationService).start();
  Mockito.verify(bootstrapInitializationService).start();
  Mockito.verify(operationsInitializationService).start();
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:22,代码来源:KaaNodeInitializationServiceTest.java

示例15: testKaaNodeInitializationServiceStartTransportException

import org.apache.thrift.transport.TServerTransport; //导入依赖的package包/类
/**
 * Test kaa node initialization service start with transport exception.
 *
 * @throws Exception the exception
 */
@Test
public void testKaaNodeInitializationServiceStartTransportException() throws Exception {
  KaaNodeInitializationService kaaNodeInitializationService = kaaNodeInitializationServiceSpy();

  TThreadPoolServer server = Mockito.mock(TThreadPoolServer.class);
  Mockito.doThrow(TTransportException.class).when(server).serve();

  Mockito.doReturn(server).when(kaaNodeInitializationService).createServer(Mockito.any(TServerTransport.class),
      Mockito.any(TMultiplexedProcessor.class));

  kaaNodeInitializationService.start();

  Mockito.verify(controlInitializationService).start();
  Mockito.verify(bootstrapInitializationService).start();
  Mockito.verify(operationsInitializationService).start();
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:22,代码来源:KaaNodeInitializationServiceTest.java


注:本文中的org.apache.thrift.transport.TServerTransport类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。