本文整理了Java中org.apache.flume.Context.containsKey()
方法的一些代码示例,展示了Context.containsKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.containsKey()
方法的具体详情如下:
包路径:org.apache.flume.Context
类名称: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;
内容来源于网络,如有侵权,请联系作者删除!