Search in sources :

Example 31 with OptionSet

use of joptsimple.OptionSet in project jackrabbit-oak by apache.

the class Utils method bootstrapDataStore.

@Nullable
public static GarbageCollectableBlobStore bootstrapDataStore(String[] args, Closer closer) throws IOException, RepositoryException {
    OptionParser parser = new OptionParser();
    parser.allowsUnrecognizedOptions();
    ArgumentAcceptingOptionSpec<String> s3dsConfig = parser.accepts("s3ds", "S3DataStore config").withRequiredArg().ofType(String.class);
    ArgumentAcceptingOptionSpec<String> fdsConfig = parser.accepts("fds", "FileDataStore config").withRequiredArg().ofType(String.class);
    ArgumentAcceptingOptionSpec<String> azureBlobDSConfig = parser.accepts("azureblobds", "AzureBlobStorageDataStore config").withRequiredArg().ofType(String.class);
    OptionSet options = parser.parse(args);
    if (!options.has(s3dsConfig) && !options.has(fdsConfig) && !options.has(azureBlobDSConfig)) {
        return null;
    }
    DataStore delegate;
    if (options.has(s3dsConfig)) {
        SharedS3DataStore s3ds = new SharedS3DataStore();
        String cfgPath = s3dsConfig.value(options);
        Properties props = loadAndTransformProps(cfgPath);
        s3ds.setProperties(props);
        File homeDir = Files.createTempDir();
        closer.register(asCloseable(homeDir));
        s3ds.init(homeDir.getAbsolutePath());
        delegate = s3ds;
    } else if (options.has(azureBlobDSConfig)) {
        AzureDataStore azureds = new AzureDataStore();
        String cfgPath = azureBlobDSConfig.value(options);
        Properties props = loadAndTransformProps(cfgPath);
        azureds.setProperties(props);
        File homeDir = Files.createTempDir();
        azureds.init(homeDir.getAbsolutePath());
        closer.register(asCloseable(homeDir));
        delegate = azureds;
    } else {
        delegate = new OakFileDataStore();
        String cfgPath = fdsConfig.value(options);
        Properties props = loadAndTransformProps(cfgPath);
        populate(delegate, asMap(props), true);
        delegate.init(null);
    }
    DataStoreBlobStore blobStore = new DataStoreBlobStore(delegate);
    closer.register(Utils.asCloseable(blobStore));
    return blobStore;
}
Also used : OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) DataStore(org.apache.jackrabbit.core.data.DataStore) AzureDataStore(org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore) SharedS3DataStore(org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore) OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) SharedS3DataStore(org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore) AzureDataStore(org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore) OptionSet(joptsimple.OptionSet) Properties(java.util.Properties) OptionParser(joptsimple.OptionParser) File(java.io.File) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) Nullable(javax.annotation.Nullable)

Example 32 with OptionSet

use of joptsimple.OptionSet in project jackrabbit-oak by apache.

the class OakUpgrade method main.

public static void main(String... args) throws IOException {
    OptionSet options = OptionParserFactory.create().parse(args);
    try {
        MigrationCliArguments cliArguments = new MigrationCliArguments(options);
        if (cliArguments.hasOption(OptionParserFactory.HELP) || cliArguments.getArguments().isEmpty()) {
            CliUtils.displayUsage();
            return;
        }
        migrate(cliArguments);
    } catch (CliArgumentException e) {
        if (e.getMessage() != null) {
            System.err.println(e.getMessage());
        }
        System.exit(e.getExitCode());
    }
}
Also used : CliArgumentException(org.apache.jackrabbit.oak.upgrade.cli.parser.CliArgumentException) OptionSet(joptsimple.OptionSet) MigrationCliArguments(org.apache.jackrabbit.oak.upgrade.cli.parser.MigrationCliArguments)

Example 33 with OptionSet

use of joptsimple.OptionSet in project samza by apache.

the class CoordinatorStreamWriter method main.

/**
   * Main function for using the CoordinatorStreamWriter. The main function starts a CoordinatorStreamWriter
   * and sends control messages.
   * To run the code use the following command:
   * {path to samza deployment}/samza/bin/run-coordinator-stream-writer.sh  --config-factory={config-factory} --config-path={path to config file of a job} --type={type of the message} --key={[optional] key of the message} --value={[optional] value of the message}
   *
   * @param args input arguments for running the writer. These arguments are:
   *             "config-factory" = The config file factory
   *             "config-path" = The path to config file of a job
   *             "type" = type of the message being written
   *             "key" = [optional] key of the message being written
   *             "value" = [optional] value of the message being written
   */
