org.apache.commons.cli.CommandLine Java Examples

The following examples show how to use org.apache.commons.cli.CommandLine. 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: CopyNumberAnalyser.java    From hmftools with GNU General Public License v3.0 6 votes vote down vote up
public static void main(@NotNull final String[] args) throws ParseException, SQLException
{
    final Options options = new Options();
    CopyNumberAnalyser.addCmdLineArgs(options);

    final CommandLineParser parser = new DefaultParser();
    final CommandLine cmd = parser.parse(options, args);

    if (cmd.hasOption(LOG_DEBUG))
    {
        Configurator.setRootLevel(Level.DEBUG);
    }

    String outputDir = formOutputPath(cmd.getOptionValue(DATA_OUTPUT_DIR));

    final DatabaseAccess dbAccess = cmd.hasOption(DB_URL) ? databaseAccess(cmd) : null;

    CopyNumberAnalyser cnAnalyser = new CopyNumberAnalyser(outputDir, dbAccess);
    cnAnalyser.loadConfig(cmd);

    cnAnalyser.runAnalysis();
    cnAnalyser.close();

    LNX_LOGGER.info("CN analysis complete");
}
 
Example #2
Source File: Main.java    From james-project with Apache License 2.0 6 votes vote down vote up
private static void runCommand(CommandLine cmd) throws Exception {
    boolean verbose = Boolean.parseBoolean(cmd.getOptionValue(VERBOSE_OPTION, Boolean.toString(false)));
    File file = new File(cmd.getOptionValue(FILE_OPTION));
    if (file.exists()) {
        try {
            Port port = new Port(Integer.parseInt(cmd.getOptionValue(PORT_OPTION)));    
            String host = cmd.getOptionValue(HOST_OPTION, "localhost");
            String shabang = cmd.getOptionValue(SHABANG_OPTION, null);
            RunScript runner = new RunScript(file, port, host, shabang, verbose);
            runner.run();
            
        } catch (NumberFormatException e) {
            System.out.println("Port must be numeric");
            System.exit(PORT_NOT_A_NUMBER);
        }
    } else {
        System.out.println("Script not found");
        System.exit(FILE_NOT_FOUND);
    }
}
 
Example #3
Source File: FlinkYarnSessionCliTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testCorrectSettingOfMaxSlots() throws Exception {
	String[] params =
		new String[] {"-ys", "3"};

	FlinkYarnSessionCli yarnCLI = createFlinkYarnSessionCliWithJmAndTmTotalMemory(2048);

	final CommandLine commandLine = yarnCLI.parseCommandLineOptions(params, true);

	final Configuration executorConfig = yarnCLI.applyCommandLineOptionsToConfiguration(commandLine);
	final ClusterClientFactory<ApplicationId> clientFactory = getClusterClientFactory(executorConfig);
	final ClusterSpecification clusterSpecification = clientFactory.getClusterSpecification(executorConfig);

	// each task manager has 3 slots but the parallelism is 7. Thus the slots should be increased.
	assertEquals(3, clusterSpecification.getSlotsPerTaskManager());
}
 
Example #4
Source File: UpdateKvConfigCommand.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // namespace
        String namespace = commandLine.getOptionValue('s').trim();
        // key name
        String key = commandLine.getOptionValue('k').trim();
        // key name
        String value = commandLine.getOptionValue('v').trim();

        defaultMQAdminExt.start();
        defaultMQAdminExt.createAndUpdateKvConfig(namespace, key, value);
        System.out.printf("create or update kv config to namespace success.%n");
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example #5
Source File: CliFrontendJobManagerConnectionTest.java    From stratosphere with Apache License 2.0 6 votes vote down vote up
@Test
public void testInvalidConfig() {
	try {
		String[] arguments = {};
		CommandLine line = new PosixParser().parse(CliFrontend.getJobManagerAddressOption(new Options()), arguments, false);
			
		TestingCliFrontend frontend = new TestingCliFrontend(CliFrontendTestUtils.getInvalidConfigDir());
		
		assertTrue(frontend.getJobManagerAddress(line) == null);
	}
	catch (Exception e) {
		System.err.println(e.getMessage());
		e.printStackTrace();
		fail("Program caused an exception: " + e.getMessage());
	}
}
 
