Search in sources :

Example 1 with Type

use of com.ibm.streamsx.topology.context.StreamsContext.Type in project streamsx.health by IBMStreams.

the class PrintService method main.

public static void main(String[] args) throws Exception {
    Option subscribeTopicOption = Option.builder("s").longOpt("subscribe-topic").hasArg().argName("subscribe topic").required().build();
    Option contextTypeOption = Option.builder("c").longOpt("context-type").hasArg().argName("context type").required(false).build();
    Options options = new Options();
    options.addOption(subscribeTopicOption);
    options.addOption(contextTypeOption);
    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("help", options);
        throw (e);
    }
    Type contextType = Type.valueOf(cmd.getOptionValue("c", Type.DISTRIBUTED.name()));
    String subscribeTopic = cmd.getOptionValue("s");
    PrintService svc = new PrintService(subscribeTopic);
    svc.run(contextType, new HashMap<String, Object>());
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) Type(com.ibm.streamsx.topology.context.StreamsContext.Type) Option(org.apache.commons.cli.Option) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) DefaultParser(org.apache.commons.cli.DefaultParser)

Aggregations

Type (com.ibm.streamsx.topology.context.StreamsContext.Type)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 DefaultParser (org.apache.commons.cli.DefaultParser)1 HelpFormatter (org.apache.commons.cli.HelpFormatter)1 Option (org.apache.commons.cli.Option)1 Options (org.apache.commons.cli.Options)1 ParseException (org.apache.commons.cli.ParseException)1