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.
- 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
-
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
- Open current directory as a new Project in IntelliJ
- Right-click on the
src
folder and select Mark Directory as > Sources Root. - Build the project by selecting Build > Build Project from the menu.
- Build with Maven using below command
mvn clean package
- Start the Server: Open the
Server
file, then click▶️ on the top right. - Start the Client: Open the
Client
file, then click▶️ on the top right.- To perform a test run, specify
-test
flag in the argument. ClickCurrent File
when havingClient
open > select⋮
>Run with Parameters
> fill in argument
- To perform a test run, specify
- 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.
- Start the server
java -cp target/kvstore.jar Server
- Start the client
java -cp target/kvstore.jar Client [-test]
Interact with the KV store using the following protocol in the client's terminal:
PUT key value
GET key
DELETE key
- Default connection to RMI registry is using localhost
127.0.0.1
from port1099
to1103
.