Example #6
Source File: ConversionTool.java    From powsybl-core with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void run(CommandLine line, ToolRunningContext context) throws Exception {
    String inputFile = line.getOptionValue(INPUT_FILE);
    String outputFormat = line.getOptionValue(OUTPUT_FORMAT);
    String outputFile = line.getOptionValue(OUTPUT_FILE);

    Exporter exporter = Exporters.getExporter(outputFormat);
    if (exporter == null) {
        throw new PowsyblException("Target format " + outputFormat + " not supported");
    }

    Properties inputParams = readProperties(line, ConversionToolUtils.OptionType.IMPORT, context);
    Network network = Importers.loadNetwork(context.getFileSystem().getPath(inputFile), context.getShortTimeExecutionComputationManager(), createImportConfig(), inputParams);

    Properties outputParams = readProperties(line, ConversionToolUtils.OptionType.EXPORT, context);
    DataSource ds2 = Exporters.createDataSource(context.getFileSystem().getPath(outputFile), new DefaultDataSourceObserver() {
        @Override
        public void opened(String streamName) {
            context.getOutputStream().println("Generating file " + streamName + "...");
        }
    });
    exporter.export(network, outputParams, ds2);
}
 
Example #7
Source File: AbstractCustomCommandLine.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Configuration applyCommandLineOptionsToConfiguration(CommandLine commandLine) throws FlinkException {
	final Configuration resultingConfiguration = new Configuration(configuration);
	resultingConfiguration.setString(DeploymentOptions.TARGET, RemoteExecutor.NAME);

	if (commandLine.hasOption(addressOption.getOpt())) {
		String addressWithPort = commandLine.getOptionValue(addressOption.getOpt());
		InetSocketAddress jobManagerAddress = NetUtils.parseHostPortAddress(addressWithPort);
		setJobManagerAddressInConfig(resultingConfiguration, jobManagerAddress);
	}

	if (commandLine.hasOption(zookeeperNamespaceOption.getOpt())) {
		String zkNamespace = commandLine.getOptionValue(zookeeperNamespaceOption.getOpt());
		resultingConfiguration.setString(HighAvailabilityOptions.HA_CLUSTER_ID, zkNamespace);
	}

	return resultingConfiguration;
}
 
Example #8
Source File: ListOfflineWorkflowsTool.java    From ipst with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void run(CommandLine line, ToolRunningContext context) throws Exception {
    try (OfflineApplication app = new RemoteOfflineApplicationImpl()) {
        Map<String, OfflineWorkflowStatus> statuses = app.listWorkflows();
        Table table = new Table(4, BorderStyle.CLASSIC_WIDE);
        table.addCell("ID");
        table.addCell("Running");
        table.addCell("Step");
        table.addCell("Time");
        for (Map.Entry<String, OfflineWorkflowStatus> entry : statuses.entrySet()) {
            String workflowId = entry.getKey();
            OfflineWorkflowStatus status = entry.getValue();
            Duration remaining = null;
            if (status.getStartTime() != null) {
                remaining = Duration.millis(status.getStartParameters().getDuration() * 60 * 1000)
                        .minus(new Duration(status.getStartTime(), DateTime.now()));
            }
            table.addCell(workflowId);
            table.addCell(Boolean.toString(status.isRunning()));
            table.addCell(status.getStep() != null ? status.getStep().toString() : "");
            table.addCell(remaining != null ? PeriodFormat.getDefault().print(remaining.toPeriod()) : "");
        }
        context.getOutputStream().println(table.render());
    }
}
 
