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


Java THsHaServer类代码示例

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


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

示例1: nonBlockMode

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
private void nonBlockMode() {
        AskerHandler handler = new AskerHandler();
        Asker.Processor processor = new Asker.Processor(handler);
        try {
            TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
            THsHaServer.Args arg = new THsHaServer.Args(transport);
            arg.protocolFactory(new TCompactProtocol.Factory());
//            arg.transportFactory(new TFramedTransport.Factory());
//            arg.processorFactory(new TProcessorFactory(processor));
            arg.processor(processor);
            server = new THsHaServer(arg);
            start.countDown();

            System.out.println("Starting the nonBlock server...");
            server.serve();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
开发者ID:altiplanogao,项目名称:rpc-comparison,代码行数:20,代码来源:AskerServer.java

示例2: ThriftTestingSource

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
public ThriftTestingSource(String handlerName, int port, String protocol) throws Exception {
  TNonblockingServerTransport serverTransport =
      new TNonblockingServerSocket(new InetSocketAddress("0.0.0.0", port));
  ThriftSourceProtocol.Iface handler = getHandler(handlerName);

  TProtocolFactory transportProtocolFactory = null;
  if (protocol != null && protocol == ThriftRpcClient.BINARY_PROTOCOL) {
    transportProtocolFactory = new TBinaryProtocol.Factory();
  } else {
    transportProtocolFactory = new TCompactProtocol.Factory();
  }
  server = new THsHaServer(new THsHaServer.Args(serverTransport).processor(
      new ThriftSourceProtocol.Processor(handler)).protocolFactory(
          transportProtocolFactory));
  Executors.newSingleThreadExecutor().submit(new Runnable() {
    @Override
    public void run() {
      server.serve();
    }
  });
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:22,代码来源:ThriftTestingSource.java

示例3: run

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
public void run() {
  try {
    Scribe.Processor processor = new Scribe.Processor(new Receiver());
    TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
    THsHaServer.Args args = new THsHaServer.Args(transport);

    args.workerThreads(workers);
    args.processor(processor);
    args.transportFactory(new TFramedTransport.Factory(maxReadBufferBytes));
    args.protocolFactory(new TBinaryProtocol.Factory(false, false));
    args.maxReadBufferBytes = maxReadBufferBytes;

    server = new THsHaServer(args);

    LOG.info("Starting Scribe Source on port " + port);

    server.serve();
  } catch (Exception e) {
    LOG.warn("Scribe failed", e);
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:22,代码来源:ScribeSource.java

示例4: hshaServer

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:PacketStreamerServer.java

示例5: hshaServer

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
/**
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:20,代码来源:PacketStreamerServer.java

示例6: startHshaServer

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
@VisibleForTesting
public static TServer startHshaServer(TProcessor processor, int portNumber) throws Exception {

    final TNonblockingServerSocket socket = new TNonblockingServerSocket(portNumber);
    final THsHaServer.Args serverArgs = new THsHaServer.Args(socket);
    serverArgs.processor(processor);
    serverArgs.inputProtocolFactory(new TCompactProtocol.Factory());
    serverArgs.outputProtocolFactory(new TCompactProtocol.Factory());
    final TServer server = new THsHaServer(serverArgs);
    final Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
            server.serve();
        }
    });
    t.start();
    return server;
}
 
开发者ID:ezbake,项目名称:ezbake-common-java,代码行数:19,代码来源:ThriftUtils.java

示例7: initHandlerServer

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
private THsHaServer initHandlerServer(Map conf, final Drpc service) throws Exception {
    int port = JStormUtils.parseInt(conf.get(Config.DRPC_PORT));
    int workerThreadNum = JStormUtils.parseInt(conf.get(Config.DRPC_WORKER_THREADS));
    int queueSize = JStormUtils.parseInt(conf.get(Config.DRPC_QUEUE_SIZE));

    TNonblockingServerSocket socket = new TNonblockingServerSocket(port);
    THsHaServer.Args targs = new THsHaServer.Args(socket);
    targs.workerThreads(64);
    targs.protocolFactory(new TBinaryProtocol.Factory());
    targs.processor(new DistributedRPC.Processor<DistributedRPC.Iface>(service));

    ThreadPoolExecutor executor = new ThreadPoolExecutor(workerThreadNum, workerThreadNum, 60, TimeUnit.SECONDS, new ArrayBlockingQueue(queueSize));
    targs.executorService(executor);

    THsHaServer handlerServer = new THsHaServer(targs);
    LOG.info("Successfully init Handler Server " + port);

    return handlerServer;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:20,代码来源:Drpc.java

示例8: initThrift

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private void initThrift(Map conf) throws TTransportException {
    Integer thrift_port = JStormUtils.parseInt(conf.get(Config.NIMBUS_THRIFT_PORT));
    TNonblockingServerSocket socket = new TNonblockingServerSocket(thrift_port);

    Integer maxReadBufSize = JStormUtils.parseInt(conf.get(Config.NIMBUS_THRIFT_MAX_BUFFER_SIZE));

    THsHaServer.Args args = new THsHaServer.Args(socket);
    args.workerThreads(ServiceHandler.THREAD_NUM);
    args.protocolFactory(new TBinaryProtocol.Factory(false, true, maxReadBufSize, -1));

    args.processor(new Nimbus.Processor<Iface>(serviceHandler));
    args.maxReadBufferBytes = maxReadBufSize;

    thriftServer = new THsHaServer(args);

    LOG.info("Successfully started nimbus: started Thrift server...");
    thriftServer.serve();
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:20,代码来源:NimbusServer.java

示例9: getServer

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
@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);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:20,代码来源:SimpleTransportPlugin.java

示例10: getTHsHaServer

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
private static TServer getTHsHaServer(TProtocolFactory protocolFactory,
    TProcessor processor, TTransportFactory transportFactory,
    int workerThreads, int maxCallQueueSize,
    InetSocketAddress inetSocketAddress, ThriftMetrics metrics)
    throws TTransportException {
  TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
  log.info("starting HBase HsHA Thrift server on " + inetSocketAddress.toString());
  THsHaServer.Args serverArgs = new THsHaServer.Args(serverTransport);
  if (workerThreads > 0) {
    // Could support the min & max threads, avoiding to preserve existing functionality.
    serverArgs.minWorkerThreads(workerThreads).maxWorkerThreads(workerThreads);
  }
  ExecutorService executorService = createExecutor(
      workerThreads, maxCallQueueSize, metrics);
  serverArgs.executorService(executorService);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  return new THsHaServer(serverArgs);
}
 
开发者ID:apache,项目名称:hbase,代码行数:21,代码来源:ThriftServer.java

示例11: main

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
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();
}
 
开发者ID:RandyAbernethy,项目名称:ThriftBook,代码行数:19,代码来源:AsyncServer.java

示例12: halfSyncHalfAsyncServer

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
public static AsyncEchoTestServer<THsHaServer> halfSyncHalfAsyncServer(final TestEnvironment environment)
        throws TTransportException {
    THsHaServer server = new THsHaServer(new THsHaServer.Args(new TNonblockingServerSocket(
            environment.getPort())).processor(getAsyncProcessor())
            .inputProtocolFactory(environment.getProtocolFactory())
            .outputProtocolFactory(environment.getProtocolFactory()));
    return new AsyncEchoTestServer<THsHaServer>(server, environment) {
        @Override
        public SyncEchoTestClient getSynchronousClient() throws TTransportException {
            return new SyncEchoTestClient.ClientForNonblockingServer(environment);
        }

        @Override
        public AsyncEchoTestClient getAsynchronousClient() throws IOException {
            return new AsyncEchoTestClient.Client(environment);
        }
    };
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:19,代码来源:AsyncEchoTestServer.java

示例13: halfSyncHalfAsyncServer

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
public static SyncEchoTestServer<THsHaServer> halfSyncHalfAsyncServer(final TestEnvironment environment)
        throws TTransportException {
    THsHaServer server = new THsHaServer(new THsHaServer.Args(new TNonblockingServerSocket(
            environment.getPort())).processor(getProcessor())
            .inputProtocolFactory(environment.getProtocolFactory())
            .outputProtocolFactory(environment.getProtocolFactory()));
    return new SyncEchoTestServer<THsHaServer>(server, environment) {
        @Override
        public SyncEchoTestClient getSynchronousClient() throws TTransportException {
            return new SyncEchoTestClient.ClientForNonblockingServer(environment);
        }

        @Override
        public AsyncEchoTestClient getAsynchronousClient() throws IOException {
            return new AsyncEchoTestClient.Client(environment);
        }
    };
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:19,代码来源:SyncEchoTestServer.java

示例14: start

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
public  void start() throws Exception {
    transport = new TNonblockingServerSocket(port);
    processor =  new SuroServer.Processor(this);

    THsHaServer.Args serverArgs = new THsHaServer.Args(transport);
    serverArgs.processor(processor);
    serverArgs.workerThreads(2);

    server = new THsHaServer(serverArgs);
    System.out.println("Server started on port:" + port);

    Thread t = new Thread() {

        @Override
        public void run() {
            server.serve();
        }

    };
    t.start();

    Field serverSocketField = TNonblockingServerSocket.class.getDeclaredField("serverSocket_");
    serverSocketField.setAccessible(true);
    ServerSocket serverSocket = (ServerSocket) serverSocketField.get(transport);
    port = serverSocket.getLocalPort();
}
 
开发者ID:Netflix,项目名称:suro,代码行数:27,代码来源:SuroServer4Test.java

示例15: bogusDataTest

import org.apache.thrift.server.THsHaServer; //导入依赖的package包/类
/**
 * Test that bogus input into the oracle server doesn't cause an OOM exception. This essentially
 * tests for THRIFT-602
 */
@Test
public void bogusDataTest() throws Exception {

  // we are expecting an error at this point
  Level curLevel = Logger.getLogger(THsHaServer.class).getLevel();
  Logger.getLogger(THsHaServer.class).setLevel(Level.FATAL);

  Socket socket = new Socket();
  socket.connect(new InetSocketAddress(HostUtil.getHostName(), oserver.getPort()));
  OutputStream outstream = socket.getOutputStream();
  try (PrintWriter out = new PrintWriter(outstream)) {
    out.print("abcd");
    out.flush();
  }

  socket.close();

  OracleClient client = env.getSharedResources().getOracleClient();

  assertEquals(2, client.getStamp().getTxTimestamp());

  Logger.getLogger(THsHaServer.class).setLevel(curLevel);
}
 
开发者ID:apache,项目名称:fluo,代码行数:28,代码来源:OracleIT.java


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