本文整理匯總了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));
}
}
示例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);
}
}
示例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);
}
}
}