YAKt-Yet-Another-KRaft
Libraries used:
- Pyraft - leader election, raft node structure, log replication
- Telnetlib - used get, set methods for log replication
Metadata Records used:
- RegisterBrokerRecord:
- Topic Record
- Partition Record
- ProducerID Record
- Change Broker Record
End points created:
- /register_broker - Responsible for the registration of brokers. Added additional timestamp for snapshot purposes.
- /get_active_brokers - Responsible for the retrieving brokers with status 'ALIVE'
- /create_topic - Responsible for creating topic
- /get_topic_by_name/string:topic_name - Responsible for retrieving the topic according to the name specified by the client.
- /create_partition - Responsible for creating partition
- /register_producer - Responsible for the registration of producers
- /update_broker - Responsible for updating the current node state and appending to 'change broker record' with an increment to epoch.
- /unregister_broker/string:broker_id - Responsible for changing the broker status to 'CLOSED' and delete the broker from the node. Note: Broker information can still be retrieved from metadata if required.
- /broker_mgmt/float:previous_offset - Responsible for fetching two different snapshots: i. Current State Snapshot - If timestamp offset is less than 10 minutes, retrieves the data present in the nodes ii. Complete State Snapshot - If timestamp offset is greater than 10 minutes, retrieves the state information from the metadata.
- /client_mgmt/float:previous_offset - Responsible for fetching two different snapshots: i. Current State Snapshot - If timestamp offset is less than 10 minutes, retrieves the data present in the nodes ii. Complete State Snapshot - If timestamp offset is greater than 10 minutes, retrieves strictly the topics, partitions, broker information.
Steps for initial node setup: python3 my_raft_node.py -i 1 -a 127.0.0.1:5010
python3 my_raft_node.py -i 2 -a 127.0.0.1:5020 -e 1/127.0.0.1:5010
python3 my_raft_node.py -i 3 -a 127.0.0.1:5030 -e 1/127.0.0.1:5010,2/127.0.0.1:5020
python3 my_raft_node.py -i 4 -a 127.0.0.1:5040 -e 1/127.0.0.1:5010,2/127.0.0.1:5020,3/127.0.0.1:5030
python3 my_raft_node.py -i 5 -a 127.0.0.1:5050 -e 1/127.0.0.1:5010,2/127.0.0.1:5020,3/127.0.0.1:5030,4/127.0.0.1:5040
To visualize leader election - kill leader node