@Parameters public static Collection<Object[]> getParameters() { Collection<Object[]> parameters = new ArrayList<Object[]>(); for (ImplType implType : ImplType.values()) { for (boolean specifyFramed : new boolean[] {false, true}) { for (boolean specifyBindIP : new boolean[] {false, true}) { if (specifyBindIP && !implType.canSpecifyBindIP) { continue; } for (boolean specifyCompact : new boolean[] {false, true}) { parameters.add(new Object[]{implType, specifyFramed, specifyBindIP, specifyCompact}); } } } } return parameters; }
@Parameters public static Collection<Object[]> getParameters() { Collection<Object[]> parameters = new ArrayList<Object[]>(); for (ImplType implType : ImplType.values()) { for (boolean specifyFramed : new boolean[] {false, true}) { for (boolean specifyBindIP : new boolean[] {false, true}) { if (specifyBindIP && !implType.canSpecifyBindIP) { continue; } for (boolean specifyCompact : new boolean[] {false, true}) { parameters.add(new Object[]{implType, new Boolean(specifyFramed), new Boolean(specifyBindIP), new Boolean(specifyCompact)}); } } } } return parameters; }
@Parameters public static Collection<Object[]> getParameters() { Collection<Object[]> parameters = new ArrayList<>(); for (ImplType implType : ImplType.values()) { for (boolean specifyFramed : new boolean[] {false, true}) { for (boolean specifyBindIP : new boolean[] {false, true}) { if (specifyBindIP && !implType.canSpecifyBindIP) { continue; } for (boolean specifyCompact : new boolean[] {false, true}) { parameters.add(new Object[] { implType, specifyFramed, specifyBindIP, specifyCompact }); } } } } return parameters; }
public TestThriftServerCmdLine(ImplType implType, boolean specifyFramed, boolean specifyBindIP, boolean specifyCompact) { this.implType = implType; this.specifyFramed = specifyFramed; this.specifyBindIP = specifyBindIP; this.specifyCompact = specifyCompact; LOG.debug(getParametersString()); }
public TestThriftServerCmdLine(ImplType implType, boolean specifyFramed, boolean specifyBindIP, boolean specifyCompact) { this.implType = implType; this.specifyFramed = specifyFramed; this.specifyBindIP = specifyBindIP; this.specifyCompact = specifyCompact; LOG.debug("implType=" + implType + ", " + "specifyFramed=" + specifyFramed + ", " + "specifyBindIP=" + specifyBindIP + ", " + "specifyCompact=" + specifyCompact); }
/** * Parse the command line options to set parameters the conf. */ private void processOptions(final String[] args) throws Exception { Options options = new Options(); options.addOption("b", BIND_OPTION, true, "Address to bind " + "the Thrift server to. [default: " + DEFAULT_BIND_ADDR + "]"); options.addOption("p", PORT_OPTION, true, "Port to bind to [default: " + DEFAULT_LISTEN_PORT + "]"); options.addOption("f", FRAMED_OPTION, false, "Use framed transport"); options.addOption("c", COMPACT_OPTION, false, "Use the compact protocol"); options.addOption("h", "help", false, "Print help information"); options.addOption("m", MIN_WORKERS_OPTION, true, "The minimum number of worker threads for " + ImplType.THREAD_POOL.simpleClassName()); options.addOption("w", MAX_WORKERS_OPTION, true, "The maximum number of worker threads for " + ImplType.THREAD_POOL.simpleClassName()); options.addOption("q", MAX_QUEUE_SIZE_OPTION, true, "The maximum number of queued requests in " + ImplType.THREAD_POOL.simpleClassName()); options.addOption("k", KEEP_ALIVE_SEC_OPTION, true, "The amount of time in secods to keep a thread alive when idle in " + ImplType.THREAD_POOL.simpleClassName()); options.addOptionGroup(ImplType.createOptionGroup()); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); // This is so complicated to please both bin/hbase and bin/hbase-daemon. // hbase-daemon provides "start" and "stop" arguments // hbase should print the help if no argument is provided List<String> commandLine = Arrays.asList(args); boolean stop = commandLine.contains("stop"); boolean start = commandLine.contains("start"); boolean invalidStartStop = (start && stop) || (!start && !stop); if (cmd.hasOption("help") || invalidStartStop) { if (invalidStartStop) { LOG.error("Exactly one of 'start' and 'stop' has to be specified"); } printUsageAndExit(options, 1); } // Get port to bind to try { int listenPort = Integer.parseInt(cmd.getOptionValue(PORT_OPTION, String.valueOf(DEFAULT_LISTEN_PORT))); conf.setInt(ThriftServerRunner.PORT_CONF_KEY, listenPort); } catch (NumberFormatException e) { LOG.error("Could not parse the value provided for the port option", e); printUsageAndExit(options, -1); } // Make optional changes to the configuration based on command-line options optionToConf(cmd, MIN_WORKERS_OPTION, conf, TBoundedThreadPoolServer.MIN_WORKER_THREADS_CONF_KEY); optionToConf(cmd, MAX_WORKERS_OPTION, conf, TBoundedThreadPoolServer.MAX_WORKER_THREADS_CONF_KEY); optionToConf(cmd, MAX_QUEUE_SIZE_OPTION, conf, TBoundedThreadPoolServer.MAX_QUEUED_REQUESTS_CONF_KEY); optionToConf(cmd, KEEP_ALIVE_SEC_OPTION, conf, TBoundedThreadPoolServer.THREAD_KEEP_ALIVE_TIME_SEC_CONF_KEY); // Set general thrift server options conf.setBoolean( ThriftServerRunner.COMPACT_CONF_KEY, cmd.hasOption(COMPACT_OPTION)); conf.setBoolean( ThriftServerRunner.FRAMED_CONF_KEY, cmd.hasOption(FRAMED_OPTION)); if (cmd.hasOption(BIND_OPTION)) { conf.set( ThriftServerRunner.BIND_CONF_KEY, cmd.getOptionValue(BIND_OPTION)); } ImplType.setServerImpl(cmd, conf); }