Question: The idea is to build a very simplified distributed algorithm network to count letters in a sentences. We also include a little simplified consensus algorithm.

The idea is to build a very simplified distributed algorithm network to count letters in a sentences. We also include a little simplified consensus algorithm. This is all very simplified just to give you a taste, you do not have to worry about security etc. but you should make sure your program is robust and well implemented.
You will need different parts that can be started:
1. A Client: this is where the user interacts with the system.
2. A Leader: this is where the Client sends a user request, a leader can be connected to many nodes.
3. Nodes: all nodes have the same code, many nodes are connected to one leader.
The basic idea is that the user can input a string (a sentence or word) and a charac- ter (a string with just one letter) into the terminal of the Client and this string and character will be sent as request to the Leader. The Leader will split up the string as stringlength/nodesInNetwork (or as best as possible). The Leader will send a part of each sentence to a node to count the occurrence of the character that was also provided by the client. How you count does not matter (you can of course use sources to find an algorithm - make sure you reference it though). Each Node uses the same algorithm, each Node has the same code (so each Node is started through the same Gradle task and uses the exact same class). The Node will send their answer (number) back to the Leader. The Leader will then do a check to make sure no Node is faulty. To do so the Leader will send over a count number and the corresponding sentence part to another Node (to a different one than the one that initially counted) and the node needs to check if the count matches the sentence. Each node will return a yes/no if it thinks the count is valid. Only when all nodes return "yes" will the Leader put the overall count together and return it to the client.
See below for the requirements split up in more detail.
1. Leader can be started through a Gradle task, describe how in Readme
2. Client can be started through a Gradle task, describe how in Readme
3. Nodes can be started through a Gradle task, describe how in Readme
4. At least 3 Nodes should be connected to the Leader
5. Counting should not work with less than 3 Nodes, Leader should just send an error message to the Client if there are less than 3 Nodes in the network. You can handle more Nodes but do not have to
6. ClientconnectstoLeader,theLeaderwillthenasktheClientforasentence and a character. The Client needs to display the question from the Leader and allow the user to enter a sentence and character. The sentence and character is then sent to the Leader
7.The sentence received is split up by the Leader based on the number of Nodes. If the sentence cannot be split up evenly then split it up as best as possible
8. Leader sends each connected Node a part of the sentence (each Node gets a different part)
9. Leader should send it threaded so that the Nodes work in parallel on the counting (imagine it is a really complicated counting that takes a long time - in your case it is not complicated of course)
10. Node receives their part of the sentence and runs some counting algorithm
11. Node sends the count back to Leader
12. Leader receives the count of each Node
13. Leader starts a consensus for double checking the result
a) Leader sends each Node a count and the corresponding sentence part (make sure it is not the same as the Node initially had - you can just shift to the next node)
b) This sending also happens in threads
c) Node counts the string it gets and matches against the count it received. If it matches it sends back an ok (or yes) otherwise a no.
d) Nodes can be faulty: with a Gradle flag -pFault=1, force a Node to count wrong, thus during this check no consensus is reached if a faulty Node is in the network.
e) The Leader receives the answers, only when all vote "yes" will the count be put together and the answer sent to the Client. The Client should display the count.
f) If one Node votes "no" then you can just return an error to the Client
14. Overall good error handling, no crashing, and users are informed of what is going on. This should go without saying. We might deduct up to 10% if this is bad.

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!