Kafka中Consumer类源码介绍

来源:互联网 发布:陈奕迅专辑 知乎 编辑:程序博客网 时间:2024/05/24 05:44

Kafka中Consumer源码

public interface Consumer<K, V> extends Closeable {    void subscribe(String... var1);    void subscribe(TopicPartition... var1);    void unsubscribe(String... var1);    void unsubscribe(TopicPartition... var1);    Map<String, ConsumerRecords<K, V>> poll(long var1);    OffsetMetadata commit(boolean var1);    OffsetMetadata commit(Map<TopicPartition, Long> var1, boolean var2);    void seek(Map<TopicPartition, Long> var1);    Map<TopicPartition, Long> position(Collection<TopicPartition> var1);    Map<TopicPartition, Long> committed(Collection<TopicPartition> var1);    Map<TopicPartition, Long> offsetsBeforeTime(long var1, Collection<TopicPartition> var3);    Map<MetricName, ? extends Metric> metrics();    void close();}
Closeable源码

public interface Closeable {    /**     * Closes this stream and releases any system resources associated     * with it. If the stream is already closed then invoking this      * method has no effect.      *     * @throws IOException if an I/O error occurs     */    public void close() throws IOException;}
TopicPartition源码

public final class TopicPartition {    private int hash = 0;    private final int partition;    private final String topic;    public TopicPartition(String topic, int partition) {        this.partition = partition;        this.topic = topic;    }    public int partition() {        return this.partition;    }    public String topic() {        return this.topic;    }    public int hashCode() {        if(this.hash != 0) {            return this.hash;        } else {            boolean prime = true;            byte result = 1;            int result1 = 31 * result + this.partition;            result1 = 31 * result1 + (this.topic == null?0:this.topic.hashCode());            this.hash = result1;            return result1;        }    }    public boolean equals(Object obj) {        if(this == obj) {            return true;        } else if(obj == null) {            return false;        } else if(this.getClass() != obj.getClass()) {            return false;        } else {            TopicPartition other = (TopicPartition)obj;            if(this.partition != other.partition) {                return false;            } else {                if(this.topic == null) {                    if(other.topic != null) {                        return false;                    }                } else if(!this.topic.equals(other.topic)) {                    return false;                }                return true;            }        }    }    public String toString() {        return this.topic + "-" + this.partition;    }}

OffsetMetadata源码

public final class OffsetMetadata {    private final Map<TopicPartition, Long> offsets;    private final Map<TopicPartition, RuntimeException> errors;

ConsumerRecords源码

public class ConsumerRecords<K, V> {    private final String topic;    private final Map<Integer, List<ConsumerRecord<K, V>>> recordsPerPartition;


MetricName源码

public final class MetricName {    private final String name;    private final String group;    private final String description;    private Map<String, String> tags;    private int hash;





0 0
原创粉丝点击