Search in sources :

Example 1 with CommandLine

use of org.apache.samza.util.CommandLine 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();
}
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)

Example 2 with CommandLine

use of org.apache.samza.util.CommandLine 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 = ReflectionUtil.getObj(validatorClass, MetricsValidator.class);
    }
    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) SetConfig(org.apache.samza.coordinator.stream.messages.SetConfig) 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 3 with CommandLine

use of org.apache.samza.util.CommandLine in project samza by apache.

the class SamzaRestService method parseConfig.

/**
 * Reads a {@link org.apache.samza.config.Config} from command line parameters.
 * @param args  the command line parameters supported by {@link org.apache.samza.util.CommandLine}.
 * @return      the parsed {@link org.apache.samza.config.Config}.
 */
private static SamzaRestConfig parseConfig(String[] args) {
    CommandLine cmd = new CommandLine();
    OptionSet options = cmd.parser().parse(args);
    Config cfg = cmd.loadConfig(options);
    return new SamzaRestConfig(new MapConfig(cfg));
}
Also used : CommandLine(org.apache.samza.util.CommandLine) MetricsConfig(org.apache.samza.config.MetricsConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) MapConfig(org.apache.samza.config.MapConfig) OptionSet(joptsimple.OptionSet)

Example 4 with CommandLine

use of org.apache.samza.util.CommandLine in project samza by apache.

the class OrderShipmentJoinExample method main.

// local execution mode
public static void main(String[] args) throws Exception {
    CommandLine cmdLine = new CommandLine();
    Config config = cmdLine.loadConfig(cmdLine.parser().parse(args));
    ApplicationRunner runner = ApplicationRunners.getApplicationRunner(new OrderShipmentJoinExample(), config);
    runner.run();
    runner.waitForFinish();
}
Also used : CommandLine(org.apache.samza.util.CommandLine) ApplicationRunner(org.apache.samza.runtime.ApplicationRunner) Config(org.apache.samza.config.Config)

Example 5 with CommandLine

use of org.apache.samza.util.CommandLine in project samza by apache.

the class RepartitionExample method main.

// local execution mode
public static void main(String[] args) {
    CommandLine cmdLine = new CommandLine();
    Config config = cmdLine.loadConfig(cmdLine.parser().parse(args));
    ApplicationRunner runner = ApplicationRunners.getApplicationRunner(new RepartitionExample(), config);
    runner.run();
    runner.waitForFinish();
}
Also used : CommandLine(org.apache.samza.util.CommandLine) ApplicationRunner(org.apache.samza.runtime.ApplicationRunner) Config(org.apache.samza.config.Config)

Aggregations

Config (org.apache.samza.config.Config)15 CommandLine (org.apache.samza.util.CommandLine)15 ApplicationRunner (org.apache.samza.runtime.ApplicationRunner)12 OptionSet (joptsimple.OptionSet)3 JobConfig (org.apache.samza.config.JobConfig)2 SetConfig (org.apache.samza.coordinator.stream.messages.SetConfig)2 OptionParser (joptsimple.OptionParser)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 MapConfig (org.apache.samza.config.MapConfig)1 MetricsConfig (org.apache.samza.config.MetricsConfig)1 ClientHelper (org.apache.samza.job.yarn.ClientHelper)1 MetricsValidator (org.apache.samza.metrics.MetricsValidator)1 HttpFileSystem (org.apache.samza.util.hadoop.HttpFileSystem)1