As part of SC4051: Distributed System requirement, we have implemented a distributed facility booking application with client-server architecture that allows users to book facilities and manage bookings. The system implements reliable communication using UDP sockets with different message delivery guarantees.
The project consists of two main components:
- Client: A Python application that provides a command-line interface for users to interact with the booking system
- Server: A Java application that manages the facility booking service, handles requests, and maintains the state of facilities and bookings
facility-booking-system/
├── client/ # Python client application
│ ├── src/ # Source code for the client
│ │ ├── comm/ # Communication modules
│ │ ├── tests/ # Client tests
│ │ └── utils/ # Utility modules
│ ├── main.py # Client entry point for automated testing
│ ├── service.py # Main client application
│ └── requirements.txt # Python dependencies
├── dspserver/ # Java server application
│ ├── src/ # Source code for the server
│ │ ├── main/ # Main server code
│ │ └── test/ # Server tests
│ ├── pom.xml # Maven dependencies
│ └── logback.xml # Logging configuration
├── interface.json # Interface definition shared between client and server
├── services.json # Service definition shared between client and server
├── runclient.sh # Script to run the client
└── runserver.sh # Script to run the server
- Facility Management: Create and manage different types of facilities
- Availability Listing: Query available time slots for facilities
- Booking Management: Book, edit, extend, and cancel facility bookings
- Callback Notifications: Register for notifications about facility availability changes
- Reliable Communication: Two socket types with different delivery guarantees:
- At-Least-Once: Ensures messages are delivered at least once, even if there are network issues
- At-Most-Once: Ensures messages are processed exactly once, preventing duplicate processing
- Custom Communication Protocol: Implements a custom binary protocol for client-server communication
- Socket Type Switching: Dynamically switch between delivery semantics during operation
- List Availability: Query available time slots for a facility on specific days
- Book Facility: Book a facility for a specific time slot
- Edit Booking: Change the timing of an existing booking
- Register Callback: Register to receive notifications about facility availability changes
- Cancel Booking: Cancel an existing booking
- Extend Booking: Extend the duration of an existing booking
- Switch Socket Type: Change between At-Least-Once and At-Most-Once delivery semantics
- Python 3.10 or higher
- Virtual environment (recommended)
- Java 17 or higher
- Maven
-
Navigate to the server directory:
cd dspserver -
Build the server using Maven:
mvn clean package -
Run the server:
java -jar target/dspserver-1.0-SNAPSHOT.jarAlternatively, use the provided script:
./runserver.sh
-
Navigate to the client directory:
cd client -
Create and activate a virtual environment:
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt -
Run the client:
python service.pyAlternatively, use the provided script:
./runclient.sh
The system uses a custom binary protocol for client-server communication defined in interface.json and services.json. This protocol includes:
- Request/Response Messages: Each service has defined request and response formats
- Error Handling: Error messages with descriptive text
- Acknowledgments: ACK messages for confirming receipt in at-most-once delivery
The server initializes with the following facilities:
- Gym
- Pool
- Spa
- Event Hall
- Lounge
cd client
python -m unittest discover ./
cd dspserver
mvn test
- Ensures that messages are delivered at least once to the recipient
- May result in duplicate message delivery
- Suitable for operations where processing the same message multiple times is acceptable
- Ensures that messages are delivered at most once to the recipient
- Prevents duplicate message processing
- Uses acknowledgments to confirm message receipt
- Suitable for operations where duplicate processing must be avoided