Example #9
Source File: QueryMsgByKeySubCommand.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);

    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));

    try {
        final String topic = commandLine.getOptionValue('t').trim();
        final String key = commandLine.getOptionValue('k').trim();

        this.queryByKey(defaultMQAdminExt, topic, key);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example #10
Source File: TopicClusterSubCommand.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    String topic = commandLine.getOptionValue('t').trim();
    try {
        defaultMQAdminExt.start();
        Set<String> clusters = defaultMQAdminExt.getTopicClusterList(topic);
        for (String value : clusters) {
            System.out.printf("%s%n", value);
        }
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example #11
Source File: TermsDataCommand.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("static-access")
private static CommandLine parse(String[] otherArgs, Writer out) {
  Options options = new Options();
  options.addOption(OptionBuilder.withArgName("startwith").hasArg().withDescription("The value to start with.")
      .create("s"));
  options.addOption(OptionBuilder.withArgName("size").hasArg().withDescription("The number of terms to return.")
      .create("n"));
  options.addOption(OptionBuilder.withDescription("Get the frequency of each term.").create("F"));

  CommandLineParser parser = new PosixParser();
  CommandLine cmd = null;
  try {
    cmd = parser.parse(options, otherArgs);
  } catch (ParseException e) {
    HelpFormatter formatter = new HelpFormatter();
    PrintWriter pw = new PrintWriter(out, true);
    formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, "terms", null, options, HelpFormatter.DEFAULT_LEFT_PAD,
        HelpFormatter.DEFAULT_DESC_PAD, null, false);
    return null;
  }
  return cmd;
}
 
Example #12
Source File: FlinkYarnSessionCli.java    From flink with Apache License 2.0 6 votes vote down vote up
private String encodeDynamicProperties(final CommandLine cmd) {
	final Properties properties = cmd.getOptionProperties(dynamicproperties.getOpt());
	final String[] dynamicProperties = properties.stringPropertyNames().stream()
			.flatMap(
					(String key) -> {
						final String value = properties.getProperty(key);

						LOG.info("Dynamic Property set: {}={}", key, GlobalConfiguration.isSensitive(key) ? GlobalConfiguration.HIDDEN_CONTENT : value);

						if (value != null) {
							return Stream.of(key + dynamicproperties.getValueSeparator() + value);
						} else {
							return Stream.empty();
						}
					})
			.toArray(String[]::new);

	return StringUtils.join(dynamicProperties, YARN_DYNAMIC_PROPERTIES_SEPARATOR);
}
 
Example #13
Source File: DatafeedsWorkflow.java    From googleads-shopping-samples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
  CommandLine parsedArgs = BaseOption.parseOptions(args);
  File configPath = null;
  if (!NO_CONFIG.isSet(parsedArgs)) {
    configPath = BaseOption.checkedConfigPath(parsedArgs);
  }
  ContentConfig config = ContentConfig.load(configPath);

  ShoppingContent.Builder builder = createStandardBuilder(parsedArgs, config);
  ShoppingContent content = createService(builder);
  ShoppingContent sandbox = createSandboxContentService(builder);
  retrieveConfiguration(content, config);

  try {
    new DatafeedsWorkflow(content, sandbox, config).execute();
  } catch (GoogleJsonResponseException e) {
    checkGoogleJsonResponseException(e);
  }
}
 
Example #14
Source File: UpdateKvConfigCommand.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
        // namespace
        String namespace = commandLine.getOptionValue('s').trim();
        // key name
        String key = commandLine.getOptionValue('k').trim();
        // key name
        String value = commandLine.getOptionValue('v').trim();

        defaultMQAdminExt.start();
        defaultMQAdminExt.createAndUpdateKvConfig(namespace, key, value);
        System.out.printf("create or update kv config to namespace success.%n");
        return;
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example #15
Source File: ExecutionContext.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static <T> CustomCommandLine<T> findActiveCommandLine(List<CustomCommandLine<?>> availableCommandLines, CommandLine commandLine) {
	for (CustomCommandLine<?> cli : availableCommandLines) {
		if (cli.isActive(commandLine)) {
			return (CustomCommandLine<T>) cli;
		}
	}
	throw new SqlExecutionException("Could not find a matching deployment.");
}
 
Example #16
Source File: StartMonitoringSubCommand.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
    try {
        MonitorService monitorService =
            new MonitorService(new MonitorConfig(), new DefaultMonitorListener(), rpcHook);

        monitorService.start();
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    }
}
 
Example #17
Source File: ServerCmdTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
public void removeSieveUserQuotaCommandShouldWork() throws Exception {
    String user = "[email protected]";
    String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVESIEVEUSERQUOTA.getCommand(), user};
    CommandLine commandLine = ServerCmd.parseCommandLine(arguments);

    testee.executeCommandLine(commandLine);

    verify(sieveProbe).removeSieveQuota(user);
}
 
Example #18
Source File: MainTest.java    From openapi-style-validator with Apache License 2.0 5 votes vote down vote up
@Test
void validateWithUnderscoreLegacyNamingOptionTestShouldReturnNoError() throws Exception {
    OptionManager optionManager = new OptionManager();
    Options options = optionManager.getOptions();
    CommandLine commandLine = parser.parse(options, new String[]{"-s", "src/test/resources/some.yaml", "-o", "src/test/resources/underscoreLegacy.json"});
    List<StyleError> errorList = Main.validate(optionManager, commandLine);
    assertEquals(0, errorList.size());
}
 
Example #19
Source File: CompilerOptions_Tests.java    From iBioSim with Apache License 2.0 5 votes vote down vote up
@Test(expected = FileNotFoundException.class)
public void Test_FileNotFoundException() throws ParseException, FileNotFoundException {
	String[] args = {"-v", "a.v"};

	CommandLine cmd = VerilogRunner.parseCommandLine(args);
	VerilogRunner.createCompilerOptions(cmd);
	
}
 
Example #20
Source File: SvSimulator.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
public static void main(@NotNull final String[] args) throws ParseException
{
    final Options options = createBasicOptions();
    final CommandLine cmd = createCommandLine(args, options);

    if (cmd.hasOption(LOG_DEBUG))
    {
        Configurator.setRootLevel(Level.DEBUG);
    }

    String outputDir = formOutputPath(cmd.getOptionValue(DATA_OUTPUT_DIR));

    SvSimulator simulator = new SvSimulator(cmd, outputDir);
    simulator.run();
}
 
Example #21
Source File: CloneGroupOffsetCommand.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) throws SubCommandException {
    String srcGroup = commandLine.getOptionValue("s").trim();
    String destGroup = commandLine.getOptionValue("d").trim();
    String topic = commandLine.getOptionValue("t").trim();

    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
    defaultMQAdminExt.setInstanceName("admin-" + Long.toString(System.currentTimeMillis()));

    try {
        defaultMQAdminExt.start();
        ConsumeStats consumeStats = defaultMQAdminExt.examineConsumeStats(srcGroup);
        Set<MessageQueue> mqs = consumeStats.getOffsetTable().keySet();
        if (!mqs.isEmpty()) {
            TopicRouteData topicRoute = defaultMQAdminExt.examineTopicRouteInfo(topic);
            for (MessageQueue mq : mqs) {
                String addr = null;
                for (BrokerData brokerData : topicRoute.getBrokerDatas()) {
                    if (brokerData.getBrokerName().equals(mq.getBrokerName())) {
                        addr = brokerData.selectBrokerAddr();
                        break;
                    }
                }
                long offset = consumeStats.getOffsetTable().get(mq).getBrokerOffset();
                if (offset >= 0) {
                    defaultMQAdminExt.updateConsumeOffset(addr, destGroup, mq, offset);
                }
            }
        }
        System.out.printf("clone group offset success. srcGroup[%s], destGroup=[%s], topic[%s]",
            srcGroup, destGroup, topic);
    } catch (Exception e) {
        throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example #22
Source File: ServerCmdTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
public void removeSieveUserQuotaCommandShouldThrowOnAdditionalArguments() throws Exception {
    String user = "user@domain";
    String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.REMOVESIEVEUSERQUOTA.getCommand(), user, ADDITIONAL_ARGUMENT };
    CommandLine commandLine = ServerCmd.parseCommandLine(arguments);

    assertThatThrownBy(() -> testee.executeCommandLine(commandLine))
        .isInstanceOf(InvalidArgumentNumberException.class);
}
 
Example #23
Source File: MiscTools.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected Connection getConnection(final CommandLine cmdLine,
    final String cmd, final String cmdDescKey)
    throws ParseException, SQLException {
  final ConnectionOptions connOpts = new ConnectionOptions();
  final Iterator<?> iter = cmdLine.iterator();
  GfxdOption opt;
  while (iter.hasNext()) {
    opt = (GfxdOption)iter.next();
    if (SCRIPT_URL.equals(opt.getOpt())) {
      this.scriptURL = opt.getValue();
    }
    else if (SCRIPT_PATH.equals(opt.getOpt())) {
      String path = opt.getValue();
      if( !new File(path).isDirectory() ) {
        Assert.fail(path + " not a directory"); 
      }
      this.scriptPath = path;
    }
    else if (ENCODING.equals(opt.getOpt())) {
      this.encoding = opt.getValue();
    }
    else if (IGNORE_ERRORS.equals(opt.getOpt())) {
      this.ignoreErrors = true;
    }
    else if (!handleCommonOption(opt, cmd, cmdDescKey)) {
      if (!handleConnectionOption(opt, connOpts)) {
        Assert.fail(opt.toString());
      }
    }
  }

  return getConnection(connOpts, cmd, cmdDescKey);
}
 
Example #24
Source File: PrintOfflineWorkflowParametersTool.java    From ipst with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void run(CommandLine line, ToolRunningContext context) throws Exception {
    String workflowId = line.getOptionValue("workflow");
    try (OfflineApplication app = new RemoteOfflineApplicationImpl()) {
        OfflineWorkflowCreationParameters parameters = app.getWorkflowParameters(workflowId);
        if (parameters != null) {
            parameters.print(context.getOutputStream());
        }
    }
}
 
Example #25
Source File: JobTemplateCommand.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CommandContext context) throws Exception {
    CommandLine cli = context.getCLI();

    JobSpecCase jobCase = JobSpecCase.BATCH;
    if (cli.hasOption('t')) {
        String jobType = cli.getOptionValue('t');
        try {
            jobCase = JobSpecCase.valueOf(jobType);
        } catch (IllegalArgumentException e) {
            logger.error("Unknown job type {}. Expected one of {}", jobType, asList(JobSpecCase.BATCH, JobSpecCase.SERVICE));
            return;
        }
    }
    File templateFile = new File(cli.getOptionValue('f'));

    JobDescriptor jobDescriptor;
    switch (jobCase) {
        case SERVICE:
            jobDescriptor = createServiceJobDescriptor();
            break;
        default:
            jobDescriptor = createBatchJobDescriptor();
    }
    String formatted = JsonFormat.printer().print(jobDescriptor);

    try (FileWriter fw = new FileWriter(templateFile)) {
        fw.write(formatted);
    }

    logger.info("Generated template file in {}", templateFile.getAbsoluteFile());
}
 
