当前位置: 首页>>代码示例>>Java>>正文


Java ConsumerRebalanceListener类代码示例

本文整理汇总了Java中org.apache.kafka.clients.consumer.ConsumerRebalanceListener的典型用法代码示例。如果您正苦于以下问题:Java ConsumerRebalanceListener类的具体用法?Java ConsumerRebalanceListener怎么用?Java ConsumerRebalanceListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConsumerRebalanceListener类属于org.apache.kafka.clients.consumer包,在下文中一共展示了ConsumerRebalanceListener类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: subscribe

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; //导入依赖的package包/类
@Override
public void subscribe(Collection<String> topics, ConsumerRebalanceListener listener) {
    super.subscribe(topics, listener);
    Map<TopicPartition, Long> offsets = topics
            .stream()
            .flatMap(
                    topic -> IntStream
                            .range(0, KafkaMockFactory.NUMBER_OF_PARTITIONS)
                            .mapToObj(i -> new TopicPartition(topic, i)))
            .collect(Collectors.toMap(Function.identity(), topicPartition -> 0L));
    rebalance(offsets.keySet());
    updateBeginningOffsets(offsets);
    updateEndOffsets(offsets);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:15,代码来源:ProxyMockConsumer.java

示例2: subscribe

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; //导入依赖的package包/类
@Override
public void subscribe(final Collection<String> topics, final ConsumerRebalanceListener callback) {
    Retries.tryMe(new Runnable() {
        @Override
        public void run() {
            inner.subscribe(topics, callback);
        }
    }, strategy());
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:10,代码来源:ConsumerProxyRetry.java

示例3: subscribe

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; //导入依赖的package包/类
@Override public void subscribe(Collection<String> topics, ConsumerRebalanceListener listener) {
    super.subscribe(topics, listener);
    Map<TopicPartition, Long> offsets = new HashMap<>();
    for (String topic : topics) {
        TopicPartition partition1 = new TopicPartition(topic, 0);
        offsets.put(partition1, 0L);

        TopicPartition partition2 = new TopicPartition(topic, 1);
        offsets.put(partition2, 0L);
    }
    rebalance(offsets.keySet());
    updateBeginningOffsets(offsets);
    updateEndOffsets(offsets);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:15,代码来源:ProxyMockConsumer.java

示例4: subscribe

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; //导入依赖的package包/类
public void subscribe(Pattern pattern, ConsumerRebalanceListener listener) {
    if (listener == null)
        throw new IllegalArgumentException("RebalanceListener cannot be null");

    setSubscriptionType(SubscriptionType.AUTO_PATTERN);

    this.listener = listener;
    this.subscribedPattern = pattern;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:10,代码来源:SubscriptionState.java

示例5: subscribe

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; //导入依赖的package包/类
@Override
public void subscribe(Collection<String> topics, ConsumerRebalanceListener callback) {
  Set<String> newSubscription = new HashSet<>(topics);
  // TODO: This is a hot fix for KAFKA-3664 and should be removed after the issue is fixed.
  commitSync();
  for (TopicPartition tp : _kafkaConsumer.assignment()) {
    if (!newSubscription.contains(tp.topic())) {
      _consumerRecordsProcessor.clear(tp);
    }
  }
  _consumerRebalanceListener.setUserListener(callback);
  _kafkaConsumer.subscribe(new ArrayList<>(topics), _consumerRebalanceListener);
}
 
开发者ID:becketqin,项目名称:likafka-clients,代码行数:14,代码来源:LiKafkaConsumerImpl.java

示例6: subscribe

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; //导入依赖的package包/类
public void subscribe(Collection<String> topics, ConsumerRebalanceListener listener) {
    if (listener == null)
        throw new IllegalArgumentException("RebalanceListener cannot be null");

    if (!this.userAssignment.isEmpty() || this.subscribedPattern != null)
        throw new IllegalStateException(SUBSCRIPTION_EXCEPTION_MESSAGE);

    this.listener = listener;

    changeSubscription(topics);
}
 
开发者ID:txazo,项目名称:kafka,代码行数:12,代码来源:SubscriptionState.java

示例7: subscribe

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; //导入依赖的package包/类
@Override
public void subscribe(Collection<String> topics, ConsumerRebalanceListener listener) {
  consumer.subscribe(topics, listener);
}
 
开发者ID:opentracing-contrib,项目名称:java-kafka-client,代码行数:5,代码来源:TracingKafkaConsumer.java

示例8: subscribe

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; //导入依赖的package包/类
@Override public void subscribe(Collection<String> topics, ConsumerRebalanceListener callback) {
    activeConsumer().subscribe(topics, callback);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:4,代码来源:ConsumerForTests.java

示例9: subscribe

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; //导入依赖的package包/类
@Override public void subscribe(Collection<String> topics, ConsumerRebalanceListener callback) {
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:3,代码来源:ConsumerAdapter.java

示例10: listener

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; //导入依赖的package包/类
public ConsumerRebalanceListener listener() {
    return listener;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:4,代码来源:SubscriptionState.java

示例11: getRebalanceListener

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; //导入依赖的package包/类
public ConsumerRebalanceListener getRebalanceListener() {
    return rebalanceListener;
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:4,代码来源:IndexingConsumer.java

示例12: setUserListener

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; //导入依赖的package包/类
public void setUserListener(ConsumerRebalanceListener userListener) {
  _userListener = userListener;
}
 
开发者ID:becketqin,项目名称:likafka-clients,代码行数:4,代码来源:LiKafkaConsumerRebalanceListener.java

示例13: subscribe

import org.apache.kafka.clients.consumer.ConsumerRebalanceListener; //导入依赖的package包/类
/**
 * Subscribe to the given list of topics to get dynamically
 * assigned partitions. <b>Topic subscriptions are not incremental. This list will replace the current
 * assignment (if there is one).</b> Note that it is not possible to combine topic subscription with group management
 * with manual partition assignment through {@link #assign(Collection)}.
 * <p>
 * If the given list of topics is empty, it is treated the same as {@link #unsubscribe()}.
 * <p>
 * As part of group management, the consumer will keep track of the list of consumers that belong to a particular
 * group and will trigger a rebalance operation if one of the following events trigger -
 * <ul>
 * <li>Number of partitions change for any of the subscribed list of topics
 * <li>Topic is created or deleted
 * <li>An existing member of the consumer group dies
 * <li>A new member is added to an existing consumer group via the join API
 * </ul>
 * <p>
 * When any of these events are triggered, the provided listener will be invoked first to indicate that
 * the consumer's assignment has been revoked, and then again when the new assignment has been received.
 * Note that this listener will immediately override any listener set in a previous call to subscribe.
 * It is guaranteed, however, that the partitions revoked/assigned through this interface are from topics
 * subscribed in this call. See {@link ConsumerRebalanceListener} for more details.
 * <p>
 * In order to support large message, the consumer tracks all the consumed messages for each partition. When the
 * user no longer subscribes to a new set of topics, the consumer will discard all the tracked messages of the
 * partitions of that topic.
 *
 * @param topics   The list of topics to subscribe to
 * @param callback Non-null listener instance to get notifications on partition assignment/revocation for the
 *                 subscribed topics
 */
@InterfaceOrigin.ApacheKafka
void subscribe(Collection<String> topics, ConsumerRebalanceListener callback);
 
开发者ID:becketqin,项目名称:likafka-clients,代码行数:34,代码来源:LiKafkaConsumer.java


注:本文中的org.apache.kafka.clients.consumer.ConsumerRebalanceListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。