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); }
public static MasterClient getConfiguredClient(Map conf) throws Exception { try { String masterHost = (String) conf.get(Config.MASTER_HOST); // String zookeeper = conf.get(Config.) LOG.info("masterHost is:" + masterHost); int masterPort = Utils.getInt(conf.get(Config.MASTER_THRIFT_PORT)); LOG.info("masterPort is" + masterPort); System.out.println("masterPort is" + masterPort); try { Integer timeout = Utils.getInt(conf.get(Config.MASTER_TIMEOUT_SECS)); return new MasterClient(conf, masterHost, masterPort, timeout); } catch (IllegalArgumentException e) { return new MasterClient(conf, masterHost, masterPort, null); } } catch (TTransportException ex) { throw new RuntimeException(ex); } }
@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(); }
@SuppressWarnings("rawtypes") public static MasterClient getConfiguredClient(Map conf) { try { String masterHost = (String) conf.get(Config.MASTER_HOST); int masterPort = Utils.getInt(conf.get(Config.MASTER_THRIFT_PORT)); try { Integer timeout = Utils.getInt(conf.get(Config.MASTER_TIMEOUT_SECS)); return new MasterClient(conf, masterHost, masterPort, timeout); } catch (IllegalArgumentException e) { return new MasterClient(conf, masterHost, masterPort, null); } } catch (TTransportException ex) { throw new RuntimeException(ex); } }
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; }
@Override public TTransport connect(TTransport transport, String serverHost) throws TTransportException, IOException { ClientCallbackHandler client_callback_handler = new ClientCallbackHandler( login_conf); TSaslClientTransport wrapper_transport = new TSaslClientTransport( DIGEST, null, AuthUtils.SERVICE, serverHost, null, client_callback_handler, transport); wrapper_transport.open(); LOG.debug("SASL DIGEST-MD5 client transport has been established"); return wrapper_transport; }
/** * 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); }
/** * Connect to the specified server via framed transport * * @param transport * The underlying Thrift transport. */ @Override public TTransport connect(TTransport transport, String serverHost) throws TTransportException { // create a framed transport TTransport conn = new TFramedTransport(transport); // connect conn.open(); LOG.debug("Simple client transport has been established"); return conn; }
/** * 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); }
/** * Connect to the specified server via framed transport * @param transport The underlying Thrift transport. */ public TTransport connect(TTransport transport, String serverHost) throws TTransportException { //create a framed transport TTransport conn = new TFramedTransport(transport); //connect conn.open(); LOG.debug("Simple client transport has been established"); return conn; }
public TTransport connect(TTransport transport, String serverHost) throws TTransportException, IOException { ClientCallbackHandler client_callback_handler = new ClientCallbackHandler( login_conf); TSaslClientTransport wrapper_transport = new TSaslClientTransport( DIGEST, null, AuthUtils.SERVICE, serverHost, null, client_callback_handler, transport); wrapper_transport.open(); LOG.debug("SASL DIGEST-MD5 client transport has been established"); return wrapper_transport; }
/** * 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); }
/** * Connect to the specified server via framed transport * * @param transport * The underlying Thrift transport. */ public TTransport connect(TTransport transport, String serverHost) throws TTransportException { // create a framed transport TTransport conn = new TFramedTransport(transport); // connect conn.open(); LOG.debug("Simple client transport has been established"); return conn; }
public ThriftClient(Map storm_conf, String host, int port) throws TTransportException { this(storm_conf, host, port, null); }
/** * Performs a failover, e.g., when a network connection closed due to failures. * * @param th the throwable causing the need for failover */ public void failover(Throwable th) { if ((th instanceof TTransportException) || (th instanceof SocketException)) { close(); // hope that it silently closes and a reconnect happens in the next round } }
@SuppressWarnings("rawtypes") public MasterClient(Map conf, String host, int port, Integer timeout) throws TTransportException { super(conf, host, port, timeout); _client = new StormMaster.Client(_protocol); }
/** * Create a server associated with a given port and service handler * * @param port * listening port * @param processor * service handler * @return server to be binded */ public TServer getServer(int port, TProcessor processor) throws IOException, TTransportException;
/** * Connect to the specified server via framed transport * * @param transport * The underlying Thrift transport. * @param serverHost * server host */ public TTransport connect(TTransport transport, String serverHost) throws IOException, TTransportException;
/** * Create a server associated with a given port and service handler * @param port listening port * @param processor service handler * @return server to be binded */ public TServer getServer(int port, TProcessor processor) throws IOException, TTransportException;
/** * Connect to the specified server via framed transport * @param transport The underlying Thrift transport. * @param serverHost server host */ public TTransport connect(TTransport transport, String serverHost) throws IOException, TTransportException;