org.apache.thrift.TProcessor Java Examples

The following examples show how to use org.apache.thrift.TProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncServer.java    From ThriftBook with Apache License 2.0 7 votes vote down vote up
public static void main(String[] args)
        throws TTransportException, IOException, InterruptedException {

    FloorBroker floor = new FloorBroker();
    (new Thread(floor)).start();

    TProcessor proc = new TradeReporting.TradeHistory.AsyncProcessor(
        new AsyncTradeHistoryHandler(floor.getQ()));
    TNonblockingServerSocket trans_svr = new TNonblockingServerSocket(9090);
    TServer server = 
        new THsHaServer(new THsHaServer.Args(trans_svr)
            .processor(proc)
            .protocolFactory(new TBinaryProtocol.Factory())
            .minWorkerThreads(4)
            .maxWorkerThreads(4));
    System.out.println("[Server] listening of port 9090");
    server.serve();
}
 
Example #2
Source File: GfxdThriftServerSelector.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: ThriftServer.java    From hbase with Apache License 2.0 6 votes vote down vote up
protected TServer getTHsHaServer(TNonblockingServerTransport serverTransport,
    TProtocolFactory protocolFactory, TProcessor processor, TTransportFactory transportFactory,
    InetSocketAddress inetSocketAddress) {
  LOG.info("starting HBase HsHA Thrift server on " + inetSocketAddress.toString());
  THsHaServer.Args serverArgs = new THsHaServer.Args(serverTransport);
  int queueSize = conf.getInt(TBoundedThreadPoolServer.MAX_QUEUED_REQUESTS_CONF_KEY,
      TBoundedThreadPoolServer.DEFAULT_MAX_QUEUED_REQUESTS);
  CallQueue callQueue = new CallQueue(new LinkedBlockingQueue<>(queueSize), metrics);
  int workerThread = conf.getInt(TBoundedThreadPoolServer.MAX_WORKER_THREADS_CONF_KEY,
      serverArgs.getMaxWorkerThreads());
  ExecutorService executorService = createExecutor(
      callQueue, workerThread, workerThread);
  serverArgs.executorService(executorService).processor(processor)
      .transportFactory(transportFactory).protocolFactory(protocolFactory);
  return new THsHaServer(serverArgs);
}
 
Example #4
Source File: TestClientsWithApacheServer.java    From drift with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: ThriftRPCServer.java    From phoenix-tephra with Apache License 2.0 6 votes vote down vote up
@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.");
}
 
Example #6
Source File: SimpleTransportPlugin.java    From jstorm with Apache License 2.0 6 votes vote down vote up
@Override
public TServer getServer(TProcessor processor) throws IOException, TTransportException {
    int port = type.getPort(storm_conf);
    TNonblockingServerSocket serverTransport = new TNonblockingServerSocket(port);
    int numWorkerThreads = type.getNumThreads(storm_conf);
    int maxBufferSize = type.getMaxBufferSize(storm_conf);
    Integer queueSize = type.getQueueSize(storm_conf);

    THsHaServer.Args server_args =
            new THsHaServer.Args(serverTransport).processor(new SimpleWrapProcessor(processor)).workerThreads(numWorkerThreads)
                    .protocolFactory(new TBinaryProtocol.Factory(false, true, maxBufferSize, -1));

    if (queueSize != null) {
        server_args.executorService(new ThreadPoolExecutor(numWorkerThreads, numWorkerThreads, 60, TimeUnit.SECONDS, new ArrayBlockingQueue(queueSize)));
    }

    // construct THsHaServer
    return new THsHaServer(server_args);
}
 