public static void main(String[] args) {
    CoordinatorStreamWriterCommandLine cmdline = new CoordinatorStreamWriterCommandLine();
    OptionSet options = cmdline.parser().parse(args);
    Config config = cmdline.loadConfig(options);
    String type = cmdline.loadType(options);
    String key = cmdline.loadKey(options);
    String value = cmdline.loadValue(options);
    CoordinatorStreamWriter writer = new CoordinatorStreamWriter(config);
    writer.start();
    writer.sendMessage(type, key, value);
    writer.stop();
}
Also used : Config(org.apache.samza.config.Config) SetConfig(org.apache.samza.coordinator.stream.messages.SetConfig) OptionSet(joptsimple.OptionSet)

Example 34 with OptionSet

use of joptsimple.OptionSet in project samza by apache.

the class YarnJobValidationTool method main.

public static void main(String[] args) throws Exception {
    CommandLine cmdline = new CommandLine();
    OptionParser parser = cmdline.parser();
    OptionSpec<String> validatorOpt = parser.accepts("metrics-validator", "The metrics validator class.").withOptionalArg().ofType(String.class).describedAs("com.foo.bar.ClassName");
    OptionSet options = cmdline.parser().parse(args);
    Config config = cmdline.loadConfig(options);
    MetricsValidator validator = null;
    if (options.has(validatorOpt)) {
        String validatorClass = options.valueOf(validatorOpt);
        validator = ClassLoaderHelper.<MetricsValidator>fromClassName(validatorClass);
    }
    YarnConfiguration hadoopConfig = new YarnConfiguration();
    hadoopConfig.set("fs.http.impl", HttpFileSystem.class.getName());
    hadoopConfig.set("fs.https.impl", HttpFileSystem.class.getName());
    ClientHelper clientHelper = new ClientHelper(hadoopConfig);
    new YarnJobValidationTool(new JobConfig(config), clientHelper.yarnClient(), validator).run();
}
Also used : CommandLine(org.apache.samza.util.CommandLine) ClientHelper(org.apache.samza.job.yarn.ClientHelper) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) JobConfig(org.apache.samza.config.JobConfig) Config(org.apache.samza.config.Config) HttpFileSystem(org.apache.samza.util.hadoop.HttpFileSystem) OptionSet(joptsimple.OptionSet) OptionParser(joptsimple.OptionParser) JobConfig(org.apache.samza.config.JobConfig) MetricsValidator(org.apache.samza.metrics.MetricsValidator)

Example 35 with OptionSet

use of joptsimple.OptionSet in project samza by apache.

the class ConfigManager method main.

/**
   * Main function for using the Config Manager. The main function starts a Config Manager, and reacts to all messages thereafter
   * In order for this module to run, you have to add the following configurations to the config file:
   * yarn.rm.address=localhost //the ip of the resource manager in yarn
   * yarn.rm.port=8088 //the port of the resource manager http server
   * Additionally, the config manger will periodically poll the coordinator stream to see if there are any new messages.
   * This period is set to 100 ms by default. However, it can be configured by adding the following property to the input config file.
   * configManager.polling.interval= &lt; polling interval &gt;
   * To run the code use the following command:
   * {path to samza deployment}/samza/bin/run-config-manager.sh  --config-factory={config-factory} --config-path={path to config file of a job}
   *
   * @param args input arguments for running ConfigManager.
   */
public static void main(String[] args) {
    CommandLine cmdline = new CommandLine();
    OptionSet options = cmdline.parser().parse(args);
    Config config = cmdline.loadConfig(options);
    ConfigManager configManager = new ConfigManager(config);
    configManager.run();
}
Also used : CommandLine(org.apache.samza.util.CommandLine) JobConfig(org.apache.samza.config.JobConfig) SetConfig(org.apache.samza.coordinator.stream.messages.SetConfig) Config(org.apache.samza.config.Config) OptionSet(joptsimple.OptionSet)

Aggregations

OptionSet (joptsimple.OptionSet)121 OptionParser (joptsimple.OptionParser)93 File (java.io.File)40 OptionException (joptsimple.OptionException)22 IOException (java.io.IOException)20 List (java.util.List)16 Cluster (voldemort.cluster.Cluster)13 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)12 StoreDefinition (voldemort.store.StoreDefinition)12 ClusterMapper (voldemort.xml.ClusterMapper)10 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)9 FileNotFoundException (java.io.FileNotFoundException)6 VoldemortException (voldemort.VoldemortException)6 BufferedReader (java.io.BufferedReader)5 Properties (java.util.Properties)5 OptionSpec (joptsimple.OptionSpec)5 Node (voldemort.cluster.Node)5 ByteArray (voldemort.utils.ByteArray)5 Closer (com.google.common.io.Closer)4