Example #26
Source File: CommonOptions.java    From metron with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<Object> getValue(OPT_T option, CommandLine cli) {
  try {
    return Optional.ofNullable(FileUtils.readFileToString(new File(option.get(cli).trim())));
  } catch (IOException e) {
    throw new IllegalStateException("Unable to retrieve extractor config from " + option.get(cli) + ": " + e.getMessage(), e);
  }
}
 
Example #27
Source File: HalyardUpdate.java    From Halyard with Apache License 2.0 5 votes vote down vote up
public int run(CommandLine cmd) throws Exception {
    SailRepository rep = new SailRepository(new TimeAwareHBaseSail(getConf(), cmd.getOptionValue('s'), false, 0, true, 0, cmd.getOptionValue('i'), null));
    rep.initialize();
    try {
        Update u = rep.getConnection().prepareUpdate(QueryLanguage.SPARQL, cmd.getOptionValue('q'));
        ((MapBindingSet)u.getBindings()).addBinding(new TimeAwareHBaseSail.TimestampCallbackBinding());
        LOG.info("Update execution started");
        u.execute();
        LOG.info("Update finished");
    } finally {
        rep.shutDown();
    }
    return 0;
}
 
Example #28
Source File: SolrCLI.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
protected void runImpl(CommandLine cli) throws Exception {
  raiseLogLevelUnlessVerbose(cli);
  String zkHost = getZkHost(cli);
  if (zkHost == null) {
    throw new IllegalStateException("Solr at " + cli.getOptionValue("solrUrl") +
        " is running in standalone server mode, downconfig can only be used when running in SolrCloud mode.\n");
  }


  try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) {
    echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...", cli);
    String confName = cli.getOptionValue("confname");
    String confDir = cli.getOptionValue("confdir");
    Path configSetPath = Paths.get(confDir);
    // we try to be nice about having the "conf" in the directory, and we create it if it's not there.
    if (configSetPath.endsWith("/conf") == false) {
      configSetPath = Paths.get(configSetPath.toString(), "conf");
    }
    if (Files.exists(configSetPath) == false) {
      Files.createDirectories(configSetPath);
    }
    echo("Downloading configset " + confName + " from ZooKeeper at " + zkHost +
        " to directory " + configSetPath.toAbsolutePath());

    zkClient.downConfig(confName, configSetPath);
  } catch (Exception e) {
    log.error("Could not complete downconfig operation for reason: {}", e.getMessage());
    throw (e);
  }

}
 
Example #29
Source File: BrokerConsumeStatsSubCommadTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Ignore
@Test
public void testExecute() throws SubCommandException {
    BrokerConsumeStatsSubCommad cmd = new BrokerConsumeStatsSubCommad();
    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[] {"-b 127.0.0.1:10911", "-t 3000", "-l 5", "-o true"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
    cmd.execute(commandLine, options, null);
}
 
Example #30
Source File: ServerCmdTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
public void deleteMailboxMappingCommandShouldWork() throws Exception {
    String user = "user@domain";
    String namespace = "#private";
    String name = "INBOX.test";
    String[] arguments = { "-h", "127.0.0.1", "-p", "9999", CmdType.DELETEMAILBOX.getCommand(), namespace, user, name};
    CommandLine commandLine = ServerCmd.parseCommandLine(arguments);

    testee.executeCommandLine(commandLine);

    verify(mailboxProbe).deleteMailbox(namespace, user, name);
}