This project implements an intelligent energy management system for a group of houses (residential complex) using a distributed network architecture. The system is composed of three main components:
A gRPC server built using Jersey, responsible for managing the entire complex. It exposes endpoints that allow:
- Adding or removing houses from the network.
- Collecting energy consumption measurements.
- Providing various services to monitor the overall status of the complex.
A terminal-based user interface (TUI) client that interacts with the AdminServer. It allows users to:
- View the current number of houses in the network.
- Retrieve the last
xenergy measurements for a specific house or the entire complex. - Display statistical data on the complex's energy consumption.
Represents a single house in the system, connected to other houses via sockets, forming a Peer-to-Peer (P2P) network. Each house:
- Periodically generates energy consumption data.
- Shares this data with the network. The network coordinator, which is the house with the highest ID, is responsible for sending the aggregated data to the AdminServer, ensuring data uniqueness and efficiency.
All the JSON exchanged between nodes has been serialized and deserialized using the Google Gson library.
A house can request a temporary energy boost for a short period. The Ricart-Agrawala algorithm is implemented in the P2P network to ensure that only one house can use the energy boost at a time, preventing conflicts and ensuring fairness.
This project was developed as part of the "Distributed Systems" course at the University of Milan. As per educational requirements, concurrency is handled using low-level Java constructs like wait and notify. In a production environment, it would be advisable to utilize classes and methods from the java.util.concurrent package for better scalability and maintainability.
Here's some sequence diagrams that explain interaction between network components:





