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


Java Config.get方法代码示例

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


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

示例1: getConsumer

import org.apache.samza.config.Config; //导入方法依赖的package包/类
/**
 * Returns a consumer that sends all configs to the coordinator stream.
 *
 * @param config Along with the configs, you can pass checkpoints and changelog stream messages into the stream.
 *               The expected pattern is cp:source:taskname -> ssp,offset for checkpoint (Use sspToString util)
 *               ch:source:taskname -> changelogPartition for changelog
 *               Everything else is processed as normal config
 */
public SystemConsumer getConsumer(String systemName, Config config, MetricsRegistry registry) {

  if (useCachedConsumer && mockConsumer != null) {
    return mockConsumer;
  }

  String jobName = config.get("job.name");
  String jobId = config.get("job.id");
  if (jobName == null) {
    throw new ConfigException("Must define job.name.");
  }
  if (jobId == null) {
    jobId = "1";
  }
  String streamName = Util.getCoordinatorStreamName(jobName, jobId);
  SystemStreamPartition systemStreamPartition = new SystemStreamPartition(systemName, streamName, new Partition(0));
  mockConsumer = new MockCoordinatorStreamWrappedConsumer(systemStreamPartition, config);
  return mockConsumer;
}
 
开发者ID:apache,项目名称:samza,代码行数:28,代码来源:MockCoordinatorStreamSystemFactory.java

示例2: init

import org.apache.samza.config.Config; //导入方法依赖的package包/类
@Override
public void init(Config config, TaskContext context) throws Exception {
  String yarnConfHome = config.get(SamzaConfigFactory.YARN_CONF_HOME_KEY);
  if (yarnConfHome != null && yarnConfHome.length() > 0) // if the property is set, otherwise, assume we are running in local mode and ignore this
    SystemsUtils.setHadoopConfigHome(yarnConfHome);

  String filename = config.get(SamzaConfigFactory.FILE_KEY);
  String filesystem = config.get(SamzaConfigFactory.FILESYSTEM_KEY);

  this.setName(config.get(SamzaConfigFactory.JOB_NAME_KEY));
  SerializationProxy wrapper = (SerializationProxy) SystemsUtils.deserializeObjectFromFileAndKey(filesystem,
      filename, this.getName());
  this.setOutputStream(wrapper.outputStream);
  SamzaStream output = (SamzaStream) this.getOutputStream();
  if (output != null) // if output stream exists, set it up
    output.onCreate();
}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:18,代码来源:SamzaEntranceProcessingItem.java

示例3: SamoaSystemConsumer

import org.apache.samza.config.Config; //导入方法依赖的package包/类
public SamoaSystemConsumer(String systemName, Config config) {
  String yarnConfHome = config.get(SamzaConfigFactory.YARN_CONF_HOME_KEY);
  if (yarnConfHome != null && yarnConfHome.length() > 0) // if the property is set, otherwise, assume we are running in local mode and ignore this
    SystemsUtils.setHadoopConfigHome(yarnConfHome);

  String filename = config.get(SamzaConfigFactory.FILE_KEY);
  String filesystem = config.get(SamzaConfigFactory.FILESYSTEM_KEY);
  String name = config.get(SamzaConfigFactory.JOB_NAME_KEY);
  SerializationProxy wrapper = (SerializationProxy) SystemsUtils.deserializeObjectFromFileAndKey(filesystem,
      filename, name);

  this.entranceProcessor = wrapper.processor;
  this.entranceProcessor.onCreate(0);

  // Internal stream from SystemConsumer to EntranceTask, so we
  // need only one partition
  this.systemStreamPartition = new SystemStreamPartition(systemName, wrapper.name, new Partition(0));
}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:19,代码来源:SamzaEntranceProcessingItem.java

示例4: init

import org.apache.samza.config.Config; //导入方法依赖的package包/类
@Override
public void init(Config config, TaskContext context) throws Exception {
  String yarnConfHome = config.get(SamzaConfigFactory.YARN_CONF_HOME_KEY);
  if (yarnConfHome != null && yarnConfHome.length() > 0) // if the property is set, otherwise, assume we are running in local mode and ignore this                                                            // set , otherwise,
    SystemsUtils.setHadoopConfigHome(yarnConfHome);

  String filename = config.get(SamzaConfigFactory.FILE_KEY);
  String filesystem = config.get(SamzaConfigFactory.FILESYSTEM_KEY);
  this.setName(config.get(SamzaConfigFactory.JOB_NAME_KEY));
  SerializationProxy wrapper = (SerializationProxy) SystemsUtils.deserializeObjectFromFileAndKey(filesystem,
      filename, this.getName());
  this.setProcessor(wrapper.processor);
  this.outputStreams = wrapper.outputStreams;

  // Init Processor and Streams
  this.getProcessor().onCreate(0);
  for (SamzaStream stream : this.outputStreams) {
    stream.onCreate();
  }

}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:22,代码来源:SamzaProcessingItem.java

示例5: getConsumer

