當前位置: 首頁>>代碼示例>>Java>>正文


Java Blacklist類代碼示例

本文整理匯總了Java中kafka.consumer.Blacklist的典型用法代碼示例。如果您正苦於以下問題:Java Blacklist類的具體用法?Java Blacklist怎麽用?Java Blacklist使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Blacklist類屬於kafka.consumer包,在下文中一共展示了Blacklist類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: MessageReader

import kafka.consumer.Blacklist; //導入依賴的package包/類
public MessageReader(SecorConfig config, OffsetTracker offsetTracker) throws
        UnknownHostException {
    mConfig = config;
    mOffsetTracker = offsetTracker;

    mConsumerConnector = Consumer.createJavaConsumerConnector(createConsumerConfig());

    if (!mConfig.getKafkaTopicBlacklist().isEmpty() && !mConfig.getKafkaTopicFilter().isEmpty()) {
        throw new RuntimeException("Topic filter and blacklist cannot be both specified.");
    }
    TopicFilter topicFilter = !mConfig.getKafkaTopicBlacklist().isEmpty()? new Blacklist(mConfig.getKafkaTopicBlacklist()):
            new Whitelist(mConfig.getKafkaTopicFilter());
    LOG.debug("Use TopicFilter {}({})", topicFilter.getClass(), topicFilter);
    List<KafkaStream<byte[], byte[]>> streams =
        mConsumerConnector.createMessageStreamsByFilter(topicFilter);
    KafkaStream<byte[], byte[]> stream = streams.get(0);
    mIterator = stream.iterator();
    mLastAccessTime = new HashMap<TopicPartition, Long>();
    StatsUtil.setLabel("secor.kafka.consumer.id", IdUtil.getConsumerId());
    mTopicPartitionForgetSeconds = mConfig.getTopicPartitionForgetSeconds();
    mCheckMessagesPerSecond = mConfig.getMessagesPerSecond() / mConfig.getConsumerThreads();
    mKafkaMessageTimestampFactory = new KafkaMessageTimestampFactory(mConfig.getKafkaMessageTimestampClass());
}
 
開發者ID:pinterest,項目名稱:secor,代碼行數:24,代碼來源:MessageReader.java

示例2: pattern

import kafka.consumer.Blacklist; //導入依賴的package包/類
public String pattern() {
	if (topicFilter instanceof Whitelist)
		return whiteListPattern;
	else if (topicFilter instanceof Blacklist)
		return blackListPattern;
	else
		throw new KafkaZKException("Invalid topicFilter.");
}
 
開發者ID:pulsarIO,項目名稱:druid-kafka-ext,代碼行數:9,代碼來源:TopicCount.java

示例3: noneOf

import kafka.consumer.Blacklist; //導入依賴的package包/類
public static TopicFilter noneOf( String...topics) {
    StringJoiner joiner = new StringJoiner(",");
    for ( String topic : topics ) {
        joiner.add(topic);
    }
    return new Blacklist(joiner.toString());
}
 
開發者ID:rhauch,項目名稱:debezium-proto,代碼行數:8,代碼來源:Topics.java

示例4: constructTopicCount

import kafka.consumer.Blacklist; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static TopicCount constructTopicCount(ZKConnector<?> zkClient, String group,
		String consumerId) {
	KafkaZKData.ZKGroupDirs dirs = new KafkaZKData.ZKGroupDirs(group);
	String subscriptionPattern = null;
	Map<String, Integer> topMap = null;
	try {
		String topicCountString = zkClient.readData(dirs.consumerRegistryDir() + "/" + consumerId);
		ObjectMapper mapper = new ObjectMapper();
		TypeReference<Map<String, Object>> typeMap = new TypeReference<Map<String, Object>>() {
		};
		Map<String, Object> jsonObj = mapper.reader(typeMap).readValue(
				topicCountString);
		if (jsonObj == null)
			throw new KafkaZKException("error constructing TopicCount : "
					+ topicCountString);
		Object pattern = jsonObj.get("pattern");
		if (pattern == null)
			throw new KafkaZKException("error constructing TopicCount : "
					+ topicCountString);
		subscriptionPattern = (String) pattern;
		Object sub = jsonObj.get("subscription");
		if (sub == null)
			throw new KafkaZKException("error constructing TopicCount : "
					+ topicCountString);
		topMap = (Map<String, Integer>) sub;

	} catch (Throwable t) {
		throw new KafkaZKException(t);
	}

	boolean hasWhiteList = whiteListPattern.equals(subscriptionPattern);
	boolean hasBlackList = blackListPattern.equals(subscriptionPattern);

	if (topMap.isEmpty() || !(hasWhiteList || hasBlackList)) {
		return new StaticTopicCount(consumerId, topMap);
	} else {
		String regex = null;
		Integer numStreams = -1;
		for (Entry<String, Integer> entity : topMap.entrySet()) {
			regex = entity.getKey();
			numStreams = entity.getValue();
			break;
		}
		TopicFilter filter = hasWhiteList ? new Whitelist(regex)
				: new Blacklist(regex);

		return new WildcardTopicCount(zkClient, consumerId, filter,
				numStreams);
	}

}
 
開發者ID:pulsarIO,項目名稱:druid-kafka-ext,代碼行數:53,代碼來源:TopicCount.java


注:本文中的kafka.consumer.Blacklist類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。