当前位置: 首页>>代码示例>>Java>>正文


Java Config.containsKey方法代码示例

本文整理汇总了Java中org.apache.samza.config.Config.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Java Config.containsKey方法的具体用法?Java Config.containsKey怎么用?Java Config.containsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.samza.config.Config的用法示例。


在下文中一共展示了Config.containsKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ConfigManager

import org.apache.samza.config.Config; //导入方法依赖的package包/类
public ConfigManager(Config config) {

    //get rm address and port
    if (!config.containsKey(rmAddressOpt) || !config.containsKey(rmPortOpt)) {
      throw new IllegalArgumentException("Missing config: the config file does not contain the rm host or port.");
    }
    String rmAddress = config.get(rmAddressOpt);
    int rmPort = config.getInt(rmPortOpt);

    //get job name and id;
    if (!config.containsKey(JobConfig.JOB_NAME())) {
      throw new IllegalArgumentException("Missing config: the config does not contain the job name");
    }
    jobName = config.get(JobConfig.JOB_NAME());
    jobID = config.getInt(JobConfig.JOB_ID(), 1);

    //set polling interval
    if (config.containsKey(pollingIntervalOpt)) {
      long pollingInterval = config.getLong(pollingIntervalOpt);
      if (pollingInterval <= 0) {
        throw new IllegalArgumentException("polling interval cannot be a negative value");
      }
      this.interval = pollingInterval;
    } else {
      this.interval = defaultPollingInterval;
    }

    this.config = config;
    CoordinatorStreamSystemFactory coordinatorStreamSystemFactory = new CoordinatorStreamSystemFactory();
    this.coordinatorStreamConsumer = coordinatorStreamSystemFactory.getCoordinatorStreamSystemConsumer(config, new MetricsRegistryMap());
    this.yarnUtil = new YarnUtil(rmAddress, rmPort);
  }
 
开发者ID:apache,项目名称:samza,代码行数:33,代码来源:ConfigManager.java

示例2: main

import org.apache.samza.config.Config; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  ApplicationRunnerCommandLine cmdLine = new ApplicationRunnerCommandLine();
  OptionSet options = cmdLine.parser().parse(args);
  Config orgConfig = cmdLine.loadConfig(options);
  Config config = Util.rewriteConfig(orgConfig);
  ApplicationRunnerOperation op = cmdLine.getOperation(options);

  if (config.containsKey(STREAM_APPLICATION_CLASS_CONFIG)) {
    ApplicationRunner runner = ApplicationRunner.fromConfig(config);
    StreamApplication app =
        (StreamApplication) Class.forName(config.get(STREAM_APPLICATION_CLASS_CONFIG)).newInstance();
    switch (op) {
      case RUN:
        runner.run(app);
        break;
      case KILL:
        runner.kill(app);
        break;
      case STATUS:
        System.out.println(runner.status(app));
        break;
      default:
        throw new IllegalArgumentException("Unrecognized operation: " + op);
    }
  } else {
    JobRunner$.MODULE$.main(args);
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:29,代码来源:ApplicationRunnerMain.java

示例3: GroupBySystemStreamPartition

import org.apache.samza.config.Config; //导入方法依赖的package包/类
/**
 * A constructor that accepts job config as the parameter
 *
 * @param config job config
 */
public GroupBySystemStreamPartition(Config config) {
  if (config.containsKey(TaskConfigJava.BROADCAST_INPUT_STREAMS)) {
    taskConfig = new TaskConfigJava(config);
    broadcastStreams = taskConfig.getBroadcastSystemStreamPartitions();
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:12,代码来源:GroupBySystemStreamPartition.java

示例4: GroupByPartition

import org.apache.samza.config.Config; //导入方法依赖的package包/类
/**
 * Accepts the config in the constructor
 *
 * @param config job's config
 */
public GroupByPartition(Config config) {
  if (config.containsKey(TaskConfigJava.BROADCAST_INPUT_STREAMS)) {
    taskConfig = new TaskConfigJava(config);
    this.broadcastStreams = taskConfig.getBroadcastSystemStreamPartitions();
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:12,代码来源:GroupByPartition.java

示例5: findJobInstances

import org.apache.samza.config.Config; //导入方法依赖的package包/类
/**
 * Finds all the job instances in the specified path and adds a corresponding {@link JobInstance} and
 * {@link InstallationRecord} for each instance.
 *
 * @param jobInstallPath  the path to search for job instances.
 * @param jobs            the map to which the job instances will be added.
 */
private void findJobInstances(final File jobInstallPath, final Map<JobInstance, InstallationRecord> jobs) {
  try {
    String jobInstallCanonPath = jobInstallPath.getCanonicalPath();
    File configPath = Paths.get(jobInstallCanonPath, CFG_SUBPATH).toFile();
    if (!(configPath.exists() && configPath.isDirectory())) {
      log.debug("Config path not found: " + configPath);
      return;
    }

    for (File configFile : configPath.listFiles()) {

      if (configFile.isFile()) {

        String configFilePath = configFile.getCanonicalPath();
        Config config = jobConfigFactory.getConfig(new URI("file://" + configFilePath));

        if (config.containsKey(JobConfig.JOB_NAME()) && config.containsKey(JobConfig.STREAM_JOB_FACTORY_CLASS())) {

          String jobName = config.get(JobConfig.JOB_NAME());
          String jobId = config.get(JobConfig.JOB_ID(), "1");
          JobInstance jobInstance = new JobInstance(jobName, jobId);

          if (jobs.containsKey(jobInstance)) {
            throw new IllegalStateException(
                String.format("Found more than one job config with jobName:%s and jobId:%s", jobName, jobId));
          }
          InstallationRecord jobInstall =
              new InstallationRecord(jobName, jobId, jobInstallCanonPath, configFilePath, getBinPath(jobInstallCanonPath));
          jobs.put(jobInstance, jobInstall);
        }
      }
    }
  } catch (Exception e) {
    throw new SamzaException("Exception finding job instance in path: " + jobInstallPath, e);
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:44,代码来源:SimpleInstallationFinder.java

示例6: getResourceInstances

import org.apache.samza.config.Config; //导入方法依赖的package包/类
@Override
public List<? extends Object> getResourceInstances(Config config) {
  List<Object> resources = new ArrayList<>();
  if (config.containsKey(JobsResourceConfig.CONFIG_JOB_PROXY_FACTORY)) {
    resources.add(new JobsResource(new JobsResourceConfig(config)));
  }
  if (config.containsKey(TaskResourceConfig.CONFIG_TASK_PROXY_FACTORY)) {
    resources.add(new TasksResource(new TaskResourceConfig(config)));
  }
  return resources;
}
 
开发者ID:apache,项目名称:samza,代码行数:12,代码来源:MockResourceFactory.java


注:本文中的org.apache.samza.config.Config.containsKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。