import org.apache.samza.config.Config; //导入方法依赖的package包/类
@Override
public SystemConsumer getConsumer(String systemName, Config config, MetricsRegistry registry) {
  String host = config.get("systems." + systemName + ".host");
  int port = config.getInt("systems." + systemName + ".port");
  WikipediaFeed feed = new WikipediaFeed(host, port);

  return new WikipediaConsumer(systemName, feed, registry);
}
 
开发者ID:yoloanalytics,项目名称:bigdata-swamp,代码行数:9,代码来源:WikipediaSystemFactory.java

示例6: 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

示例7: getSystemStreamPartitionGrouper

import org.apache.samza.config.Config; //导入方法依赖的package包/类
@Override
public SystemStreamPartitionGrouper getSystemStreamPartitionGrouper(Config config) {
  if (!(new TaskConfigJava(config).getBroadcastSystemStreams().isEmpty())) {
    throw new ConfigException("The job configured with AllSspToSingleTaskGrouper cannot have broadcast streams.");
  }

  String processors = config.get(JobConfig.PROCESSOR_LIST());
  List<String> processorList = Arrays.asList(processors.split(","));
  if (processorList.isEmpty()) {
    throw new SamzaException("processor list cannot be empty!");
  }
  return new AllSspToSingleTaskGrouper(processorList);
}
 
开发者ID:apache,项目名称:samza,代码行数:14,代码来源:AllSspToSingleTaskGrouperFactory.java

示例8: 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

示例9: init

import org.apache.samza.config.Config; //导入方法依赖的package包/类
@Override
public void init(Config config, TaskContext context) throws Exception {
  maxMessages = config.getInt("task.max.messages", 50);
  String outputSystemStreamString = config.get("task.outputs", null);
  if (outputSystemStreamString == null) {
    throw new ConfigException("Missing required configuration: task.outputs");
  }
  outputSystemStream = Util.getSystemStreamFromNames(outputSystemStreamString);
}
 
开发者ID:apache,项目名称:samza,代码行数:10,代码来源:NegateNumberTask.java

示例10: init

import org.apache.samza.config.Config; //导入方法依赖的package包/类
@Override
public void init(Config config, TaskContext taskContext)
    throws Exception {
  this.processorId = config.get(ApplicationConfig.PROCESSOR_ID);
  this.outputTopic = config.get("app.outputTopic", "output");
  this.outputSystem = config.get("app.outputSystem", "test-system");
  this.processorIdToFail = config.get("processor.id.to.fail", "1");
}
 
开发者ID:apache,项目名称:samza,代码行数:9,代码来源:TestZkStreamProcessorBase.java

示例11: getSerde

import org.apache.samza.config.Config; //导入方法依赖的package包/类
@Override
public AvroSerde getSerde(String s, Config config) {
    final String registryUrl = config.get("confluent.schema.registry.url");
    final Properties encoderProps = new Properties();
    encoderProps.setProperty("schema.registry.url", registryUrl);
    final Properties decoderProps = new Properties();
    decoderProps.setProperty("schema.registry.url", registryUrl);
    decoderProps.setProperty("specific.avro.reader", "true");
    return new AvroSerde(new VerifiableProperties(encoderProps), new VerifiableProperties(decoderProps));
}
 
开发者ID:theduderog,项目名称:hello-samza-confluent,代码行数:11,代码来源:AvroSerdeFactory.java

示例12: init

import org.apache.samza.config.Config; //导入方法依赖的package包/类
@Override
public void init(Config config, TaskContext context) throws Exception {
  outputStream = new SystemStream(config.get(OUTPUT_SYSTEM, "kafka"), config.get(OUTPUT_STREAM, "result"));
  maxMessages = Integer.parseInt(config.get(MAX_MESSAGES, "10"));
}
 
开发者ID:FreshetDMS,项目名称:Freshet-Deprecated,代码行数:6,代码来源:IntDoublerStreamTask.java

示例13: getSerde

import org.apache.samza.config.Config; //导入方法依赖的package包/类
public Serde<String> getSerde(String name, Config config) {
  return new StringSerde(config.get("encoding", "UTF-8"));
}
 
开发者ID:apache,项目名称:samza,代码行数:4,代码来源:StringSerdeFactory.java

示例14: build

import org.apache.samza.config.Config; //导入方法依赖的package包/类
@Override
public TaskNameGrouper build(Config config) {
  return new SingleContainerGrouper(config.get(JobConfig.PROCESSOR_ID()));
}
 
开发者ID:apache,项目名称:samza,代码行数:5,代码来源:SingleContainerGrouperFactory.java

示例15: getCoordinatorSystemStream

import org.apache.samza.config.Config; //导入方法依赖的package包/类
private SystemStream getCoordinatorSystemStream(Config config) {
  assertNotNull(config.get("job.coordinator.system"));
  assertNotNull(config.get("job.name"));
  return new SystemStream(config.get("job.coordinator.system"), Util.getCoordinatorStreamName(config.get("job.name"),
      config.get("job.id") == null ? "1" : config.get("job.id")));
}
 
开发者ID:apache,项目名称:samza,代码行数:7,代码来源:MockCoordinatorStreamSystemFactory.java


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