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


Java TThreadPoolServer类代码示例

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


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

示例1: poolServer

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的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: start

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void start() {
  try {
    InetSocketAddress bindAddr = new InetSocketAddress(host, port);
    serverTransport = new TServerSocket(bindAddr);
    ThriftFlumeEventServer.Processor processor =
        new ThriftFlumeEventServer.Processor(new ThriftFlumeEventServerImpl());
    server = new TThreadPoolServer(
        new TThreadPoolServer.Args(serverTransport).processor(processor));
  } catch (TTransportException e) {
    throw new FlumeException("Failed starting source", e);
  }
  ThriftHandler thriftHandler = new ThriftHandler(server);
  thriftHandlerThread = new Thread(thriftHandler);
  thriftHandlerThread.start();
  super.start();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:19,代码来源:ThriftLegacySource.java

示例3: startSchedulerThriftService

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
/**
 * @Title: startSchedulerThriftService
 * @Description: 开启scheduler 同步、异步调用服务
 * @return void 返回类型
 */
private static void startSchedulerThriftService() {
	LOG.info("start scheduler thrift service....");
	new Thread() {
		@Override
		public void run(){
			try {
				SchedulerServiceImpl schedulerServiceImpl =  SpringUtil.getBean(SchedulerServiceImpl.class); 
				TProcessor tprocessor = new SchedulerService.Processor<SchedulerService.Iface>(schedulerServiceImpl);
				TServerSocket serverTransport = new TServerSocket(PropertyLoader.THRIFT_SCHEDULER_PORT);
				TThreadPoolServer.Args ttpsArgs = new TThreadPoolServer.Args(serverTransport);
				ttpsArgs.processor(tprocessor);
				ttpsArgs.protocolFactory(new TBinaryProtocol.Factory());
				//线程池服务模型,使用标准的阻塞式IO,预先创建一组线程处理请求。
				TServer server = new TThreadPoolServer(ttpsArgs);
				server.serve();
			} catch (Exception e) {
				LOG.error("start scheduler thrift service error,msg:"+ExceptionUtil.getStackTraceAsString(e));
			}
		}
	}.start();
	LOG.info("start scheduler thrift server success!");
}
 
开发者ID:elves-project,项目名称:scheduler,代码行数:28,代码来源:ProgramEntrance.java

示例4: ServerThread

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的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

示例5: getTThreadPoolServer

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的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

示例6: start

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
public void start() throws TTransportException, UnknownHostException {
    InetAddress inetAddress = InetAddress.getByName(hostName);

    TSSLTransportFactory.TSSLTransportParameters params =
            new TSSLTransportFactory.TSSLTransportParameters();
    params.setKeyStore(keyStore, keyStorePassword);

    TServerSocket serverTransport;

    serverTransport = TSSLTransportFactory.getServerSocket(port, clientTimeout, inetAddress, params);


    AuthenticatorService.Processor<AuthenticatorServiceImpl> processor =
            new AuthenticatorService.Processor<AuthenticatorServiceImpl>(
                    new AuthenticatorServiceImpl(thriftAuthenticatorService));
    authenticationServer = new TThreadPoolServer(
            new TThreadPoolServer.Args(serverTransport).processor(processor));
    Thread thread = new Thread(new ServerRunnable(authenticationServer));
    if (log.isDebugEnabled()) {
        log.debug("Thrift Authentication Service started at ssl://" + hostName + ":" + port);
    }
    thread.start();
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:TCPThriftAuthenticationService.java

示例7: testDefaultServiceImpl

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
@Test
public void testDefaultServiceImpl() {
	int serverPort = 49000;
	ThriftServerConfiguration thriftServerConfiguration = new ThriftServerConfiguration();
	thriftServerConfiguration.setServerArgsAspect(new ServerArgsAspect() {
		@Override
		public TThreadPoolServer.Args TThreadPoolServerArgsAspect(TThreadPoolServer.Args args) {
			args.stopTimeoutVal = 1;
			return args;
		}
	});
	Factory factory = new GeneralFactory(thriftServerConfiguration);
	ThriftServer thriftServer = factory.getThriftServer(serverPort, new TestService());
	thriftServer.run();
	ThriftClient thriftClient = factory.getThriftClient("localhost", serverPort);
	try {
		Thread.sleep(500);
		Service service = factory.getService(thriftClient);
		assertEquals(service.get(testString), testString);
	} catch (Exception e) {
		fail();
	} finally {
		thriftServer.stop();
	}
}
 
开发者ID:venwyhk,项目名称:ikasoa,代码行数:26,代码来源:ServiceTest.java

示例8: main

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的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

示例9: initializeClusterManagerCallbackServer

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
private synchronized void initializeClusterManagerCallbackServer()
    throws IOException {
  // Create thrift RPC to serve ClusterManager
  int soTimeout = fConf.getInt(
      CORONA_TASK_TRACKER_SERVER_CLIENTTIMEOUT_KEY, 30 * 1000);
  ServerSocket serverSocket = new ServerSocket();
  serverSocket.setReuseAddress(true);
  serverSocket.bind(new InetSocketAddress(0));
  TServerSocket tSocket = new TServerSocket(serverSocket, soTimeout);
  CoronaTaskTrackerService.Processor proc =
      new CoronaTaskTrackerService.Processor(this);
  TBinaryProtocol.Factory protocolFactory =
      new TBinaryProtocol.Factory(true, true);
  TThreadPoolServer.Args args = new TThreadPoolServer.Args(tSocket);
  args.processor(proc);
  args.protocolFactory(protocolFactory);
  clusterManagerCallbackServer = new TThreadPoolServer(args);
  clusterManagerCallbackServerThread =
      new TServerThread(clusterManagerCallbackServer);
  clusterManagerCallbackServerThread.start();
  clusterManagerCallbackServerAddr = new InetAddress(
      getLocalHostname(), serverSocket.getLocalPort());
  LOG.info("SessionServer up at " + serverSocket.getLocalSocketAddress());
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:25,代码来源:CoronaTaskTracker.java

示例10: HadoopThriftServer

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的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

示例11: startThreadedPoolServer

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
private static TServer startThreadedPoolServer(final TServerTransport transport, final TProcessor processor,
        Properties properties) throws Exception {

    TThreadPoolServer.Args serverArgs;
    if (properties == null) {
        serverArgs = new TThreadPoolServer.Args(transport).processor(processor);
    } else {
        serverArgs =
                (TThreadPoolServer.Args) ThriftUtils.getServerArgs(transport, properties).processor(
                        processor);
    }

    final TServer server = new TThreadPoolServer(serverArgs);
    new Thread(new Runnable() {
        @Override
        public void run() {
            server.serve();
        }
    }).start();
    return server;
}
 
开发者ID:ezbake,项目名称:ezbake-common-java,代码行数:22,代码来源:ThriftUtils.java

示例12: getServerArgs

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
@SuppressWarnings("null")
public static TServer.AbstractServerArgs<?> getServerArgs(TServerTransport transport, Properties properties) {
    TServer.AbstractServerArgs<?> args = null;
    ThriftConfigurationHelper thriftConfiguration = new ThriftConfigurationHelper(properties);
    switch (thriftConfiguration.getServerMode()) {
        case Simple:
            args = new TServer.Args(transport);
            break;
        case ThreadedPool:
            args = new TThreadPoolServer.Args(transport);
            break;
        case HsHa:
            throw new IllegalArgumentException("Unable to create an HsHa Server Args at this time");
    }

    // Use the EzSecureTransport (exposes peer ssl certs) if using SSL
    if (thriftConfiguration.useSSL()) {
        args.inputTransportFactory(new EzSecureServerTransport.Factory(properties));
    }

    return args;
}
 
开发者ID:ezbake,项目名称:ezbake-common-java,代码行数:23,代码来源:ThriftUtils.java

示例13: getServer

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
@Override
public TServer getServer(TProcessor processor) throws IOException, TTransportException {
    int port = type.getPort(storm_conf);
    TTransportFactory serverTransportFactory = getServerTransportFactory();
    TServerSocket serverTransport = new TServerSocket(port);
    int numWorkerThreads = type.getNumThreads(storm_conf);
    Integer queueSize = type.getQueueSize(storm_conf);

    TThreadPoolServer.Args server_args =
            new TThreadPoolServer.Args(serverTransport).processor(new TUGIWrapProcessor(processor)).minWorkerThreads(numWorkerThreads)
                    .maxWorkerThreads(numWorkerThreads).protocolFactory(new TBinaryProtocol.Factory(false, true));

    if (serverTransportFactory != null) {
        server_args.transportFactory(serverTransportFactory);
    }
    BlockingQueue workQueue = new SynchronousQueue();
    if (queueSize != null) {
        workQueue = new ArrayBlockingQueue(queueSize);
    }
    ThreadPoolExecutor executorService = new ExtendedThreadPoolExecutor(numWorkerThreads, numWorkerThreads, 60, TimeUnit.SECONDS, workQueue);
    server_args.executorService(executorService);
    return new TThreadPoolServer(server_args);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:24,代码来源:SaslTransportPlugin.java

示例14: main

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的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

示例15: getServer

import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
public TServer getServer(int port, TProcessor processor) throws IOException, TTransportException {
    TTransportFactory serverTransportFactory = getServerTransportFactory();

    //define THsHaServer args 
    //original: THsHaServer + TNonblockingServerSocket
    //option: TThreadPoolServer + TServerSocket
    TServerSocket serverTransport = new TServerSocket(port);
    TThreadPoolServer.Args server_args = new TThreadPoolServer.Args(serverTransport).
            processor(new TUGIWrapProcessor(processor)).
            minWorkerThreads(64).
            maxWorkerThreads(64).
            protocolFactory(new TBinaryProtocol.Factory());            
    if (serverTransportFactory != null) 
        server_args.transportFactory(serverTransportFactory);

    //construct THsHaServer
    return new TThreadPoolServer(server_args);
}
 
开发者ID:metamx,项目名称:incubator-storm,代码行数:19,代码来源:SaslTransportPlugin.java


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