Implement a distributed file replication system. Assuming no transport failure. More information on the problem here.
System requirements:
- Java 10 or higher
- JDK 10 or higher
- JRE 1.8 or higher
- Maven
- Windows 10 and/or Ubuntu LTS 18.4 (tested)
Files requirements:
- Each server's directory that stores the files to be written to by the Clients must be in this format:
File#.txt
(i.e.File1.txt
,File2.txt
, etc.) as samples here
- Run the following command from the root directory:
mvn clean install -U
mvn package
- A jar file should be generated under
Server/target/
andClient/target
directories
- Start multiple instances of Server either from IDE or by running command
java -jar Name.jar
whereName
is the rest of the jar file name in theServer/target/
directory, then populate all necessary fields on them as prompted, but DO NOT choose to start any instance until all server instances are ready to be activated - Activate (choose start) all Server instances at the same time
- Start multiple instances of Client either from IDE or by running command
java -jar Name.jar
whereName
is the rest of the jar file name in theClient/target/
directory, populate all necessary fields on them as prompted, but DO NOT choose to start any instance until all server instances are ready to be activated - Activate (choose start) all Client instances at the same time
- Create configuration file for each
Server
instance following this format with: line 1 as the file directory; line 2 as server's IP name, address, and port number; line 3 as list of other servers' names, IP addresses, and ports separated by pipe - Create configuration file for each
Client
instance following this format with: line 1 as the client name; line 2 as list of other servers' names, IP addresses, and ports separated by pipe - Run
java -jar Name.jar Path
whereName
is the rest of the jar file name in theServer/target/
directory andPath
is the full path to the server's configuration file created above at the same time - Run
java -jar Name.jar Path
whereName
is the rest of the jar file name in theClient/target/
directory andPath
is the full path to the client's configuration file created above at the same time
A set of automated PowerShell scripts are provided to automatically run all servers and clients on a local machine to test. Follow these steps to run:
- Go to Scripts directory using PowerShell
- Run
./Build-Local.ps1
to build the entire project - Run
./Start-Local-Server.ps1
to start all (3) server instances - Run
./Start-Local-Client.ps1
to start all (5) client instances
For UNIX-related system, run the corresponding .sh
scripts instead. Note that you may need to reformat those files to make them UNIX-compatible using the below command:
sudo apt install dos2unix
dos2unix *.sh