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


Java TProcessor类代码示例

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


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

示例1: testApacheServer

import org.apache.thrift.TProcessor; //导入依赖的package包/类
private static int testApacheServer(List<MethodInvocationFilter> filters)
        throws Exception
{
    ScribeService scribeService = new ScribeService();
    TProcessor processor = new scribe.Processor<>(scribeService);

    int invocationCount = 0;
    for (boolean secure : ImmutableList.of(true, false)) {
        for (Transport transport : Transport.values()) {
            for (Protocol protocol : Protocol.values()) {
                invocationCount += testApacheServer(secure, transport, protocol, processor, ImmutableList.<ToIntFunction<HostAndPort>>builder()
                        .addAll(legacyApacheThriftTestClients(filters, transport, protocol, secure))
                        .addAll(driftNettyTestClients(filters, transport, protocol, secure))
                        .addAll(apacheThriftTestClients(filters, transport, protocol, secure))
                        .build());
            }
        }
    }

    assertEquals(scribeService.getMessages(), newArrayList(concat(nCopies(invocationCount, MESSAGES))));

    return invocationCount;
}
 
开发者ID:airlift,项目名称:drift,代码行数:24,代码来源:TestClientsWithApacheServer.java

示例2: startSchedulerThriftService

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

示例3: startRPCServer

import org.apache.thrift.TProcessor; //导入依赖的package包/类
public static void startRPCServer(leafServer leafserver , String ip , int port) throws Exception
{
	ServerSocket serverSocket = new ServerSocket(port,10000, InetAddress.getByName(ip));

	TServerSocket serverTransport = new TServerSocket(serverSocket);

	//设置协议工厂为TBinaryProtocolFactory
	Factory proFactory = new TBinaryProtocol.Factory();
	//关联处理器leafrpc的实现
	TProcessor processor = new leafrpc.Processor<leafrpc.Iface>(new RPCService(leafserver));
	TThreadPoolServer.Args args2 = new TThreadPoolServer.Args(serverTransport);
	args2.processor(processor);
	args2.protocolFactory(proFactory);
	TServer server = new TThreadPoolServer(args2);
	LOG.info("leaf RPCServer(type:TThreadPoolServer) start at ip:port : "+ ip +":" + port );
	server.serve();
}
 
开发者ID:weizhenyi,项目名称:leaf-snowflake,代码行数:18,代码来源:rpcServer.java

示例4: startRPCServer2

import org.apache.thrift.TProcessor; //导入依赖的package包/类
public static void startRPCServer2(leafServer leafserver , String ip , int port) throws Exception
{
	//关联处理器leafrpc的实现
	TProcessor processor = new leafrpc.Processor<leafrpc.Iface>(new RPCService(leafserver));
	//传输通道,非阻塞模式
	InetSocketAddress address = new InetSocketAddress(InetAddress.getByName(ip),port);
	TNonblockingServerSocket serverTransport = new TNonblockingServerSocket(address,10000);
	//多线程半同步半异步
	TThreadedSelectorServer.Args tArgs = new TThreadedSelectorServer.Args(serverTransport);
	tArgs.processor(processor);
	//二进制协议
	tArgs.protocolFactory(new TBinaryProtocol.Factory());
	//多线程半同步半异步的服务模型
	TServer server = new TThreadedSelectorServer(tArgs);
	LOG.info("leaf RPCServer(type:TThreadedSelectorServer) start at ip:port : "+ ip +":" + port );
	server.serve();
}
 
开发者ID:weizhenyi,项目名称:leaf-snowflake,代码行数:18,代码来源:rpcServer.java

示例5: ServerThread

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

示例6: getTThreadPoolServer

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

示例7: getProcessor

import org.apache.thrift.TProcessor; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public TProcessor getProcessor() {
    return new ThriftHiveMetastore.Processor<>(
        new CatalogThriftHiveMetastore(config, hiveConverters, metacatV1, partitionV1, catalogName, registry)
    );
}
 
开发者ID:Netflix,项目名称:metacat,代码行数:10,代码来源:CatalogThriftService.java

示例8: ClientProcessData

