当前位置: 首页>>代码示例>>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;未经允许,请勿转载。