Example #7
Source File: ThriftServer.java    From hbase with Apache License 2.0 6 votes vote down vote up
protected TServer getTThreadPoolServer(TProtocolFactory protocolFactory, TProcessor processor,
    TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) throws Exception {
  LOG.info("starting HBase ThreadPool Thrift server on " + inetSocketAddress.toString());
  // Thrift's implementation uses '0' as a placeholder for 'use the default.'
  int backlog = conf.getInt(BACKLOG_CONF_KEY, BACKLOG_CONF_DEAFULT);
  int readTimeout = conf.getInt(THRIFT_SERVER_SOCKET_READ_TIMEOUT_KEY,
      THRIFT_SERVER_SOCKET_READ_TIMEOUT_DEFAULT);
  TServerTransport serverTransport = new TServerSocket(
      new TServerSocket.ServerSocketTransportArgs().
          bindAddr(inetSocketAddress).backlog(backlog).
          clientTimeout(readTimeout));

  TBoundedThreadPoolServer.Args serverArgs =
      new TBoundedThreadPoolServer.Args(serverTransport, conf);
  serverArgs.processor(processor).transportFactory(transportFactory)
      .protocolFactory(protocolFactory);
  return new TBoundedThreadPoolServer(serverArgs, metrics);
}
 
Example #8
Source File: GfxdThriftServerSelector.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #9
Source File: ThriftServerApplication.java    From spring-boot-demo with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    SpringApplication.run(ThriftServerApplication.class, args);

    try {
        System.out.println("服务端开启....");
        TProcessor tprocessor = new Hello.Processor<Hello.Iface>(new HelloServiceImpl());
        // 简单的单线程服务模型
        TServerSocket serverTransport = new TServerSocket(9898);
        TServer.Args tArgs = new TServer.Args(serverTransport);
        tArgs.processor(tprocessor);
        tArgs.protocolFactory(new TBinaryProtocol.Factory());
        TServer server = new TSimpleServer(tArgs);
        server.serve();
    } catch (TTransportException e) {
        e.printStackTrace();
    }
}
 
Example #10
Source File: ThriftServer.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #11
Source File: ThriftTest.java    From java-specialagent with Apache License 2.0 6 votes vote down vote up
private void startNewThreadPoolServer() throws Exception {
  final TServerTransport transport = new TServerSocket(port);
  final TProtocolFactory protocolFactory = new TBinaryProtocol.Factory();
  // TTransportFactory transportFactory = new TFramedTransport.Factory();

  final CustomHandler customHandler = new CustomHandler();
  final TProcessor customProcessor = new CustomService.Processor<CustomService.Iface>(customHandler);

  final TThreadPoolServer.Args args = new TThreadPoolServer.Args(transport)
    .processorFactory(new TProcessorFactory(customProcessor))
    .protocolFactory(protocolFactory)
    // .transportFactory(transportFactory)
    .minWorkerThreads(5)
    // .executorService(Executors.newCachedThreadPool())
    .maxWorkerThreads(10);

  server = new TThreadPoolServer(args);
  new Thread(new Runnable() {
    @Override
    public void run() {
      server.serve();
    }
  }).start();
}
 
Example #12
Source File: TSetIpAddressProcessorFactory.java    From waggle-dance with Apache License 2.0 6 votes vote down vote up
@Override
public TProcessor getProcessor(TTransport transport) {
  try {
    if (transport instanceof TSocket) {
      Socket socket = ((TSocket) transport).getSocket();
      log.debug("Received a connection from ip: {}", socket.getInetAddress().getHostAddress());
    }
    CloseableIHMSHandler baseHandler = federatedHMSHandlerFactory.create();
    IHMSHandler handler = newRetryingHMSHandler(ExceptionWrappingHMSHandler.newProxyInstance(baseHandler), hiveConf,
        false);
    transportMonitor.monitor(transport, baseHandler);
    return new TSetIpAddressProcessor<>(handler);
  } catch (MetaException | ReflectiveOperationException | RuntimeException e) {
    throw new RuntimeException("Error creating TProcessor", e);
  }
}
 
