This project is a multi-module Spring Boot application demonstrating various aspects of distributed systems, including service discovery, configuration management, distributed logging, and distributed data storage.
The project consists of the following modules:
- config-server: Configuration server for the distributed system
- facade-service: Frontend service that interfaces with other services
- logging-service: Service for centralized logging
- message-service: Service for message handling
- hz-cluster: Hazelcast cluster configuration for distributed data storage
- Java 17
- Maven 3.6+
-
Clone the repository:
git clone <repository-url> cd distributed-systems-lab
-
Build the project:
mvn clean install
The easiest way to launch all services at once is using Docker Compose:
-
Build the project first:
mvn clean install
-
Start all services using Docker Compose:
docker-compose up -d
-
Verify that all services are running:
docker-compose ps
-
To view logs from all services:
docker-compose logs
Or for a specific service:
docker-compose logs <service-name>
Example:
docker-compose logs facade-service
-
To stop all services:
docker-compose down
Once all services are running, you can test the functionality using the following endpoints:
-
Send a message:
curl -X POST -H "Content-Type: text/plain" -d "Hello, Distributed World!" http://localhost:8080/message
-
Retrieve all messages:
curl http://localhost:8080/messages
Alternatively, you can start each service manually in the following order:
-
Start the config-server:
cd config-server mvn spring-boot:run
-
Start the hz-cluster:
cd hz-cluster mvn spring-boot:run
-
Start the logging-service:
cd logging-service mvn spring-boot:run
-
Start the message-service:
cd message-service mvn spring-boot:run
-
Start the facade-service:
cd facade-service mvn spring-boot:run
To run all tests:
mvn test
To run tests for a specific module:
mvn test -pl <module-name>
Example:
mvn test -pl logging-service
To run a specific test class:
mvn test -pl <module-name> -Dtest=<TestClassName>
Example:
mvn test -pl logging-service -Dtest=LoggingServiceTest
The project includes the following tests:
-
config-server: Tests for the configuration server
- ConfigControllerTest: Tests the configuration controller
-
facade-service: Tests for the facade service
- FacadeControllerTest: Tests the facade controller
-
logging-service: Tests for the logging service
- LoggingServiceTest: Tests the REST logging service
- GrpcLoggingServiceTest: Tests the gRPC logging service
-
message-service: Tests for the message service
- MessageServiceTest: Tests the message service
-
hz-cluster: Tests for the Hazelcast cluster
- HzClientServiceTest: Tests the Hazelcast client service
- HazelcastConfigTest: Tests the Hazelcast configuration
- POST
/message
: Sends a message to the logging service - GET
/messages
: Retrieves all messages from the logging and message services
- GET
/messages
: Retrieves all messages from the logging service
- GET
/messages
: Retrieves a static message (not implemented yet)
- GET
/hz-test
: Tests the Hazelcast cluster with a simple counter - GET
/hz-test-pesim
: Tests the Hazelcast cluster with pessimistic locking - GET
/hz-test-optimistic
: Tests the Hazelcast cluster with optimistic locking
The project demonstrates a microservices architecture with the following components:
- Service Discovery: The config-server provides service discovery for other services.
- API Gateway: The facade-service acts as an API gateway, routing requests to appropriate services.
- Distributed Logging: The logging-service provides centralized logging for all services.
- Distributed Data Storage: The hz-cluster provides distributed data storage using Hazelcast.
- Circuit Breaking: The facade-service implements circuit breaking using Resilience4j.
- Spring Boot
- Hazelcast
- gRPC
- Resilience4j
- JUnit 5
- Mockito