@Test public void testFilterRegistration() throws Exception { Configuration conf = UTIL.getConfiguration(); conf.set("hbase.thrift.filters", "MyFilter:filterclass"); ThriftServer.registerFilters(conf); Map<String, String> registeredFilters = ParseFilter.getAllFilters(); assertEquals("filterclass", registeredFilters.get("MyFilter")); }
private static ThriftServer startThriftServer(int port, boolean useHttp) { Configuration thriftServerConf = HBaseConfiguration.create(TEST_UTIL.getConfiguration()); thriftServerConf.setInt(Constants.PORT_CONF_KEY, port); if (useHttp) { thriftServerConf.setBoolean(Constants.USE_HTTP_CONF_KEY, true); } ThriftServer server = new ThriftServer(thriftServerConf); Thread thriftServerThread = new Thread(() -> { try{ server.run(); } catch (Exception t) { LOG.error("Thrift Server failed", t); } }); thriftServerThread.setDaemon(true); thriftServerThread.start(); if (useHttp) { TEST_UTIL.waitFor(10000, () -> server.getHttpServer() != null); } else { TEST_UTIL.waitFor(10000, () -> server.getTserver() != null); } return server; }
@Override public int run(String[] args) throws Exception { final Configuration conf = getConf(); TServer server = null; Options options = getOptions(); CommandLine cmd = parseArguments(conf, options, args); int workerThreads = 0; int selectorThreads = 0; printUsage(); return 1; registerFilters(conf); TProtocolFactory protocolFactory = getTProtocolFactory(compact); final ThriftHBaseServiceHandler hbaseHandler = new ThriftHBaseServiceHandler(conf, userProvider); TTransportFactory transportFactory = getTTransportFactory(qop, name, host, framed, conf.getInt("hbase.regionserver.thrift.framed.max_frame_size_in_mb", 2) * 1024 * 1024); InetSocketAddress inetSocketAddress = bindToPort(bindAddress, listenPort); conf.setBoolean("hbase.regionserver.thrift.framed", framed); if (qop != null) { printUsage(); System.exit(1); server = getTNonBlockingServer(protocolFactory, processor, transportFactory,
Options options = getOptions(); try { CommandLine cmd = parseArguments(options, args); printUsage(); System.exit(1); TProtocolFactory protocolFactory = getTProtocolFactory(compact); THBaseService.Iface handler = ThriftHBaseServiceHandler.newInstance(conf, metrics); TTransportFactory transportFactory = getTTransportFactory(framed); conf.setBoolean("hbase.regionserver.thrift.framed", framed); log.error("The Nonblocking and HsHaServer servers don't support IP address binding at the moment." + " See https://issues.apache.org/jira/browse/HBASE-2155 for details."); printUsage(); System.exit(1); printUsage(); System.exit(1); InetSocketAddress inetSocketAddress = bindToPort(cmd.getOptionValue("bind"), listenPort); server = getTNonBlockingServer(protocolFactory, processor, transportFactory, inetSocketAddress); } else if (hsha) { server = getTHsHaServer(protocolFactory, processor, transportFactory, inetSocketAddress, metrics); } else { server = getTThreadPoolServer(protocolFactory, processor, transportFactory, inetSocketAddress);
/** * Start up the Thrift2 server. */ public static void main(String[] args) throws Exception { final Configuration conf = HBaseConfiguration.create(); // for now, only time we return is on an argument error. final int status = ToolRunner.run(conf, new ThriftServer(conf), args); System.exit(status); }
private static TServer getTHsHaServer(TProtocolFactory protocolFactory, THBaseService.Processor processor, TTransportFactory transportFactory, 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); ExecutorService executorService = createExecutor( serverArgs.getWorkerThreads(), metrics); serverArgs.executorService(executorService); serverArgs.processor(processor); serverArgs.transportFactory(transportFactory); serverArgs.protocolFactory(protocolFactory); return new THsHaServer(serverArgs); }
private static void printUsage() { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Thrift", null, getOptions(), "To start the Thrift server run 'bin/hbase-daemon.sh start thrift2'\n" + "To shutdown the thrift server run 'bin/hbase-daemon.sh stop thrift2' or" + " send a kill signal to the thrift server pid", true); }
@Override public int run(String[] args) throws Exception { final Configuration conf = getConf(); TServer server = null; Options options = getOptions(); CommandLine cmd = parseArguments(conf, options, args); int workerThreads = 0; int selectorThreads = 0; printUsage(); return 1; registerFilters(conf); TProtocolFactory protocolFactory = getTProtocolFactory(compact); final ThriftHBaseServiceHandler hbaseHandler = new ThriftHBaseServiceHandler(conf, userProvider); TTransportFactory transportFactory = getTTransportFactory(qop, name, host, framed, conf.getInt("hbase.regionserver.thrift.framed.max_frame_size_in_mb", 2) * 1024 * 1024); InetSocketAddress inetSocketAddress = bindToPort(bindAddress, listenPort); conf.setBoolean("hbase.regionserver.thrift.framed", framed); if (qop != null) { printUsage(); System.exit(1); server = getTNonBlockingServer(protocolFactory, processor, transportFactory,
@Override protected ThriftServer createThriftServer() { return new ThriftServer(TEST_UTIL.getConfiguration()); }
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); }
private static void printUsage() { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Thrift", null, getOptions(), "To start the Thrift server run 'hbase-daemon.sh start thrift2' or " + "'hbase thrift2'\n" + "To shutdown the thrift server run 'hbase-daemon.sh stop thrift2' or" + " send a kill signal to the thrift server pid", true); }
@Test public void testFilterRegistration() throws Exception { Configuration conf = UTIL.getConfiguration(); conf.set("hbase.thrift.filters", "MyFilter:filterclass"); ThriftServer.registerFilters(conf); Map<String, String> registeredFilters = ParseFilter.getAllFilters(); assertEquals("filterclass", registeredFilters.get("MyFilter")); }
@Override protected ThriftServer createThriftServer() { return new ThriftServer(TEST_UTIL.getConfiguration()); }
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); }
private static void printUsage() { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Thrift", null, getOptions(), "To start the Thrift server run 'hbase-daemon.sh start thrift2' or " + "'hbase thrift2'\n" + "To shutdown the thrift server run 'hbase-daemon.sh stop thrift2' or" + " send a kill signal to the thrift server pid", true); }
@Test public void testFilterRegistration() throws Exception { Configuration conf = UTIL.getConfiguration(); conf.set("hbase.thrift.filters", "MyFilter:filterclass"); ThriftServer.registerFilters(conf); Map<String, String> registeredFilters = ParseFilter.getAllFilters(); assertEquals("filterclass", registeredFilters.get("MyFilter")); }
/** * Start up the Thrift2 server. */ public static void main(String[] args) throws Exception { final Configuration conf = HBaseConfiguration.create(); // for now, only time we return is on an argument error. final int status = ToolRunner.run(conf, new ThriftServer(), args); System.exit(status); }
private static TServer getTThreadedSelectorServer(TProtocolFactory protocolFactory, TProcessor processor, TTransportFactory transportFactory, int workerThreads, int selectorThreads, int maxCallQueueSize, InetSocketAddress inetSocketAddress, ThriftMetrics metrics) throws TTransportException { TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress); log.info("starting HBase ThreadedSelector Thrift server on " + inetSocketAddress.toString()); TThreadedSelectorServer.Args serverArgs = new TThreadedSelectorServer.Args(serverTransport); if (workerThreads > 0) { serverArgs.workerThreads(workerThreads); } if (selectorThreads > 0) { serverArgs.selectorThreads(selectorThreads); } ExecutorService executorService = createExecutor( workerThreads, maxCallQueueSize, metrics); serverArgs.executorService(executorService); serverArgs.processor(processor); serverArgs.transportFactory(transportFactory); serverArgs.protocolFactory(protocolFactory); return new TThreadedSelectorServer(serverArgs); }
/** * Start up the Thrift2 server. */ public static void main(String[] args) throws Exception { final Configuration conf = HBaseConfiguration.create(); // for now, only time we return is on an argument error. final int status = ToolRunner.run(conf, new ThriftServer(), args); System.exit(status); }
private static TServer getTThreadedSelectorServer(TProtocolFactory protocolFactory, TProcessor processor, TTransportFactory transportFactory, int workerThreads, int selectorThreads, int maxCallQueueSize, InetSocketAddress inetSocketAddress, ThriftMetrics metrics) throws TTransportException { TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress); log.info("starting HBase ThreadedSelector Thrift server on " + inetSocketAddress.toString()); TThreadedSelectorServer.Args serverArgs = new TThreadedSelectorServer.Args(serverTransport); if (workerThreads > 0) { serverArgs.workerThreads(workerThreads); } if (selectorThreads > 0) { serverArgs.selectorThreads(selectorThreads); } ExecutorService executorService = createExecutor( workerThreads, maxCallQueueSize, metrics); serverArgs.executorService(executorService); serverArgs.processor(processor); serverArgs.transportFactory(transportFactory); serverArgs.protocolFactory(protocolFactory); return new TThreadedSelectorServer(serverArgs); }