Example #13
Source File: ThriftServer.java    From hbase with Apache License 2.0 6 votes vote down vote up
protected TServer getTThreadedSelectorServer(TNonblockingServerTransport serverTransport,
    TProtocolFactory protocolFactory, TProcessor processor, TTransportFactory transportFactory,
    InetSocketAddress inetSocketAddress) {
  LOG.info("starting HBase ThreadedSelector Thrift server on " + inetSocketAddress.toString());
  TThreadedSelectorServer.Args serverArgs =
      new HThreadedSelectorServerArgs(serverTransport, conf);
  int queueSize = conf.getInt(TBoundedThreadPoolServer.MAX_QUEUED_REQUESTS_CONF_KEY,
      TBoundedThreadPoolServer.DEFAULT_MAX_QUEUED_REQUESTS);
  CallQueue callQueue = new CallQueue(new LinkedBlockingQueue<>(queueSize), metrics);
  int workerThreads = conf.getInt(TBoundedThreadPoolServer.MAX_WORKER_THREADS_CONF_KEY,
      serverArgs.getWorkerThreads());
  int selectorThreads = conf.getInt(THRIFT_SELECTOR_NUM, serverArgs.getSelectorThreads());
  serverArgs.selectorThreads(selectorThreads);
  ExecutorService executorService = createExecutor(
      callQueue, workerThreads, workerThreads);
  serverArgs.executorService(executorService).processor(processor)
      .transportFactory(transportFactory).protocolFactory(protocolFactory);
  return new TThreadedSelectorServer(serverArgs);
}
 
Example #14
Source File: rpcServer.java    From leaf-snowflake with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #15
Source File: DKMLServer.java    From dk-fitting with Apache License 2.0 6 votes vote down vote up
/**
 * 阻塞式、多线程处理
 *
 * @param args
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void main(String[] args) {
    try {
        int port = Integer.valueOf(prop.get("dkml.port"));
        //设置传输通道,普通通道
        TServerTransport serverTransport = new TServerSocket(port);
        //使用高密度二进制协议
        TProtocolFactory proFactory = new TCompactProtocol.Factory();
        //设置处理器
        TProcessor processor = new DKML.Processor(new DKMLImpl());
        //创建服务器
        TServer server = new TThreadPoolServer(
                new TThreadPoolServer.Args(serverTransport)
                        .protocolFactory(proFactory)
                        .processor(processor)
        );

        System.out.println("Start server on port "+ port +"...");
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #16
Source File: rpcServer.java    From leaf-snowflake with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #17
Source File: TFactoryBasedThreadPoolServer.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Loops on processing a client forever
 */
public void run() {
  TProcessor processor = null;
  TTransport inputTransport = null;
  TTransport outputTransport = null;
  TProtocol inputProtocol = null;
  TProtocol outputProtocol = null;
  try {
    processor = processorFactory_.getProcessor(client_);
    inputTransport = inputTransportFactory_.getTransport(client_);
    outputTransport = outputTransportFactory_.getTransport(client_);
    inputProtocol = inputProtocolFactory_.getProtocol(inputTransport);
    outputProtocol = outputProtocolFactory_.getProtocol(outputTransport);
    // we check stopped_ first to make sure we're not supposed to be shutting
    // down. this is necessary for graceful shutdown.
    while (!stopped_ && processor.process(inputProtocol, outputProtocol)) {}
  } catch (TTransportException ttx) {
    // Assume the client died and continue silently
  } catch (TException tx) {
    LOG.error("Thrift error occurred during processing of message.", tx);
  } catch (Exception x) {
    LOG.error("Error occurred during processing of message.", x);
  }

  if (inputTransport != null) {
    inputTransport.close();
  }

  if (outputTransport != null) {
    outputTransport.close();
  }
}
 
Example #18
Source File: ServerTest.java    From ikasoa with MIT License 5 votes vote down vote up
@SneakyThrows
@Test
@Override
public void afterStart(String serverName, int serverPort, ServerConfiguration configuration,
		TProcessor processor, ThriftServer server) {
	assertEquals(ServerTest.serverName, serverName);
	assertEquals(ServerUtil.getNewPort("testServerAspect"), serverPort);
	waiting();
	assertTrue(server.isServing());
}
 
