Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA You will be creating two classes: Node and Head. The Head will setup the ServerSocket and the Nodes will call the Head. I want

JAVA

You will be creating two classes: Node and Head. The Head will setup the ServerSocket and the Nodes will call the Head.

I want this done in two phases. Phase one is to have all the Nodes connect to the Head, but not to issue any work to the Nodes until all of them have connected. The Head won't know where the Nodes are connecting from, but it will know exactly how many Nodes it is expecting. The Nodes, of course, need to know the location/port of the Head.

Once all the Nodes have connected, the Head should then divide up the work and tell each of the Node what it is to do. The Nodes should receive this information, do the work, and send back a result. The Head will keep the socket open with each Node until it receives the result back.

Again, just like the last few labs, we will be doing prime finding as the work. A range of 1000 - 1000000 works well for this lab.

Note that once all the Nodes have connected, you then need to tell all the Nodes to do work. You can start out doing this one at a time in serial. That is, tell the first one to do some range, then wait for its result. Then tell the next one to do some range, then wait for its result. Etc. However, eventually you will want to do this in parallel. Thus, you Head will need to have Threads running to handle the passing out of work. Don't forget about potential race conditions. You can make a method in Java synchronized and only one thread will be able to run it at a time. This is a similar concept to C++ mutex locks.

In order to run your code, you will start the Head node. Then you will start as many Nodes as you setup in your Head. Note that print statements showing connection and range status will be quite useful in debugging your code.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

The company has fair promotion/advancement policies.

Answered: 1 week ago