import org.apache.thrift.TProcessor; //导入依赖的package包/类
protected ClientProcessData(GfxdTSocket socket, int connectionNumber,
    TProcessor proc, TTransport in, TTransport out, TProtocol inp,
    TProtocol outp, TServerEventHandler eventHandler) {
  this.clientSocket = socket;
  this.connectionNumber = connectionNumber;
  this.processor = proc;
  this.inputTransport = in;
  this.outputTransport = out;
  this.inputProtocol = inp;
  this.outputProtocol = outp;
  this.eventHandler = eventHandler;
  if (eventHandler != null) {
    this.connectionContext = eventHandler.createContext(inp, outp);
  }
  else {
    this.connectionContext = null;
  }
  this.idle = true;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:GfxdThriftServerSelector.java

示例9: testAysncServiceImpl

import org.apache.thrift.TProcessor; //导入依赖的package包/类
@Test
public void testAysncServiceImpl() {
	int serverPort = 49001;
	TProcessor p = new ServiceProcessor(new TestThriftServiceImpl1());
	thriftServerConfiguration.setProcessorFactory(new TProcessorFactory(p));
	Factory factory = new GeneralFactory(thriftServerConfiguration);
	ThriftServer thriftServer = factory.getThriftServer(serverPort, new TestThriftServiceImpl1());
	thriftServer.run();
	try {
		AsyncService service = factory.getAsyncService(new TNonblockingSocket(LOCAL_HOST, serverPort));
		Thread.sleep(500);
		TestCallback1 callback = new TestCallback1();
		service.get(testString1, callback);
		Thread.sleep(1000);
	} catch (Exception e) {
		fail();
	} finally {
		thriftServer.stop();
	}
}
 
开发者ID:venwyhk,项目名称:ikasoa,代码行数:21,代码来源:AysncServiceTest.java

示例10: testMultiplexedThriftServerImpl

import org.apache.thrift.TProcessor; //导入依赖的package包/类
@Test
public void testMultiplexedThriftServerImpl() {
	int serverPort = 39101;
	Map<String, TProcessor> processorMap = new HashMap<>();
	processorMap.put("testServer", new ThriftSimpleService.Processor<Iface>(new ThriftSimpleServiceImpl()));
	MultiplexedProcessor processor = new MultiplexedProcessor(processorMap);
	ThriftServer defaultThriftServer = new DefaultThriftServerImpl(serverName, serverPort, configuration,
			processor);
	assertEquals(defaultThriftServer.getServerName(), serverName);
	assertEquals(defaultThriftServer.getServerPort(), serverPort);
	assertEquals(defaultThriftServer.getThriftServerConfiguration(), configuration);
	defaultThriftServer.run();
	try (ThriftClient thriftClient = factory.getThriftClient(LOCAL_HOST, serverPort);
			TTransport transport = thriftClient.getTransport()) {
		Thread.sleep(500);
		transport.open();
		ThriftSimpleService.Client client = new ThriftSimpleService.Client(
				thriftClient.getProtocol(transport, "testServer"));
		assertEquals(testString, client.get(testString));
	} catch (Exception e) {
		fail();
	} finally {
		defaultThriftServer.stop();
	}
}
 
开发者ID:venwyhk,项目名称:ikasoa,代码行数:26,代码来源:ServerTest.java

示例11: createProcessor

import org.apache.thrift.TProcessor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private TProcessor createProcessor(final Class<T> handlerType, Class<I> serviceType) {
  // Pick the Iface inner interface and the Processor class
  Class<? extends TProcessor> processorType = null;
  Class<?> ifaceType = null;
  for (Class<?> clz : serviceType.getDeclaredClasses()) {
    if (TProcessor.class.isAssignableFrom(clz)) {
      processorType = (Class<? extends TProcessor>) clz;
    } else if (clz.isInterface() && "Iface".equals(clz.getSimpleName())) {
      ifaceType = clz;
    }
  }

  Preconditions.checkArgument(processorType != null,
                              "Missing TProcessor, %s is not a valid thrift service.", serviceType.getName());
  Preconditions.checkArgument(ifaceType != null,
                              "Missing Iface, %s is not a valid thrift service.", serviceType.getName());

  // If handler already implements the Iface, simply delegate
  if (ifaceType.isAssignableFrom(handlerType)) {
    return createProxyProcessor(handlerType, processorType, ifaceType);
  }

  throw new IllegalArgumentException("Unsupported handler type.");
}
 
开发者ID:apache,项目名称:incubator-tephra,代码行数:26,代码来源:ThriftRPCServer.java

示例12: getProcessorIface

import org.apache.thrift.TProcessor; //导入依赖的package包/类
/**
 * 根据refImpl来获取相应的TProcessor,然后构造一个对象
 * 
 * @return
 */
private TProcessor getProcessorIface(Class iface) {

    if (iface == null) {
        LOGGER.error("refImpl is not thrift implement class instance.");
        throw new OureaException("invalid null refImpl params");
    }

    String parentClazzName = StringUtils.substringBeforeLast(iface.getCanonicalName(), ".Iface");
    String processorClazzName = parentClazzName + "$Processor";

    try {

        Class clazz = Class.forName(processorClazzName);
        if (clazz.isMemberClass() && !clazz.isInterface()) {
            @SuppressWarnings("unchecked")
            Class<TProcessor> processorClazz = (Class<TProcessor>) clazz;
            return processorClazz.getConstructor(iface).newInstance(refImpl);
        }
        return null;
    } catch (Exception e) {
        LOGGER.error("get thrift Porcessor class from Iface class fail.e:", e);
        throw new OureaException("invalid iface class params maybe not thrift class.");
    }
}
 
开发者ID:ketao1989,项目名称:ourea,代码行数:30,代码来源:ServiceProvider.java

示例13: createThrift

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

示例14: ThriftServerThread

import org.apache.thrift.TProcessor; //导入依赖的package包/类
public ThriftServerThread(InetAddress listenAddr,
                          int listenPort,
                          int listenBacklog,
                          TProcessor processor,
                          TTransportFactory transportFactory)
{
    // now we start listening for clients
    logger.info(String.format("Binding thrift service to %s:%s", listenAddr, listenPort));

    TServerFactory.Args args = new TServerFactory.Args();
    args.tProtocolFactory = new TBinaryProtocol.Factory(true, true);
    args.addr = new InetSocketAddress(listenAddr, listenPort);
    args.listenBacklog = listenBacklog;
    args.processor = processor;
    args.keepAlive = DatabaseDescriptor.getRpcKeepAlive();
    args.sendBufferSize = DatabaseDescriptor.getRpcSendBufferSize();
    args.recvBufferSize = DatabaseDescriptor.getRpcRecvBufferSize();
    args.inTransportFactory = transportFactory;
    args.outTransportFactory = transportFactory;
    serverEngine = new TServerCustomFactory(DatabaseDescriptor.getRpcServerType()).buildTServer(args);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:ThriftServer.java

示例15: ThriftServerThread

import org.apache.thrift.TProcessor; //导入依赖的package包/类
public ThriftServerThread(InetAddress listenAddr,
                          int listenPort,
                          CassandraServer server,
                          TProcessor processor,
                          TTransportFactory transportFactory)
{
    // now we start listening for clients
    logger.info(String.format("Binding thrift service to %s:%s", listenAddr, listenPort));

    TServerFactory.Args args = new TServerFactory.Args();
    args.tProtocolFactory = new TBinaryProtocol.Factory(true, true);
    args.addr = new InetSocketAddress(listenAddr, listenPort);
    args.cassandraServer = server;
    args.processor = processor;
    args.keepAlive = DatabaseDescriptor.getRpcKeepAlive();
    args.sendBufferSize = DatabaseDescriptor.getRpcSendBufferSize();
    args.recvBufferSize = DatabaseDescriptor.getRpcRecvBufferSize();
    args.inTransportFactory = transportFactory;
    args.outTransportFactory = transportFactory;
    serverEngine = new TServerCustomFactory(DatabaseDescriptor.getRpcServerType()).buildTServer(args);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:ThriftServer.java


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