Search in sources :

Example 11 with ParameterException

use of com.beust.jcommander.ParameterException in project drill by apache.

the class QuerySubmitter method main.

public static void main(String[] args) throws Exception {
    QuerySubmitter submitter = new QuerySubmitter();
    Options o = new Options();
    JCommander jc = null;
    try {
        jc = new JCommander(o, args);
        jc.setProgramName("./submit_plan");
    } catch (ParameterException e) {
        System.out.println(e.getMessage());
        String[] valid = { "-f", "file", "-t", "physical" };
        new JCommander(o, valid).usage();
        System.exit(-1);
    }
    if (o.help) {
        jc.usage();
        System.exit(0);
    }
    System.exit(submitter.submitQuery(o.location, o.queryString, o.planType, o.zk, o.local, o.bits, o.format, o.width));
}
Also used : JCommander(com.beust.jcommander.JCommander) ParameterException(com.beust.jcommander.ParameterException)

Example 12 with ParameterException

use of com.beust.jcommander.ParameterException in project druid by druid-io.

the class TestNG method privateMain.

/**
   * <B>Note</B>: this method is not part of the public API and is meant for internal usage only.
   */
public static TestNG privateMain(String[] argv, ITestListener listener) {
    TestNG result = new TestNG();
    if (null != listener) {
        result.addListener(listener);
    }
    //
    try {
        CommandLineArgs cla = new CommandLineArgs();
        m_jCommander = new JCommander(cla, argv);
        validateCommandLineParameters(cla);
        result.configure(cla);
    } catch (ParameterException ex) {
        exitWithError(ex.getMessage());
    }
    //
    try {
        result.run();
    } catch (TestNGException ex) {
        if (TestRunner.getVerbose() > 1) {
            ex.printStackTrace(System.out);
        } else {
            error(ex.getMessage());
        }
        result.setStatus(HAS_FAILURE);
    }
    return result;
}
Also used : JCommander(com.beust.jcommander.JCommander) ParameterException(com.beust.jcommander.ParameterException)

Example 13 with ParameterException

use of com.beust.jcommander.ParameterException in project walle by Meituan-Dianping.

the class Main method main.

public static void main(final String[] args) throws Exception {
    final Map<String, IWalleCommand> subCommandList = new HashMap<String, IWalleCommand>();
    subCommandList.put("show", new ShowCommand());
    subCommandList.put("rm", new RemoveCommand());
    subCommandList.put("put", new WriteChannelCommand());
    subCommandList.put("batch", new WriteChannelsCommand());
    final WalleCommandLine walleCommandLine = new WalleCommandLine();
    final JCommander commander = new JCommander(walleCommandLine);
    for (Map.Entry<String, IWalleCommand> commandEntry : subCommandList.entrySet()) {
        commander.addCommand(commandEntry.getKey(), commandEntry.getValue());
    }
    try {
        commander.parse(args);
    } catch (ParameterException e) {
        System.out.println(e.getMessage());
        commander.usage();
        System.exit(1);
        return;
    }
    walleCommandLine.parse(commander);
    final String parseCommand = commander.getParsedCommand();
    if (parseCommand != null) {
        subCommandList.get(parseCommand).parse();
    }
}
Also used : RemoveCommand(com.meituan.android.walle.commands.RemoveCommand) WriteChannelsCommand(com.meituan.android.walle.commands.WriteChannelsCommand) HashMap(java.util.HashMap) IWalleCommand(com.meituan.android.walle.commands.IWalleCommand) JCommander(com.beust.jcommander.JCommander) ParameterException(com.beust.jcommander.ParameterException) ShowCommand(com.meituan.android.walle.commands.ShowCommand) WriteChannelCommand(com.meituan.android.walle.commands.WriteChannelCommand) Map(java.util.Map) HashMap(java.util.HashMap)

Example 14 with ParameterException

use of com.beust.jcommander.ParameterException in project pulsar by yahoo.

the class CliCommand method validatePersistentTopic.

String validatePersistentTopic(List<String> params) {
    String destination = checkArgument(params);
    DestinationName ds = DestinationName.get(destination);
    if (ds.getDomain() != DestinationDomain.persistent) {
        throw new ParameterException("Need to provide a persistent topic name");
    }
    return ds.toString();
}
Also used : DestinationName(com.yahoo.pulsar.common.naming.DestinationName) ParameterException(com.beust.jcommander.ParameterException)

