Java Code Examples for org.apache.thrift.server.THsHaServer#Args
The following examples show how to use
org.apache.thrift.server.THsHaServer#Args .
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: ThriftServer.java From hbase with Apache License 2.0 | 6 votes |
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 2
Source File: ScribeSource.java From mt-flume with Apache License 2.0 | 6 votes |
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()); args.protocolFactory(new TBinaryProtocol.Factory(false, false)); server = new THsHaServer(args); LOG.info("Starting Scribe Source on port " + port); server.serve(); } catch (Exception e) { LOG.warn("Scribe failed", e); } }
Example 3
Source File: SuroServer4Test.java From suro with Apache License 2.0 | 6 votes |
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(); }
Example 4
Source File: Drpc.java From jstorm with Apache License 2.0 | 6 votes |
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)); LOG.info("Begin to init DRPC handler server at port: " + port); 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<Runnable>(queueSize)); targs.executorService(executor); THsHaServer handlerServer = new THsHaServer(targs); LOG.info("Successfully inited DRPC handler server at port: " + port); return handlerServer; }
Example 5
Source File: Drpc.java From jstorm with Apache License 2.0 | 6 votes |
private THsHaServer initInvokeServer(Map conf, final Drpc service) throws Exception { int port = JStormUtils.parseInt(conf.get(Config.DRPC_INVOCATIONS_PORT)); LOG.info("Begin to init DRPC invoke server at port: " + port); TNonblockingServerSocket socket = new TNonblockingServerSocket(port); THsHaServer.Args targsInvoke = new THsHaServer.Args(socket); targsInvoke.workerThreads(64); targsInvoke.protocolFactory(new TBinaryProtocol.Factory()); targsInvoke.processor(new DistributedRPCInvocations.Processor<DistributedRPCInvocations.Iface>(service)); THsHaServer invokeServer = new THsHaServer(targsInvoke); LOG.info("Successfully inited DRPC invoke server at port: " + port); return invokeServer; }
Example 6
Source File: NimbusServer.java From jstorm with Apache License 2.0 | 6 votes |
@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(); }
Example 7
Source File: SimpleTransportPlugin.java From jstorm with Apache License 2.0 | 6 votes |
@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 8
Source File: PacketStreamerServer.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
/** * 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(); } }
Example 9
Source File: OracleServer.java From fluo with Apache License 2.0 | 5 votes |
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 10
Source File: ServerArgsAspect.java From ikasoa with MIT License | 4 votes |
public THsHaServer.Args tHsHaServerArgsAspect(THsHaServer.Args args) { return args; }