當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。