A distributed casino application built using the MapReduce Framework, designed to execute computations across multiple machines. The project demonstrates core distributed systems concepts such as task distribution, parallel processing, inter-node communication, and result aggregation. The system distributes workloads among multiple worker nodes, enabling parallel execution and improved scalability compared to a traditional centralized approach. This project was developed as part of a Distributed Systems course on 6th Semester.
- Distributed execution across multiple PCs in the same LAN
- MapReduce-based processing architecture
- Parallel task execution using worker nodes
- Client-Master-Worker communication model
- Task scheduling and workload distribution
- Result aggregation through a Reduce phase
- Multi-threaded processing
- Scalable architecture supporting multiple workers
+-------------+
| Client |
+------+------+
|
v
+-------------+
| Master |
+------+------+
|
+---------------+---------------+
| | |
v v v
+-------------+ +-------------+ +-------------+
| Worker 1 | | Worker 2 | | Worker N |
+-------------+ +-------------+ +-------------+
| | |
+------- Map Processing --------+
|
v
+-------------+
| Reduce |
+-------------+
- Java
- Java Sockets
- Multithreading
- MapReduce Framework
- Simple XML-based User Interface
- The client submits a request to the system.
- The Master node receives and partitions the workload.
- Tasks are distributed among available Worker nodes.
- Workers execute Map operations in parallel.
- Intermediate results are returned to the Master.
- The Reduce phase aggregates all partial results.
- The final result is sent back to the client.
A key objective of this project was to provide high availability and fault tolerance within the distributed environment.
Each worker has a backup replica capable of taking over execution if the primary worker becomes unavailable.
This approach minimizes downtime and allows the system to continue processing requests without requiring manual intervention.
The Master node continuously monitors worker availability using a heartbeat mechanism.
At regular intervals:
- Workers send heartbeat messages to the Master.
- The Master verifies that workers are alive and responsive.
- Missing heartbeats indicate a potential worker failure.
- The Master automatically redirects tasks to the corresponding backup worker.
Worker A
│
│ Heartbeats
▼
Master
│
│ Worker Failure Detected
▼
Backup Worker A
│
▼
Continue Processing
- High Availability
- Fault Tolerance
- Automatic Failure Detection
- Reduced Service Downtime
- Continuous Task Execution
- Improved System Reliability
Before starting the system, ensure that all network configurations are properly set.
Update the config.json file with the appropriate IP addresses and ports for your environment.
{
"Master": {"first": "127.0.0.1", "second": 3333},
"Workers": [
{"first": "127.0.0.1", "second": 4001},
{"first": "127.0.0.1", "second": 4002},
{"first": "127.0.0.1", "second": 4003}
],
"RNG": {"first": "127.0.0.1", "second": 5000},
"Reducer": {"first": "127.0.0.1", "second": 6000},
"Secret": "your-secret-key",
"bufferSize": 100000
}| Component | Description |
|---|---|
| Master | Master node IP and port |
| Workers | List of available worker nodes |
| RNG | Random Number Generator service |
| Reducer | Reducer service |
| Secret | Shared secret used for secure communication |
| bufferSize | Socket communication buffer size |
For distributed deployment across multiple machines, replace the localhost (127.0.0.1) addresses with the actual IP address of each host.
The frontend must be configured to communicate with the Master node.
Navigate to:
src/main/java/com/example/taketwo_partb/network/InternalConfig.java
and update the backend IP address:
public class InternalConfig {
private static final String BackendIp = "192.168.X.X";
private static final int port = 3333;
public static String getBackendIp() {
return BackendIp;
}
public static int getPort() {
return port;
}
}BackendIpmust point to the machine running the Master node.portmust match the Master port defined inconfig.json.- When running all components locally,
127.0.0.1can be used. - When deploying across multiple PCs, use the actual LAN or public IP address of the Master machine.
| Component | IP Address | Port |
|---|---|---|
| Master | 192.168.1.10 | 3333 |
| Worker 1 | 192.168.1.11 | 4001 |
| Worker 2 | 192.168.1.12 | 4002 |
| Worker 3 | 192.168.1.13 | 4003 |
| RNG | 192.168.1.14 | 5000 |
| Reducer | 192.168.1.15 | 6000 |
The frontend should then use:
private static final String BackendIp = "192.168.1.10";to connect to the Master node.
The system consists of several distributed components that must be started in the following order:
java RNGProvides the random values required by the casino games.
java ReducerResponsible for aggregating intermediate results produced by worker nodes during the Reduce phase.
java WorkerLaunch one or more worker instances. Workers execute Map tasks assigned by the Master node.
Example:
java Worker
java Worker
java WorkerWorkers may run on separate machines to enable distributed execution.
java MasterThe Master coordinates the system by:
- Receiving requests
- Partitioning workloads
- Assigning tasks to workers
- Monitoring worker health
- Handling fault recovery
- Aggregating results
java ManagerConsoleThe Manager Console allows administrators to monitor the state of the distributed system and manage casino operations.
java PlayerPlayers connect to the distributed casino system and interact with the available games.
Master node assigning tasks to workers.
Worker-2 was intentionally shut down during execution. The Master detected the failure and automatically redirected requests to the backup worker, demonstrating Active Replication and fault-tolerant execution.
Casino application's user interface.