Skip to content

Multithreaded client-server application built with Java RMI that allows multiple clients perform concurrent operations on a cluster of five servers. Use 2 Phase Commit Protocol to ensure consistency across replicas.

Notifications You must be signed in to change notification settings

amyhuang95/multi-threaded-key-value-store-2PC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Multithreaded Key-Value Store using RPC and 2PC

Overview

This project demonstrates a multi-threaded client-server application built with Java RMI (Remote Method Invocation) that allows multiple clients to perform operations (GET/PUT/DELETE) on a cluster of 5 key-value replicas concurrently. It implements a two-phase commit (2PC) protocol to ensure consistency across the replicas during write operations.

Features

  • Remote Operations: Java RMI
  • Concurrency: Multi-threaded request processing with thread pool
  • Thread Safety: ConcurrentHashMap for thread-safe operations
  • Two-Phase Commit: Atomic operations to ensure consistency across replicas
  • Request Tracking: Request IDs to track communications
  • Logging: Comprehensive logging for each class in their own log files

Requirements

  • Java 17 or higher

  • Maven for dependency management

  • Dependencies (included in pom.xml):

    • Apache Commons CLI (1.9.0) - Command line argument parsing
    • Apache Commons Validator (1.7) - IP address validation

How to Build

With IntelliJ

  1. Open current directory as a new Project in IntelliJ
  2. Right-click on the src folder and select Mark Directory as > Sources Root.
  3. Build the project by selecting Build > Build Project from the menu.

With Terminal

  • Build with Maven using below command
    mvn clean package
    

How to Run

With IntelliJ

  1. Start the Server: Open the Server file, then click ▶️ on the top right.
  2. Start the Client: Open the Client file, then click ▶️ on the top right.
    • To perform a test run, specify -test flag in the argument. Click Current File when having Client open > select > Run with Parameters > fill in argument
  3. Inspect logs: Once the server and client are finished, log files for each class will be saved in the /log folder in the current directory.

With Terminal

  1. Start the server
    java -cp target/kvstore.jar Server
    
  2. Start the client
    java -cp target/kvstore.jar Client [-test]
    

Usage

Interact with the KV store using the following protocol in the client's terminal:

PUT key value
GET key
DELETE key

Other Notes

  • Default connection to RMI registry is using localhost 127.0.0.1 from port 1099 to 1103.

About

Multithreaded client-server application built with Java RMI that allows multiple clients perform concurrent operations on a cluster of five servers. Use 2 Phase Commit Protocol to ensure consistency across replicas.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages