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;
}
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());
}
}
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();
}
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();
}
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= < polling interval >
* 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();
}
Aggregations