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


Java Config.entrySet方法代码示例

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


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

示例1: convertConfigToCoordinatorMessage

import org.apache.samza.config.Config; //导入方法依赖的package包/类
private void convertConfigToCoordinatorMessage(Config config) {
  try {
    for (Map.Entry<String, String> configPair : config.entrySet()) {
      byte[] keyBytes = null;
      byte[] messgeBytes = null;
      if (configPair.getKey().startsWith(CHANGELOGPREFIX)) {
        String[] changelogInfo = configPair.getKey().split(":");
        String changeLogPartition = configPair.getValue();
        SetChangelogMapping changelogMapping = new SetChangelogMapping(changelogInfo[1], changelogInfo[2], Integer.parseInt(changeLogPartition));
        keyBytes = MAPPER.writeValueAsString(changelogMapping.getKeyArray()).getBytes("UTF-8");
        messgeBytes = MAPPER.writeValueAsString(changelogMapping.getMessageMap()).getBytes("UTF-8");
      } else {
        SetConfig setConfig = new SetConfig("source", configPair.getKey(), configPair.getValue());
        keyBytes = MAPPER.writeValueAsString(setConfig.getKeyArray()).getBytes("UTF-8");
        messgeBytes = MAPPER.writeValueAsString(setConfig.getMessageMap()).getBytes("UTF-8");
      }
      // The ssp here is the coordinator ssp (which is always fixed) and not the task ssp.
      put(systemStreamPartition, new IncomingMessageEnvelope(systemStreamPartition, "", keyBytes, messgeBytes));
    }
    setIsAtHead(systemStreamPartition, true);
  } catch (Exception e) {
    throw new SamzaException(e);
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:25,代码来源:MockCoordinatorStreamWrappedConsumer.java

示例2: setAwsClientConfigs

import org.apache.samza.config.Config; //导入方法依赖的package包/类
private void setAwsClientConfigs(Config config, ClientConfiguration clientConfig) {
  for (Entry<String, String> entry : config.entrySet()) {
    boolean found = false;
    String key = entry.getKey();
    String value = entry.getValue();
    if (StringUtils.isEmpty(value)) {
      continue;
    }
    for (Method method : ClientConfiguration.class.getMethods()) {
      // For each property invoke the corresponding setter, if it exists
      if (method.getName().equals("set" + key)) {
        found = true;
        Class<?> type = method.getParameterTypes()[0];
        try {
          if (type == long.class) {
            method.invoke(clientConfig, Long.valueOf(value));
          } else if (type == int.class) {
            method.invoke(clientConfig, Integer.valueOf(value));
          } else if (type == boolean.class) {
            method.invoke(clientConfig, Boolean.valueOf(value));
          } else if (type == String.class) {
            method.invoke(clientConfig, value);
          }
          LOG.info("Loaded property " + key + " = " + value);
          break;
        } catch (Exception e) {
          throw new IllegalArgumentException(
              String.format("Error trying to set field %s with the value '%s'", key, value), e);
        }
      }
    }
    if (!found) {
      LOG.warn("Property " + key + " ignored as there is no corresponding set method");
    }
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:37,代码来源:KinesisConfig.java

示例3: writeConfig

import org.apache.samza.config.Config; //导入方法依赖的package包/类
/**
 * Helper method that sends a series of SetConfig messages to the coordinator
 * stream.
 * 
 * @param source
 *          An identifier to denote which source is sending a message. This
 *          can be any arbitrary string.
 * @param config
 *          The config object to store in the coordinator stream.
 */
public void writeConfig(String source, Config config) {
  log.debug("Writing config: {}", config);
  for (Map.Entry<String, String> configPair : config.entrySet()) {
    send(new SetConfig(source, configPair.getKey(), configPair.getValue()));
  }
  systemProducer.flush(source);
}
 
开发者ID:apache,项目名称:samza,代码行数:18,代码来源:CoordinatorStreamSystemProducer.java


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