Intuting
  • Untitled
  • Algorithm Interviews
    • Common Manager
    • Least # of Activities
    • Real Estate Agent
    • Palindrome Pairs
    • Mirror Tree
    • Ship Cargo in 5 Days
  • Coding Interviews
    • Linux "Find" Command
    • Amazon Locker Service
    • Cache Analysis Service
    • Zookeeper Service
  • System Design Interviews
    • Event Reservation System
Powered by GitBook
On this page

Was this helpful?

  1. Coding Interviews

Zookeeper Service

#Airbnb #Onsite #Coding

PreviousCache Analysis ServiceNextEvent Reservation System

Last updated 5 years ago

Was this helpful?

Question

is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. Implement the simple version of Zookeeper interface:

public class ZooKeeperService {

    // Create a new zNode with the given path & value. Throw
    // InvalidArgument exception if the parents node do not exist.
    // E.g., path: '/a/b/c', zNode 'a' and 'b' must already exist. 
    void create(String path, int value);

    // Set the given value to the zNode at the given path. Throw 
    // InvalidArgument exception if a zNode does not exist at 
    // the given path. 
    void set(String path, int value);

    // Get the value of the zNode at the given path. Throw 
    // InvalidArgument exception if a zNode does not exist at the
    // given path. 
    int get(String path);

    // Register callback to call when they are any changes under
    // the given path. Throw InvalidArgument exception if a zNode
    // does not exist at the given path. 
    void watch(String path, Callback<Node, Void> callback);
}

ZooKeeper