Question: Help with the java code please! Distributed Algorithm ( 8 0 points ) This project is intended to give you a taste of building a

Help with the java code please!
Distributed Algorithm (80 points)
This project is intended to give you a taste of building a simple distributed algorithm
that distributes computation across multiple nodes. It includes a basic consensus algorithm to verify results. The focus here is on robustness and a clean, well-documented
implementation rather than security.
Requirements
In this section, partial credit is available if some requirements are met. Clear documentation and a functional demo are essential for partial credit. We cannot award points if we cannot run your project.
The system should consist of:
1. Client: Accepts a list of numbers and a delay value from the user and sends it to the leader for processing.
2. Leader: Divides the list into smaller portions, sends each portion to a different node, waits for results, and combines these to get the final sum. The leader also performs a simple consensus to verify results.
3. Nodes: Each node calculates the sum of its portion of the list, simulating computation time by sleeping for a given duration (e.g.,100ms to 500ms), then sends the
result back to the leader. More detailed requirements:
1.(3 points) The Leader can be started via a Gradle task; explain how to do this in
the README.
2.(3 points) The Client can be started via a Gradle task; explain how to do this in
the README.
3.(3 points) Each Node can be started via a Gradle task; explain how to do this in the
README. Important: there should be only one Node.java class, with all nodes
in the system being instances of this single class.
4.(3 points) Ensure at least 3 Nodes are connected to the Leader.
5.(3 points) If there are fewer than 3 Nodes in the network, the Leader should send
an error message to the Client and stop processing.
6.(3 points) Client Input: The client should ask the user to input a list of numbers
and a delay time, which it then sends to the leader. Example list: [1,2,3,4,5,...,15], delay: 50ms.7.(5 points) Single Sum Calculation: The leader should calculate the sum on
its own, adding X milliseconds delay to each iteration to simulate a time-consuming
calculation. For example, for the list [1,2,3,4] with a delay of 50ms, it would add:
1+2(sleep 50ms),3+3(sleep 50ms),6+4(sleep 50ms), resulting in a computation
time and final sum.
8.(5 points) Leader Divides List: The leader should divide the list into equal parts,
e.g., with 3 nodes: Node 1: [1,2,3,4,5] Node 2: [6,7,8,9,10] Node 3: [11,12,
13,14,15]
9. Distributed Sum Calculation:
(6 points) The leader sends each node a portion of the list along with the delay
specified by the client.
(7 points) This should be threaded so that nodes calculate in parallel, not
sequentially.
(5 points) Each node computes the sum of its portion, applying the delay
between each addition as the leader did.
(4 points) After receiving all partial sums from the nodes, the leader combines
these and calculates the total sum and time taken for distributed processing.
10.(4 points) Performance Comparison: The leader compares the time taken for
single sum processing with distributed processing and prints the result. If node
communication is not threaded, the distributed version will generally be slower.
Perform this comparison regardless of threading status, but note that threading is
likely to show distributed advantages, depending on the delay time chosen.
11.(5 points) Simulating Faulty Nodes: Nodes can simulate faults, in which case
they will calculate the sum of the given list incorrectly. Use a Gradle flag -pFault=1
to make a node perform an incorrect calculation.
12. Consensus Check for Result Verification:
a)(4 points) The leader sends each node the sum and list from another node
(e.g., shifting the list to the next node).
b)(3 points) Sending this information should also be threaded.
c)(4 points) Each node recalculates the sum (with or without delay) and compares
it with the sum received from the leader.
d)(4 points) Nodes return a true/false (or yes/no, or similar) response to the
leader to indicate agreement with the results. Nodes should always respond
"yes" if there are no faulty nodes in the network.
e)(5 points) If all nodes agree on the result, the leader sends the final sum and
computation times to the client. If consensus fails, the leader sends an error
message to the client.
13.(3 points) Client Output: The client displays the results clearly, showing the sum
and calculation times.
14. Error Handling: Ensure robust error handling, informative messaging, and no
program crashes. Up to 10% of points may be deducted for poor error handling.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!