(2) synchronization of Config-related classes in storm-kafka Source code

Source: Internet
Author: User

Config is the configuration information. The following is the source code of KafkaConfig and the comments of the younger brother. If there are any errors, I would like to point out

Public class KafkaConfig implements Serializable {/** is an excuse for implementing classes such as ZkHosts and StatisHosts **/public final BrokerHosts hosts; public final String topic; // kafka topic name public final String clientId; // Obtain a unique ID. public int fetchSizeBytes = 1024*1024; // The number of bytes read from kafka each time, this variable will see public int socketTimeoutMs = 10000 in the fetchMessage method of KafkaUtils; // Consumer connection kafka server timeout time public int fetchMaxWait = 10000; public int bufferSizeBytes = 1024*1024; // the cache size on the Consumer side is public MultiScheme scheme = new RawMultiScheme (); // serialization and deserialization of data transmission defined Scheme. A special article will be provided later on public boolean forceFromStart = false; // used with startOffsetTime. The value is false by default. Once startOffsetTime is set, it must be set to true public long startOffsetTime = kafka. api. offsetRequest. earliestTime (); //-2 starting from the kafka header-1 is from the latest start 0 = not starting from ZK public long maxOffsetBehind = Long. MAX_VALUE; // each time kafka reads a batch of offsets and stores them in the list. When zk offset is greater than the current locally saved commitOffse offset, reset commitOffset to the current zk offset, for code, see PartitionManager public boolean useStartOffsetTimeIfOffsetOutOfRange = true; public int metricsTimeBucketSizeInSecs = 60; public KafkaConfig (BrokerHosts hosts, String topic) {this (hosts, topic, kafka. api. offsetRequest. defaultClientId ();} public KafkaConfig (BrokerHosts hosts, String topic, String clientId) {this. hosts = hosts; this. topic = topic; this. clientId = clientId ;}}

SpoutConfig inherits KafkaConfig

Public class SpoutConfig extends KafkaConfig implements Serializable {public List <String> zkServers = null; // List of zk hosts, in the format of simple ip: xxx. xxx. xxx. xxx, used as zkserver, followed by the leader election using public Integer zkPort = null; // zk port, generally 2181 public String zkRoot = null; // This parameter is the meta information consumed by Consumer, save it in the zk path and specify public String id = null; // unique id public long stateUpdateIntervalMs = 2000; // time interval between offset and zk consumed by commit public SpoutConfig (BrokerHosts hosts, String topic, String zkRoot, String id) {super (hosts, topic); this. zkRoot = zkRoot; this. id = id ;}}

The config parameter will be used in subsequent classes. To create a KafkaSpout, the required constructor is SpoutConfig.

The next section describes how to build a KafkaSpout


(2) synchronization of Config-related classes in storm-kafka Source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.