Example 15 with ParameterException

use of com.beust.jcommander.ParameterException in project pulsar by yahoo.

the class CmdNamespaceIsolationPolicy method createNamespaceIsolationData.

private NamespaceIsolationData createNamespaceIsolationData(List<String> namespaces, List<String> primary, List<String> secondary, String autoFailoverPolicyTypeName, Map<String, String> autoFailoverPolicyParams) {
    // validate
    namespaces = validateList(namespaces);
    if (namespaces.isEmpty()) {
        throw new ParameterException("unable to parse namespaces parameter list: " + namespaces);
    }
    primary = validateList(primary);
    if (primary.isEmpty()) {
        throw new ParameterException("unable to parse primary parameter list: " + namespaces);
    }
    secondary = validateList(secondary);
    // System.out.println("namespaces = " + namespaces);
    // System.out.println("primary = " + primary);
    // System.out.println("secondary = " + secondary);
    // System.out.println("autoFailoverPolicyTypeName = " + autoFailoverPolicyTypeName);
    // System.out.println("autoFailoverPolicyParams = " + autoFailoverPolicyParams);
    NamespaceIsolationData nsIsolationData = new NamespaceIsolationData();
    if (namespaces != null) {
        nsIsolationData.namespaces = namespaces;
    }
    if (primary != null) {
        nsIsolationData.primary = primary;
    }
    if (secondary != null) {
        nsIsolationData.secondary = secondary;
    }
    nsIsolationData.auto_failover_policy = new AutoFailoverPolicyData();
    nsIsolationData.auto_failover_policy.policy_type = AutoFailoverPolicyType.fromString(autoFailoverPolicyTypeName);
    nsIsolationData.auto_failover_policy.parameters = autoFailoverPolicyParams;
    // validation if necessary
    if (nsIsolationData.auto_failover_policy.policy_type == AutoFailoverPolicyType.min_available) {
        // ignore
        boolean error = true;
        String[] expectParamKeys = { "min_limit", "usage_threshold" };
        if (autoFailoverPolicyParams.size() == expectParamKeys.length) {
            for (String paramKey : expectParamKeys) {
                if (!autoFailoverPolicyParams.containsKey(paramKey)) {
                    break;
                }
            }
            error = false;
        }
        if (error) {
            throw new ParameterException("Unknown auto failover policy params specified : " + autoFailoverPolicyParams);
        }
    } else {
        // either we don't handle the new type or user has specified a bad type
        throw new ParameterException("Unknown auto failover policy type specified : " + autoFailoverPolicyTypeName);
    }
    return nsIsolationData;
}
Also used : AutoFailoverPolicyData(com.yahoo.pulsar.common.policies.data.AutoFailoverPolicyData) NamespaceIsolationData(com.yahoo.pulsar.common.policies.data.NamespaceIsolationData) ParameterException(com.beust.jcommander.ParameterException)

Aggregations

ParameterException (com.beust.jcommander.ParameterException)19 JCommander (com.beust.jcommander.JCommander)15 RateLimiter (com.google.common.util.concurrent.RateLimiter)4 PulsarClient (com.yahoo.pulsar.client.api.PulsarClient)4 FileInputStream (java.io.FileInputStream)4 Message (com.yahoo.pulsar.client.api.Message)3 File (java.io.File)3 IOException (java.io.IOException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)2 ClientConfiguration (com.yahoo.pulsar.client.api.ClientConfiguration)2 Consumer (com.yahoo.pulsar.client.api.Consumer)2 ConsumerConfiguration (com.yahoo.pulsar.client.api.ConsumerConfiguration)2 Producer (com.yahoo.pulsar.client.api.Producer)2 PulsarClientException (com.yahoo.pulsar.client.api.PulsarClientException)2 PulsarClientImpl (com.yahoo.pulsar.client.impl.PulsarClientImpl)2 DestinationName (com.yahoo.pulsar.common.naming.DestinationName)2 EventLoopGroup (io.netty.channel.EventLoopGroup)2 EpollEventLoopGroup (io.netty.channel.epoll.EpollEventLoopGroup)2 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)2