Example #19
Source File: ThreadPoolThriftServerImpl.java    From ikasoa with MIT License 5 votes vote down vote up
public ThreadPoolThriftServerImpl(final String serverName, final int serverPort,
		final ThriftServerConfiguration configuration, final TProcessor processor) {
	setServerName(serverName);
	setServerPort(serverPort);
	setConfiguration(configuration);
	setProcessor(processor);
}
 
Example #20
Source File: ServerTest.java    From ikasoa with MIT License 5 votes vote down vote up
@Test
@Override
public void beforeStop(String serverName, int serverPort, ServerConfiguration configuration,
		TProcessor processor, ThriftServer server) {
	assertEquals(ServerTest.serverName, serverName);
	assertEquals(ServerUtil.getNewPort("testServerAspect"), serverPort);
	assertTrue(server.isServing());
}
 
Example #21
Source File: OracleServer.java    From fluo with Apache License 2.0 5 votes vote down vote up
private InetSocketAddress startServer() throws TTransportException {
  Preconditions.checkState(
      curatorFramework != null && curatorFramework.getState() == CuratorFrameworkState.STARTED);

  if (env.getConfiguration().containsKey(FluoConfigurationImpl.ORACLE_PORT_PROP)) {
    port = env.getConfiguration().getInt(FluoConfigurationImpl.ORACLE_PORT_PROP);
    Preconditions.checkArgument(port >= 1 && port <= 65535,
        FluoConfigurationImpl.ORACLE_PORT_PROP + " must be valid port (1-65535)");
  } else {
    port = PortUtils.getRandomFreePort();
  }
  InetSocketAddress addr = new InetSocketAddress(port);

  TNonblockingServerSocket socket = new TNonblockingServerSocket(addr);

  THsHaServer.Args serverArgs = new THsHaServer.Args(socket);
  TProcessor processor = new OracleService.Processor<OracleService.Iface>(this);
  serverArgs.processor(processor);
  serverArgs.maxReadBufferBytes = ORACLE_MAX_READ_BUFFER_BYTES;
  serverArgs.inputProtocolFactory(new TCompactProtocol.Factory());
  serverArgs.outputProtocolFactory(new TCompactProtocol.Factory());
  server = new THsHaServer(serverArgs);

  serverThread = new Thread(server::serve);
  serverThread.setDaemon(true);
  serverThread.start();

  return addr;
}
 
Example #22
Source File: NettyServerImpl.java    From ikasoa with MIT License 5 votes vote down vote up
public NettyServerImpl(final String serverName, final int serverPort, final NettyServerConfiguration configuration,
		final TProcessor processor, final ChannelGroup allChannels) {
	setServerName(serverName);
	requestedPort = serverPort;
	setConfiguration(ObjectUtil.isNull(configuration)
			? new NettyServerConfiguration(new TProcessorFactory(processor)) : configuration);
	setProcessor(processor);
	this.allChannels = allChannels;
}
 
Example #23
Source File: CatalogThriftService.java    From metacat with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public TProcessor getProcessor() {
    return new ThriftHiveMetastore.Processor<>(
        new CatalogThriftHiveMetastore(config, hiveConverters, metacatV1, partitionV1, catalogName, registry)
    );
}
 
Example #24
Source File: AbstractTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected TProcessor getProcessor() {
    MultiServiceProcessor result = new MultiServiceProcessor();
    result.addProcessor(
            com.alibaba.dubbo.rpc.gen.dubbo.Demo.class,
            new $__DemoStub.Processor( getServiceImpl() ) );
    return result;
}
 
Example #25
Source File: ServiceProvider.java    From ourea with Apache License 2.0 5 votes vote down vote up
/**
 * 启动thrift server,如果存在server容器或者多个service,则一些需要设置为daemon模式
 */
