Search in sources :

Example 11 with ArgumentAcceptingOptionSpec

use of joptsimple.ArgumentAcceptingOptionSpec in project ambry by linkedin.

the class ToolUtils method validateSSLOptions.

public static void validateSSLOptions(OptionSet options, OptionParser parser, ArgumentAcceptingOptionSpec<String> sslEnabledDatacentersOpt, ArgumentAcceptingOptionSpec<String> sslKeystorePathOpt, ArgumentAcceptingOptionSpec<String> sslKeystoreTypeOpt, ArgumentAcceptingOptionSpec<String> sslTruststorePathOpt, ArgumentAcceptingOptionSpec<String> sslKeystorePasswordOpt, ArgumentAcceptingOptionSpec<String> sslKeyPasswordOpt, ArgumentAcceptingOptionSpec<String> sslTruststorePasswordOpt) throws Exception {
    String sslEnabledDatacenters = options.valueOf(sslEnabledDatacentersOpt);
    if (sslEnabledDatacenters.length() != 0) {
        ArrayList<OptionSpec<?>> listOpt = new ArrayList<OptionSpec<?>>();
        listOpt.add(sslKeystorePathOpt);
        listOpt.add(sslKeystoreTypeOpt);
        listOpt.add(sslKeystorePasswordOpt);
        listOpt.add(sslKeyPasswordOpt);
        listOpt.add(sslTruststorePathOpt);
        listOpt.add(sslTruststorePasswordOpt);
        for (OptionSpec opt : listOpt) {
            if (!options.has(opt)) {
                System.err.println("If sslEnabledDatacenters is not empty, missing required argument \"" + opt + "\"");
                parser.printHelpOn(System.err);
                throw new Exception("Lack of SSL arguments " + opt);
            }
        }
    }
}
Also used : OptionSpec(joptsimple.OptionSpec) ArgumentAcceptingOptionSpec(joptsimple.ArgumentAcceptingOptionSpec) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Aggregations

ArgumentAcceptingOptionSpec (joptsimple.ArgumentAcceptingOptionSpec)11 OptionParser (joptsimple.OptionParser)10 OptionSet (joptsimple.OptionSet)10 OptionSpec (joptsimple.OptionSpec)10 ArrayList (java.util.ArrayList)9 VerifiableProperties (com.github.ambry.config.VerifiableProperties)8 Properties (java.util.Properties)8 ClusterMapConfig (com.github.ambry.config.ClusterMapConfig)7 ClusterAgentsFactory (com.github.ambry.clustermap.ClusterAgentsFactory)6 ClusterMap (com.github.ambry.clustermap.ClusterMap)6 MetricRegistry (com.codahale.metrics.MetricRegistry)5 IOException (java.io.IOException)5 BlobProperties (com.github.ambry.messageformat.BlobProperties)4 Throttler (com.github.ambry.utils.Throttler)4 File (java.io.File)4 FileWriter (java.io.FileWriter)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)4 ReplicaId (com.github.ambry.clustermap.ReplicaId)2 BlobIdFactory (com.github.ambry.commons.BlobIdFactory)2