This project aims to put into practice various communication concepts and patterns found in today's distributed systems.
This project is divided into 2 parts, one being the server and the other the client, the client component must make requests to the server through network protocols (TCP) and the server responds to the requests.
Since this project is divided into two completely different components, the dependencies will vary, but the technologies used for the development of both are the same.
In order for the program to work correctly, you first have to set the environment variables as follows:
Java is a widely used programming language known for its versatility, portability, and robustness.
Java is an object-oriented programming language, which means it emphasizes the concept of objects and classes. It provides a rich set of APIs (Application Programming Interfaces) that developers can use to build a wide range of applications, from desktop software to web applications and mobile apps.
-
Download and install JDK 17 for Windows from the official Oracle website.
-
Once the installation is complete, open the Start Menu and search for "Environment Variables".
-
Click on the "Edit the system environment variables" option. This will open the System Properties window.
-
In the System Properties window, click on the "Environment Variables" button at the bottom.
-
In the Environment Variables window, under the "System variables" section, click on the "New" button.
-
Set the following values for the new environment variable:
- Variable name:
JAVA_HOME
- Variable value: The installation path of JDK 17 (e.g.,
C:\Program Files\Java\jdk-17
)
- Variable name:
-
Click "OK" to save the environment variable.
-
In the Environment Variables window, under the "System variables" section, scroll down to find the "Path" variable and click on the "Edit" button.
-
In the Edit Environment Variable window, click on the "New" button and add the following value:
%JAVA_HOME%\bin
-
Click "OK" to save the changes.
-
Open a new command prompt window and type
java -version
. It should display the Java version as JDK 17.
You could use the repositories from your distro (OpenJDK) or installing a package from the Oracle website.
Repository:
sudo apt install openjdk-17-jdk
Oracle website:
-
Download and install JDK 17 for Linux from the official Oracle website.
-
Once the installation is complete, open a terminal.
-
Open the .bashrc file in a text editor using the following command:
nano ~/.bashrc
- At the end of the file, add the following line:
export JAVA_HOME=/usr/lib/jvm/jdk-17
Replace /usr/lib/jvm/jdk-17
with the actual installation path of JDK 17.
-
Save the file by pressing Ctrl + O, then press Enter. Exit the text editor by pressing Ctrl + X.
-
In the terminal, run the following command to apply the changes:
source ~/.bashrc
- Type
java --version
in the terminal. It should display the Java version as JDK 17.
Maven is a build automation and project management tool for Java-based projects. It provides a comprehensive set of features and conventions to help streamline the development process and simplify project management.
Maven simplifies dependency management by automatically resolving and downloading project dependencies from remote repositories. It also supports dependency version management to ensure consistent and predictable builds.
-
Download Maven from the official website.
-
Extract the downloaded zip file to a directory of your choice (e.g.,
C:\Program Files\Maven
). -
Open the Start Menu and search for "Environment Variables".
-
Click on the "Edit the system environment variables" option.
-
In the System Properties window, click on the "Environment Variables" button at the bottom.
-
Add a new system variable with the following values:
- Variable name:
M2_HOME
- Variable value: The path to the Maven installation directory (e.g.,
C:\Program Files\Maven
).
- Variable name:
-
Edit the "Path" variable and add
%M2_HOME%\bin
to the list of paths. -
Open a new command prompt window and type
mvn -version
to verify the installation.
- Install Maven using the package manager of your Linux distribution.
sudo apt install maven
- Open a terminal and verify the installation.
mvn -version
MySQL is an open-source relational database management system (RDBMS) that is widely used for storing and managing structured data. It provides a reliable, scalable, and efficient solution for managing databases in various applications.
MySQL offers features such as replication, which enables data to be replicated across multiple database servers for improved scalability and high availability. It also provides robust security measures, including user authentication, encryption, and access control, to protect sensitive data.
-
Download the MySQL Installer for Windows from the official website.
-
Run the downloaded installer and follow the on-screen instructions.
- Select "Developer Default" or "Custom" installation type.
-
Set a root password for the MySQL server during the installation.
- You will be prompted to set a root password for the MySQL server. Choose a strong password and remember it.
-
Open a command prompt or MySQL Command Line Client and type
mysql -V
to verify the installation.
-
Open a terminal.
-
Run the command
sudo apt update
to update the package lists. -
Install the MySQL server package by running
sudo apt install mysql-server
. -
Set a root password for the MySQL server during the installation.
-
Open a terminal and type
mysql -V
to verify the installation.
For the development of this service a bidirectional replication scheme was implemented, based on the model (MASTER-SLAVE), where both databases are slaves and masters at the same time, which allows that any change made in any of the two instances will be reflected in the other, MYSQL offers this replication option, it is only necessary to configure the instances.
- Open the MySQL configuration file on the source server. The path to this file varies depending on the operating system:
Windows: C:\ProgramData\MySQL\MySQL Server x.x\my.ini Linux: /etc/mysql/mysql.conf.d/mysqld.cnf
-
Locate the [mysqld] section inside the configuration file.
-
Add the following lines to enable binary logging and set a unique server ID:
log-bin=mysql-bin
server-id=1
-
Save the configuration file and restart the MySQL service.
-
Log in to the Master DB and create a user with replication privileges:
CREATE USER 'replication_user'@'%' IDENTIFIED BY 'password';
GRANT REPLICATION SLAVE ON *.* TO 'replication_user'@'%';
FLUSH PRIVILEGES;
- Run the following SQL command to retrieve the binary log coordinates:
SHOW MASTER STATUS;
Note down the values of the File and Position columns, as we'll need them in the next step.
- On the Slave DB, open the configuration file and add the following lines in the [mysqld] section:
log-bin=mysql-bin
server-id=2
-
Save the configuration file and restart the MySQL service.
-
Access the slave DB and run the following command to configure replication:
CHANGE MASTER TO
MASTER_HOST='serverA_IP',
MASTER_USER='replication_user',
MASTER_PASSWORD='password',
MASTER_LOG_FILE='mysql-bin.XXXXXX',
MASTER_LOG_POS=XXXXXX;
SOURCE_SSL=1;
Put the values from the step 4
- Starts replication on slave DB:
START SLAVE;
- Repeat steps 2 and 3, reversing the roles of the Master and Slave DB's. Now Slave will become the master and Master will be the Slave.
With the above steps a bidirectional replication will be obtained.
Check the readme inside the client folder of the project.
Check the readme inside the server folder of the project.