DS_341_Assignment_3V1.pdf

Parallel Computing and Distributed Systems - Assignment 3 (15 points)

MQTT and JSON are libraries and are also known as dependencies. Maven is a way to build java projects while automatically handling these dependencies - check the video attached to the assignment folder first. The video shows the steps to create a Maven project over Eclipse, and similar steps are used to create a Maven project over other Java IDEs. Feel free to use more different online resources to read about Maven projects and to create simple java projects with it.

In this assignment, you will use the MQTT (Message Queuing Telemetry Transport) protocol -we discussed in Unit 4- to implement a distributed application using the Java IDE you find appropriate.

Setting up the Environment: you need to include the MQTT library. o The first option: use Maven project option and include the following dependency

<dependency> <groupId>org.eclipse.paho</groupId> <artifactId>org.eclipse.paho.client.mqttv3</artifactId> <version>1.1.0</version>

</dependency>

o The second option: search online for MQTT client library you find appropriate and import the corresponding JAR files

System Units: o You will design and develop a number of individual MQTT clients to run in parallel o You will use a global/public MQTT broker that facilities the communication (no need to import a local broker or

implement a broker). There are a few global/public MQTT brokers online; it is recommended to use the MQTT broker discussed in the video (https://www.hivemq.com/public-mqtt-broker/), but you may also use another public MQTT broker.

Task Description: The system you will develop is composed of 3 MQTT clients (two are automated A and B, and one is user-operated) and an MQTT broker.

Client A: o Has a local dynamic array (Arraylist) and a Hash map o Subscribes to topic: /DS341/TaskTo/<yourLastName>/ClientA o Recevies the task then performs the required work o Publishes the result on topic: /DS341/ResultsFrom/<yourLastName>/ClientA

Client B: o Holds a local dynamic array (Arraylist) and a Hash map o Subscribes to topic: /DS341/TaskTo/<yourLastName>/ClientB o Receives the task then performs the required work o Publishes the result on topic: /DS341/ResultsFrom/<yourLastName>/ClientB

Client You: o Subscribes to topic: /DS341/ResultsFrom/<yourLastName>/# o The user, through the terminal, can type one of the commands shown in the table below o The user, through the terminal, can select one of the clients (A or B) or both of them (#) to target o Publishes the command accordingly on topic: /DS341/TaskTo/<yourLastName>/<clientName> o Displays the result(s) to the user in an appropriate format.

Client Supported Commands Description

Add: x where x can be any integer values (e.g., Add: 74)

o The target client adds the input value to its array o Responds, through publish, with “added successfully” o Stores the received command in the Hash Map as a value, where the key can be

incremented per command

Remove: x where x can be any integer values (e.g., Remove: 74)

o The target client removes the input value to its array o Responds, through publish, with “removed successfully” o Stores the received command in the Hash Map as a value, where the key can be

incremented per command

Get_Summation o The target client calculates the summation value to its array o Responds, through publish, with “The summation is x” - where x is the summation of

all values in the list. If empty list or all elements are zeros, x in the message equals null

o Stores the received command in the Hash Map as a value, where the key can be incremented per command

Review_Old_Commands o The target client accesses its Hash Map o Responds, through publish, with a concatenated version of the received commands so

far (e.g., [Add: 15, Remove: 17, Get_Summation, Add: 13]) in a nice format.

**Note: for this system to work, you must run Client A and B first, then Client You.

**Make sure to give a unique name for each Client (e.g., attach your last name to the client’s ID)

Submission: 1. Submit the following files directly to the folder titled Assignment 2 under the D2L Assignments tab (don’t submit a zip

file holding them): a. The developed/updated client A and B Java files b. The developed/updated client You Java file(s) c. PDF file with clear screenshots for the terminal of client You showing the different commands and the

reactions/responses..

2. Check the due date on D2L. You can submit your assignment within 24 hours after this due date to be graded out of 50% of the assignment’s grade. After this grace period, your late submission will not be accepted.

3. This is an individual assignment -- Cheating/plagiarism will be checked and will receive zero.