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


Java Context.containsKey方法代码示例

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


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

示例1: configure

import org.apache.flume.Context; //导入方法依赖的package包/类
@Override
public void configure(Context context) {
  String searchPattern = context.getString(SEARCH_PAT_KEY);
  Preconditions.checkArgument(!StringUtils.isEmpty(searchPattern),
      "Must supply a valid search pattern " + SEARCH_PAT_KEY +
      " (may not be empty)");

  replaceString = context.getString(REPLACE_STRING_KEY);
  // Empty replacement String value or if the property itself is not present
  // assign empty string as replacement
  if (replaceString == null) {
    replaceString = "";
  }

  searchRegex = Pattern.compile(searchPattern);

  if (context.containsKey(CHARSET_KEY)) {
    // May throw IllegalArgumentException for unsupported charsets.
    charset = Charset.forName(context.getString(CHARSET_KEY));
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:22,代码来源:SearchAndReplaceInterceptor.java

示例2: configure

import org.apache.flume.Context; //导入方法依赖的package包/类
@Override
public void configure(Context context) {
    searchAndReplace = context.getBoolean(SEARCH_AND_REPLACE_KEY);
    String searchPattern = context.getString(SEARCH_PATTERN_KEY);
    replaceString = context.getString(REPLACE_STRING_KEY);
    searchRegex = Pattern.compile(searchPattern);
    if (context.containsKey(CHARSET_KEY)) {
        // May throw IllegalArgumentException for unsupported charsets.
        charset = Charset.forName(context.getString(CHARSET_KEY));
    }
    filterByRow = context.getBoolean(FILTER_BY_ROW_KEY);
    String regexString = context.getString(REGEX_KEY);
    regex = Pattern.compile(regexString);
    filterByCol = context.getBoolean(FILTER_BY_COL_KEY);
    colSeparator = context.getString(COL_SEPARATOR_KEY);
    index = context.getString(INDEX_KEY);
}
 
开发者ID:Transwarp-DE,项目名称:Transwarp-Sample-Code,代码行数:18,代码来源:SearchAndReplaceAndFilterInterceptor.java

示例3: translateOldProps

import org.apache.flume.Context; //导入方法依赖的package包/类
private void translateOldProps(Context ctx) {

    if (!(ctx.containsKey(TOPIC_CONFIG))) {
      ctx.put(TOPIC_CONFIG, ctx.getString("topic"));
      logger.warn("{} is deprecated. Please use the parameter {}", "topic", TOPIC_CONFIG);
    }

    //Broker List
    // If there is no value we need to check and set the old param and log a warning message
    if (!(ctx.containsKey(BOOTSTRAP_SERVERS_CONFIG))) {
      String brokerList = ctx.getString(BROKER_LIST_FLUME_KEY);
      if (brokerList == null || brokerList.isEmpty()) {
        throw new ConfigurationException("Bootstrap Servers must be specified");
      } else {
        ctx.put(BOOTSTRAP_SERVERS_CONFIG, brokerList);
        logger.warn("{} is deprecated. Please use the parameter {}",
                    BROKER_LIST_FLUME_KEY, BOOTSTRAP_SERVERS_CONFIG);
      }
    }

    //batch Size
    if (!(ctx.containsKey(BATCH_SIZE))) {
      String oldBatchSize = ctx.getString(OLD_BATCH_SIZE);
      if ( oldBatchSize != null  && !oldBatchSize.isEmpty())  {
        ctx.put(BATCH_SIZE, oldBatchSize);
        logger.warn("{} is deprecated. Please use the parameter {}", OLD_BATCH_SIZE, BATCH_SIZE);
      }
    }

    // Acks
    if (!(ctx.containsKey(KAFKA_PRODUCER_PREFIX + ProducerConfig.ACKS_CONFIG))) {
      String requiredKey = ctx.getString(
              KafkaSinkConstants.REQUIRED_ACKS_FLUME_KEY);
      if (!(requiredKey == null) && !(requiredKey.isEmpty())) {
        ctx.put(KAFKA_PRODUCER_PREFIX + ProducerConfig.ACKS_CONFIG, requiredKey);
        logger.warn("{} is deprecated. Please use the parameter {}", REQUIRED_ACKS_FLUME_KEY,
                KAFKA_PRODUCER_PREFIX + ProducerConfig.ACKS_CONFIG);
      }
    }

    if (ctx.containsKey(KEY_SERIALIZER_KEY )) {
      logger.warn("{} is deprecated. Flume now uses the latest Kafka producer which implements " +
          "a different interface for serializers. Please use the parameter {}",
          KEY_SERIALIZER_KEY,KAFKA_PRODUCER_PREFIX + ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG);
    }

    if (ctx.containsKey(MESSAGE_SERIALIZER_KEY)) {
      logger.warn("{} is deprecated. Flume now uses the latest Kafka producer which implements " +
                  "a different interface for serializers. Please use the parameter {}",
                  MESSAGE_SERIALIZER_KEY,
                  KAFKA_PRODUCER_PREFIX + ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG);
    }
  }
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:54,代码来源:KafkaSink.java

示例4: translateOldProps

import org.apache.flume.Context; //导入方法依赖的package包/类
private void translateOldProps(Context ctx) {

    if (!(ctx.containsKey(TOPIC_CONFIG))) {
      ctx.put(TOPIC_CONFIG, ctx.getString("topic"));
      logger.warn("{} is deprecated. Please use the parameter {}", "topic", TOPIC_CONFIG);
    }

    //Broker List
    // If there is no value we need to check and set the old param and log a warning message
    if (!(ctx.containsKey(BOOTSTRAP_SERVERS_CONFIG))) {
      String brokerList = ctx.getString(BROKER_LIST_FLUME_KEY);
      if (brokerList == null || brokerList.isEmpty()) {
        throw new ConfigurationException("Bootstrap Servers must be specified");
      } else {
        ctx.put(BOOTSTRAP_SERVERS_CONFIG, brokerList);
        logger.warn("{} is deprecated. Please use the parameter {}",
                    BROKER_LIST_FLUME_KEY, BOOTSTRAP_SERVERS_CONFIG);
      }
    }

    //GroupId
    // If there is an old Group Id set, then use that if no groupId is set.
    if (!(ctx.containsKey(KAFKA_CONSUMER_PREFIX + ConsumerConfig.GROUP_ID_CONFIG))) {
      String oldGroupId = ctx.getString(GROUP_ID_FLUME);
      if (oldGroupId != null  && !oldGroupId.isEmpty()) {
        ctx.put(KAFKA_CONSUMER_PREFIX + ConsumerConfig.GROUP_ID_CONFIG, oldGroupId);
        logger.warn("{} is deprecated. Please use the parameter {}",
                    GROUP_ID_FLUME, KAFKA_CONSUMER_PREFIX + ConsumerConfig.GROUP_ID_CONFIG);
      }
    }

    if (!(ctx.containsKey((KAFKA_CONSUMER_PREFIX + ConsumerConfig.AUTO_OFFSET_RESET_CONFIG)))) {
      Boolean oldReadSmallest = ctx.getBoolean(READ_SMALLEST_OFFSET);
      String auto;
      if (oldReadSmallest != null) {
        if (oldReadSmallest) {
          auto = "earliest";
        } else {
          auto = "latest";
        }
        ctx.put(KAFKA_CONSUMER_PREFIX + ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,auto);
        logger.warn("{} is deprecated. Please use the parameter {}",
                    READ_SMALLEST_OFFSET,
                    KAFKA_CONSUMER_PREFIX + ConsumerConfig.AUTO_OFFSET_RESET_CONFIG);
      }

    }
  }
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:49,代码来源:KafkaChannel.java


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