How shihuili1218/klein works
Project type and purpose
• Klein is not a web or mobile app but a modular, Java-based, distributed tool library implementing consistent data structures (Cache, Lock, Map, List, Queue) on top of Paxos consensus. It provides pluggable subsystems (RPC, Serialization, Consensus, Storage) to replace middleware like Redis or messaging queues.
• The README confirms Klein’s goal: “a distributed collection tool library based on Paxos... keep data consistent across members without relying on any middleware.”
File structure
• Top-level pom.xml, plus Maven modules under the root:
• klein-common: shared utilities (Disruptor, timers, threading, exceptions).
• klein-spi: extension-point loader (Java SPI).
• klein-core: public API (Klein.startup(), createCache(), createLock(), KleinProp) and runtime orchestration.
• klein-rpc-facade & klein-rpc-grpc: RPC interface and gRPC implementation.
• klein-consensus-facade & klein-consensus-paxos: consensus interface and Paxos implementation.
• klein-serializer-facade & bindings (hessian2, protobuf): serialization interface and implementations.
• klein-storage-facade & implementations (file, H2): storage interface (log, snapshot) and back ends.
• klein-example: sample applications illustrating usage.
• klein-jepsen: Jepsen test harness with Docker configurations.
• Configuration files: checkstyle.xml, .github/workflows, Docker templates, Maven POMs.
README for additional insights
• Quick Start shows how client code interacts with Klein API, how to set properties via System.setProperty or KleinProp.
Elements
• Clear labels for each Maven module or runtime component
• From Client → Core → SPI → each Facade
• From Consensus → RPC → Network
• From Consensus → Storage
• From RPC → Serializer
• Facade interfaces in another
• Implementations (gRPC, Paxos, Hessian2, File/H2) in a third
• External network/peers in a different style
– “RPC Facade”
– “Consensus Facade”
– “Serializer Facade”
– “Storage Facade”
– RPC Facade → “gRPC Impl”
– Consensus Facade → “Paxos Impl”
– Serializer Facade → “Hessian2 / Protobuf Impl”
– Storage Facade → “File / H2 Storage Impl”
8) Optionally, include a bottom area for “Jepsen Test Harness” interacting with multiple Dockerized Klein nodes.