THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
Motivation
Summary of existing controller
Current Kafka controller is a multi-threaded controller that emulates a state machine. It works in the following model.
Maintained state:
- Partitions replicas on each machine.
- Leaders of partitions.
State change input source:
- Listeners Registered to Zookeeper.
- AddPartitionsListener
- BrokerChangeListener
- DeleteTopicListener
- PartitionReassignedListener(Admin)
- PreferredReplicaElectionListener(Admin)
- ReassignedPartitionsIsrChangeListener
- TopicChangeListener
- Channels to brokers (controlled shutdown)
- Internal scheduled tasks (preferred leader election)
State change propagate model:
- P2P blocking channel from controller to each broker.
- Dedicated message queue for each controller-to-broker connection.
- No synchronization on message sent to different brokers.
- No callback for sending messages except topic deletion.
Fail Over/Back model:
- Zookeeper based leader election
- Zookeeper as persistent state store for fault tolerance.
Problems of existing controller
- State change are executed by different listeners concurrently. Hence complicated synchronization is needed which is error prone and difficult to debug.
- State propagation is not synchronized. Brokers might be in different state for undetermined time. This leads to unnecessary extra data loss.
New controller design
Design Principle
- Abstract the output of each state change input source to an event.
- Have a single execution thread to serially process events one at a time.
- Keep cluster state and topic state separately.
- Use o.a.k.clients.NetworClient + callback for state change propagation.
Top level design