Design and Develop the Zookeeper using Rocksdb and Google's BigTable.
MediumLet's simplify the problem. We are building a simplified in-memory version of Zookeeper. Zookeeper is a distributed coordination service. At its heart, it's a hierarchical key-value store (like a file system) that maintains configuration information, naming, providing distributed synchronization, and group services. Our simplified version will focus on the core functionalities:
- Data Model: A hierarchical namespace, much like a file system. Each node in the namespace is called a znode. Znodes can have data associated with them (a byte array).
- Session Management: Clients establish sessions with the Zookeeper service. Sessions have a timeout. If a client doesn't send heartbeats within the timeout, the session expires.
- Persistent and Ephemeral Nodes: Znodes can be persistent (they exist until explicitly deleted) or ephemeral (they are automatically deleted when the session that created them expires).
- Watches: Clients can set watches on znodes. A watch is a one-time trigger. When the znode changes (data changes, child nodes added/removed, or the znode itself is deleted), the watch is triggered, and the client is notified. The watch is then removed.
- Concurrency: Handle concurrent client requests safely.
This problem requires a robust object-oriented design that prioritizes maintainability, extensibility, and thread safety.
Requirements
Interview Simulation
Experience a realistic interview conversation. The interviewer will ask clarifying questions,and you'll reveal your understanding of the requirements.
Let's start by understanding the scope. What are the core functionalities this system needs to provide?
💡 Interview Tip
Identify the Actors (Who uses the system?) and their Use Cases (What are they trying to achieve?). Start with the 'Happy Path' scenarios.