C# Class Kafka.Client.Producers.Partitioning.ZKBrokerPartitionInfo

Fetch broker info like ID, host, port and number of partitions from ZooKeeper.
Used when zookeeper based auto partition discovery is enabled
Inheritance: IBrokerPartitionInfo, IZooKeeperStateListener
显示文件 Open project: precog/kafka Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void

Closes underlying connection to ZooKeeper

GetAllBrokerInfo ( ) : Broker>.IDictionary

Gets a mapping from broker ID to the host and port for all brokers

GetBrokerInfo ( int brokerId ) : Broker

Gets the host and port information for the broker identified by the given broker ID

GetBrokerPartitionInfo ( string topic ) : SortedSet

Gets a mapping from broker ID to partition IDs

HandleSessionCreated ( ZooKeeperSessionCreatedEventArgs args ) : void

Called after the ZooKeeper session has expired and a new session has been created.

We would have to re-create any ephemeral nodes here.

HandleStateChanged ( ZooKeeperStateChangedEventArgs args ) : void

Called when the ZooKeeper connection state has changed.

Do nothing, since zkclient will do reconnect for us.

ZKBrokerPartitionInfo ( IZooKeeperClient zkclient ) : System

Initializes a new instance of the ZKBrokerPartitionInfo class.

ZKBrokerPartitionInfo ( Kafka.Client.Cfg.ProducerConfiguration config, Action callback ) : System

Initializes a new instance of the ZKBrokerPartitionInfo class.

Private Methods

Method Description
BootstrapWithExistingBrokers ( string topic ) : SortedSet

Add the all available brokers with default one partition for new topic, so all of the brokers participate in hosting this topic

Since we do not have the in formation about number of partitions on these brokers, just assume single partition just pick partition 0 from each broker as a candidate

EnsuresNotDisposed ( ) : void

Ensures that object was not disposed

InitializeBrokers ( ) : void

Initializes the list of brokers.

InitializeTopicBrokerPartitions ( ) : void

Initializes the topic - broker's partitions mappings.

RegisterListeners ( ) : void

Registers the listeners under several path in ZooKeeper to keep related data structures updated.

Watch on following path: /broker/topics /broker/topics/[topic] /broker/ids

Reset ( ) : void

Resets the related data structures

Method Details

Dispose() public method

Closes underlying connection to ZooKeeper
public Dispose ( ) : void
return void

GetAllBrokerInfo() public method

Gets a mapping from broker ID to the host and port for all brokers
public GetAllBrokerInfo ( ) : Broker>.IDictionary
return Broker>.IDictionary

GetBrokerInfo() public method

Gets the host and port information for the broker identified by the given broker ID
public GetBrokerInfo ( int brokerId ) : Broker
brokerId int The broker ID.
return Kafka.Client.Cluster.Broker

GetBrokerPartitionInfo() public method

Gets a mapping from broker ID to partition IDs
public GetBrokerPartitionInfo ( string topic ) : SortedSet
topic string The topic for which this information is to be returned
return SortedSet

HandleSessionCreated() public method

Called after the ZooKeeper session has expired and a new session has been created.
We would have to re-create any ephemeral nodes here.
public HandleSessionCreated ( ZooKeeperSessionCreatedEventArgs args ) : void
args Kafka.Client.ZooKeeperIntegration.Events.ZooKeeperSessionCreatedEventArgs The instance containing the event data.
return void

HandleStateChanged() public method

Called when the ZooKeeper connection state has changed.
Do nothing, since zkclient will do reconnect for us.
public HandleStateChanged ( ZooKeeperStateChangedEventArgs args ) : void
args Kafka.Client.ZooKeeperIntegration.Events.ZooKeeperStateChangedEventArgs The instance containing the event data.
return void

ZKBrokerPartitionInfo() public method

Initializes a new instance of the ZKBrokerPartitionInfo class.
public ZKBrokerPartitionInfo ( IZooKeeperClient zkclient ) : System
zkclient IZooKeeperClient The wrapper above ZooKeeper client.
return System

ZKBrokerPartitionInfo() public method

Initializes a new instance of the ZKBrokerPartitionInfo class.
public ZKBrokerPartitionInfo ( Kafka.Client.Cfg.ProducerConfiguration config, Action callback ) : System
config Kafka.Client.Cfg.ProducerConfiguration The config.
callback Action The callback invoked when new broker is added.
return System