private void startServer() throws Exception {

    TServerSocket serverTransport = new TServerSocket(serverConfig.getPort());
    TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverTransport);
    args.maxWorkerThreads = serverConfig.getMaxWorkerThreads();
    args.minWorkerThreads = serverConfig.getMinWorkerThreads();
    args.protocolFactory(new TBinaryProtocol.Factory());

    TProcessor tProcessor = getProcessorIface(getIfaceClass());
    args.processor(tProcessor);
    final TServer server = new TThreadPoolServer(args);
    server.setServerEventHandler(serverConfig.getServerEventHandler());
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            server.serve();
        }
    });
    thread.setDaemon(serverConfig.isDaemonRun());
    thread.start();
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override public void run() {
            if (!serverConfig.isDirectInvoke()) {
                unZkRegister(providerInfo, serviceInfo);
            }
            server.stop();
        }
    }));

    LOGGER.info("----------------start thrift server--------------");
}
 
Example #26
Source File: GfxdThriftServerSelector.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected ClientProcessData newClientProcessData(GfxdTSocket client) {
  TProcessor processor = processorFactory_.getProcessor(client);
  TProtocol inputProtocol = inputProtocolFactory_.getProtocol(client);
  TProtocol outputProtocol = outputProtocolFactory_.getProtocol(client);

  final int connectionNumber = connectionCounter.incrementAndGet();
  // register with ConnectionListener
  final ConnectionListener listener = connListener;
  if (listener != null) {
    listener.connectionOpened(client.getSocket(), connectionNumber);
  }

  return new ClientProcessData(client, connectionNumber, processor, client,
      client, inputProtocol, outputProtocol, getEventHandler());
}
 
Example #27
Source File: HttpEchoTestServer.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
protected HttpEchoTestServer(TestEnvironment environment, TProcessor processor) {
    this.environment = environment;
    int port = this.environment.getPort();
    String path = this.environment.getHttpPath();
    TProtocolFactory protocolFactory = this.environment.getProtocolFactory();
    this.server = new Server(port);
    this.server.setHandler(new EchoHttpServerHandler(path, processor, protocolFactory));
}
 
Example #28
Source File: ZkServerAspect.java    From ikasoa with MIT License 5 votes vote down vote up
@Override
public void afterStop(String serverName, int serverPort, ServerConfiguration configuration, TProcessor processor,
		ThriftServer server) {
	if (StringUtil.isNotEmpty(sNodeStr)) {
		log.debug("Delete server node : {}", sNodeStr);
		zkBase.getZkClient().delete(sNodeStr);
	}
}
 
Example #29
Source File: GfxdThriftServerSelector.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected ClientProcessData newClientProcessData(GfxdTSocket client) {
  TProcessor processor = processorFactory_.getProcessor(client);
  TProtocol inputProtocol = inputProtocolFactory_.getProtocol(client);
  TProtocol outputProtocol = outputProtocolFactory_.getProtocol(client);

  final int connectionNumber = connectionCounter.incrementAndGet();
  // register with ConnectionListener
  final ConnectionListener listener = connListener;
  if (listener != null) {
    listener.connectionOpened(client.getSocket(), connectionNumber);
  }

  return new ClientProcessData(client, connectionNumber, processor, client,
      client, inputProtocol, outputProtocol, getEventHandler());
}
 
Example #30
Source File: SentryHDFSServiceProcessorFactory.java    From incubator-sentry with Apache License 2.0 5 votes vote down vote up
@Override
public boolean register(TMultiplexedProcessor multiplexedProcessor) throws Exception {
  SentryHDFSServiceProcessor sentryServiceHandler =
      new SentryHDFSServiceProcessor();
  LOGGER.info("Calling registerProcessor from SentryHDFSServiceProcessorFactory");
  TProcessor processor = new ProcessorWrapper(sentryServiceHandler);
  multiplexedProcessor.registerProcessor(
      SentryHDFSServiceClient.SENTRY_HDFS_SERVICE_NAME, processor);
  return true;
}