org.apache.flume.Context.containsKey()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中org.apache.flume.Context.containsKey()方法的一些代码示例,展示了Context.containsKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.containsKey()方法的具体详情如下:
包路径:org.apache.flume.Context
类名称:Context
方法名:containsKey

Context.containsKey介绍

[英]Returns true if this Context contains a mapping for key. Otherwise, returns false.
[中]如果此上下文包含键的映射,则返回true。否则,返回false。

代码示例

代码示例来源:origin: apache/flume

private void handleDeprecatedParameter(Context context, String newParam, String oldParam) {
 if (!context.containsKey(newParam) && context.containsKey(oldParam)) {
  context.put(newParam, context.getString(oldParam));
 }
}

代码示例来源:origin: apache/flume

@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));
 }
}

代码示例来源:origin: apache/flume

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);
 if (!(ctx.containsKey(BOOTSTRAP_SERVERS_CONFIG))) {
  String brokerList = ctx.getString(BROKER_LIST_FLUME_KEY);
  if (brokerList == null || brokerList.isEmpty()) {
 if (!(ctx.containsKey(BATCH_SIZE))) {
  String oldBatchSize = ctx.getString(OLD_BATCH_SIZE);
  if ( oldBatchSize != null  && !oldBatchSize.isEmpty())  {
 if (!(ctx.containsKey(KAFKA_PRODUCER_PREFIX + ProducerConfig.ACKS_CONFIG))) {
  String requiredKey = ctx.getString(
      KafkaSinkConstants.REQUIRED_ACKS_FLUME_KEY);
 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 {}",
 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 {}",

代码示例来源:origin: apache/flume

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);
 if (!(ctx.containsKey(BOOTSTRAP_SERVERS_CONFIG))) {
  String brokerList = ctx.getString(BROKER_LIST_FLUME_KEY);
  if (brokerList == null || brokerList.isEmpty()) {
 if (!(ctx.containsKey(KAFKA_CONSUMER_PREFIX + ConsumerConfig.GROUP_ID_CONFIG))) {
  String oldGroupId = ctx.getString(GROUP_ID_FLUME);
  if (oldGroupId != null  && !oldGroupId.isEmpty()) {
 if (!(ctx.containsKey((KAFKA_CONSUMER_PREFIX + ConsumerConfig.AUTO_OFFSET_RESET_CONFIG)))) {
  Boolean oldReadSmallest = ctx.getBoolean(READ_SMALLEST_OFFSET);
  String auto;

代码示例来源:origin: org.apache.flume/flume-ng-core

private void handleDeprecatedParameter(Context context, String newParam, String oldParam) {
 if (!context.containsKey(newParam) && context.containsKey(oldParam)) {
  context.put(newParam, context.getString(oldParam));
 }
}

代码示例来源:origin: org.apache.flume/flume-ng-core

@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));
 }
}

代码示例来源:origin: org.apache.flume.flume-ng-sinks/flume-ng-kafka-sink

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);
 if (!(ctx.containsKey(BOOTSTRAP_SERVERS_CONFIG))) {
  String brokerList = ctx.getString(BROKER_LIST_FLUME_KEY);
  if (brokerList == null || brokerList.isEmpty()) {
 if (!(ctx.containsKey(BATCH_SIZE))) {
  String oldBatchSize = ctx.getString(OLD_BATCH_SIZE);
  if ( oldBatchSize != null  && !oldBatchSize.isEmpty())  {
 if (!(ctx.containsKey(KAFKA_PRODUCER_PREFIX + ProducerConfig.ACKS_CONFIG))) {
  String requiredKey = ctx.getString(
      KafkaSinkConstants.REQUIRED_ACKS_FLUME_KEY);
 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 {}",
 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 {}",

代码示例来源:origin: Stratio/ingestion

if (!context.containsKey(CONF_OUTPUT_HEADER)) {
 throw new ConfigurationException(
   String.format("Either %s must be false or %s must be defined", CONF_OUTPUT_BODY, CONF_OUTPUT_HEADER));

代码示例来源:origin: org.apache.flume.flume-ng-channels/flume-kafka-channel

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);
 if (!(ctx.containsKey(BOOTSTRAP_SERVERS_CONFIG))) {
  String brokerList = ctx.getString(BROKER_LIST_FLUME_KEY);
  if (brokerList == null || brokerList.isEmpty()) {
 if (!(ctx.containsKey(KAFKA_CONSUMER_PREFIX + ConsumerConfig.GROUP_ID_CONFIG))) {
  String oldGroupId = ctx.getString(GROUP_ID_FLUME);
  if (oldGroupId != null  && !oldGroupId.isEmpty()) {
 if (!(ctx.containsKey((KAFKA_CONSUMER_PREFIX + ConsumerConfig.AUTO_OFFSET_RESET_CONFIG)))) {
  Boolean oldReadSmallest = ctx.getBoolean(READ_SMALLEST_OFFSET);
  String auto;

相关文章