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; }
private THsHaServer initInvokeServer(Map conf, final Drpc service) throws Exception { int port = JStormUtils.parseInt(conf.get(Config.DRPC_INVOCATIONS_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 init Invoke Server " + port); return invokeServer; }
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)); args.processor(new Nimbus.Processor<Iface>(serviceHandler)); args.maxReadBufferBytes = maxReadBufSize; thriftServer = new THsHaServer(args); LOG.info("Successfully started nimbus: started Thrift server..."); thriftServer.serve(); }
@Override public TServer getServer(int port, TProcessor processor) throws IOException, TTransportException { TTransportFactory serverTransportFactory = getServerTransportFactory(); // define THsHaServer args // original: THsHaServer + TNonblockingServerSocket // option: TThreadPoolServer + TServerSocket TServerSocket serverTransport = new TServerSocket(port); TThreadPoolServer.Args server_args = new TThreadPoolServer.Args( serverTransport).processor(new TUGIWrapProcessor(processor)) .minWorkerThreads(64).maxWorkerThreads(64) .protocolFactory(new TBinaryProtocol.Factory()); if (serverTransportFactory != null) server_args.transportFactory(serverTransportFactory); // construct THsHaServer return new TThreadPoolServer(server_args); }
@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)); args.processor(new Nimbus.Processor<Iface>(serviceHandler)); args.maxReadBufferBytes = maxReadBufSize; thriftServer = new THsHaServer(args); LOG.info("Successfully started nimbus: started Thrift server..."); thriftServer.serve(); }
public TServer getServer(int port, TProcessor processor) throws IOException, TTransportException { TTransportFactory serverTransportFactory = getServerTransportFactory(); // define THsHaServer args // original: THsHaServer + TNonblockingServerSocket // option: TThreadPoolServer + TServerSocket TServerSocket serverTransport = new TServerSocket(port); TThreadPoolServer.Args server_args = new TThreadPoolServer.Args( serverTransport).processor(new TUGIWrapProcessor(processor)) .minWorkerThreads(64).maxWorkerThreads(64) .protocolFactory(new TBinaryProtocol.Factory()); if (serverTransportFactory != null) server_args.transportFactory(serverTransportFactory); // construct THsHaServer return new TThreadPoolServer(server_args); }
@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)); args.processor(new Nimbus.Processor<Iface>(serviceHandler)); args.maxReadBufferBytes = maxReadBufSize; thriftServer = new THsHaServer(args); LOG.info("Successfully started nimbus: started Thrift server..."); thriftServer.serve(); }
public static List nimbusClientandConn(String host, Integer port) throws TTransportException { TSocket ts = new TSocket(host, port); TFramedTransport tt = new TFramedTransport(ts); TBinaryProtocol prot = new TBinaryProtocol(tt); Client nc = new Client(prot); ts.open(); List l = new ArrayList(); l.add(nc); l.add(tt); return l; }
/** * We will let Thrift to apply default transport factory */ @Override public TServer getServer(int port, TProcessor processor) throws IOException, TTransportException { TNonblockingServerSocket serverTransport = new TNonblockingServerSocket( port); THsHaServer.Args server_args = new THsHaServer.Args(serverTransport) .processor(new SimpleWrapProcessor(processor)) .workerThreads(64) .protocolFactory(new TBinaryProtocol.Factory()); // construct THsHaServer return new THsHaServer(server_args); }
private void connect() throws TException { TSocket socket = new TSocket(host, port); if (timeout != null) { socket.setTimeout(timeout); } conn = new TFramedTransport(socket); client = new DistributedRPC.Client(new TBinaryProtocol(conn)); conn.open(); }
/** * We will let Thrift to apply default transport factory */ public TServer getServer(int port, TProcessor processor) throws IOException, TTransportException { TNonblockingServerSocket serverTransport = new TNonblockingServerSocket(port); THsHaServer.Args server_args = new THsHaServer.Args(serverTransport). processor(new SimpleWrapProcessor(processor)). workerThreads(64). protocolFactory(new TBinaryProtocol.Factory()); //construct THsHaServer return new THsHaServer(server_args); }
/** * We will let Thrift to apply default transport factory */ public TServer getServer(int port, TProcessor processor) throws IOException, TTransportException { TNonblockingServerSocket serverTransport = new TNonblockingServerSocket( port); THsHaServer.Args server_args = new THsHaServer.Args(serverTransport) .processor(new SimpleWrapProcessor(processor)) .workerThreads(64) .protocolFactory(new TBinaryProtocol.Factory()); // construct THsHaServer return new THsHaServer(server_args); }
/** * Creates a connection with explicit nimbus host. Ignored if a local cluster is set * for testing. * * @param nimbusHost the nimbus host name * @param port the nimbus port number * @see #setLocalCluster(ILocalCluster) */ public ThriftConnection(String nimbusHost, int port) { if (null == localCluster) { socket = new TSocket(nimbusHost, port); LOGGER.info("Thrift connection info " + nimbusHost + " " + port); transport = new TFramedTransport(socket); protocol = new TBinaryProtocol(transport); client = new Client(protocol); } }
public KestrelThriftClient(String hostname, int port) throws TException { _transport = new TFramedTransport(new TSocket(hostname, port)); final TProtocol proto = new TBinaryProtocol(_transport); _client = new Kestrel.Client(proto); _transport.open(); }
private void connect() throws TException { conn = new TFramedTransport(new TSocket(host, port)); client = new DistributedRPCInvocations.Client(new TBinaryProtocol(conn)); conn.open(); }