Create the compute-task object

Assignment Help Programming Languages
Reference no: EM133189682

Part 1: Java TCP Streaming, Multi-threading and Object Serialization Programming

The framework consists of a Master (i.e. server), a number of Workers (i.e. clients) and a Class Repository in the Master. The framework is depicted in the following diagram. The framework is a generic computing architecture because the Master and Workers just need to know/follow the interaction contract only so that they can interact with each other via the framework. The specification of the interaction contract is as follows.

1. The interaction contract

The interaction contract between a Worker and the Master consists of:

a. The Task interface defines two standard methods that every compute-task must implements.

package Contract; public interface Task {
public void executeTask(); public Object getResult();
}

b. The TaskList class is a container that holds the titles and the class names of available compute-tasks.

package Contract;
import java.io.Serializable;
public class TaskList implements Serializable{ private String AvailableTasks[];
private String TaskClassName[];

public String[] getAvailableTasks() { return AvailableTasks;
}
public void setAvailableTasks(String[] AvailableTasks) { this.AvailableTasks = AvailableTasks;
}
public String[] getTaskClassName() { return TaskClassName;
}
public void setTaskClassName(String[] TaskClassName) { this.TaskClassName = TaskClassName;
}
}
c. The TaskObject class is a container that holds a particular compute-task object, its ID and credit.

package Contract;
import java.io.Serializable;
public class TaskObject implements Serializable{ private Integer TaskID=0;
private Integer Credit=0; private Task TObject=null; public TaskObject() {
}
public Integer getTaskID() { return TaskID;
}
public void setTaskID(Integer TaskID) { this.TaskID = TaskID;
}
public Integer getCredit() { return Credit;
}
public void setCredit(Integer Credit) { this.Credit = Credit;
}
public Task getTObject() { return TObject;
}
public void setTObject(Task TObject) { this.TObject = TObject;
}
}

The above interface and classes form a complete interaction contract between the Master and Workers.

2. The compute-task

The Master has a class repository that holds the Java classes of available compute-tasks. A compute-task must implement the Task interface. Executing the executeTask() method will perform the task and set the result. Calling the getResult() method will return the result. A compute-task must implement java.io.Serializable interface so that the compute-task can be transferred between the Master and a worker over the network. The structure of a compute-class is as follows.

public class CalculatePi implements Task, Serializable{
...... @Override
public void executeTask() {
//The implementation of method

......
}
@Override
public Object getResult() {
//The implementation of method
......
}
//may have other methods
......
}

3. The interaction workflow of the framework

A Worker provides a user frontend to access the remote Master. A Worker just needs to follow the interaction contract only for volunteer computing. The interaction workflow between Worker and Mater includes:

a. Workers connect to the Master

b. Workers download the available task list from the Master

c. Workers download some tasks from the Master

d. Workers perform the tasks

e. Workers upload computing results to the Master.

The demonstration of interaction workflow between Workers and the Mater is in the demonstration document on the unit Moodle site.

4. The implementation

To complete this assignment, you need to implement such a framework and integrate the Calculate Pi, Calculate Primes and Calculate the Greatest Common Divisor tasks into this framework. The algorithms of the tasks are given on the unit web site. The Master must be multi-threaded and follow the ‘thread-per-connection' architecture (reference Week-4 contents). The communication between the Master and Workers must use TCP streaming by using Java TCP API Socket and ServerSocket as described in Week-2 contents of this unit. Note: use of any other networking protocols will incur no marks to be awarded for this part.

To implement the framework, you need to implement the following Java classes:

a. A Java application to implement the Worker; a graphic user interface is required;

b. A Java application to implement the Master; and

c. A number of Java classes to implement the processing threads when necessary.

d. Note: to demonstrate your competence in concurrency programming, you will need to make an analysis on when concurrency is needed. Marks will be deducted if concurrency is not identified or necessary multithreading is not used.

e. A number of Java classes to implement Calculate Pi, Calculate Primes and Calculate the Greatest Common Divisor tasks.

Note: to simulate Master and Worker interaction, you don't have to run them on two physical machines. Instead, they can be run on two JVMs (Java Virtual Machines) on a single physical machine. As a result, the name of the Master machine can be ‘localhost'.

Part 2: Program use and test instruction

After the implementation of the framework, prepare an end user' instruction about how to use your software. The instruction should cover all aspects of the framework as detailed in the Part 2 of marking criteria below.

Submission

You need to provide the following files in your submission.

1. Files of Java source code of the Master, the Worker and the processing threads and the compute-tasks. The in-line comments on the data structure and program structure in the programs are required. The source code files must be able to be compiled by the standard JDK (Java Development Kit) or NetBeans IDE from Oracle.

2. The compiled Java class files of the source code. The Java classes must be runnable on the standard Java Runtime Environment (JRE) from Oracle.

Note: an easy way to provide the source code and executables is to submit them in a NetBeans project.

3. A Microsoft Word document to address the issues as specified in Part 2 above.

Function Demonstration of the Master

1. The compute-task repository on the Master

The Master has a class repository that holds the Java classes of available compute-tasks. The following screenshot shows that 3 compute-tasks CalculatePi.class, CalculatePrime.class and CalculateGCD.class (Greatest Common Divisor) along with the Task interface, the TaskList class and TaskObject class are saved in the class repository.

2. The interaction workflow of the framework

The following screenshot shows that when the Master starts, it is listening on two ports for object or file transfer.

A Worker provides a user frontend to access the remote Master. A Worker just needs to follow the interaction contract only for volunteer computing. The following screenshots show the contract directory in a Worker and the start of the Worker.

On the Worker frontend as shown in the following screenshot, clicking the Set button will establish two TCP connections to the Master on the given ports, one for object transfer and the other for file transfer, and enable the Refresh button.

Clicking the Refresh button, the worker will send an empty TaskList object to the Master and receive the same TaskList object back with the available compute-tasks that is filled by the Master. After that, the Calculate button is enabled and the Worker is ready to ask for a compute-task to calculate.

Selecting a task e.g. ‘Calculating Pi to 70 decimal digits' and clicking the Calculate button, the following interaction will happen between the Worker and the Master.

1. The Worker downloads the class file of the selected compute-task (e.g. CalculatePi.class) from the Master
Note: the downloading is automated by the Worker, not manually by a user.

2. The worker creates a TaskObject and sets the selected task ID on the TaskObject and then sends the TaskObject to the Master.

3. The Master receives the TaskObject, creates the compute-task object (e.g.
CalculatePi) according to the compute-task ID.

4. The Master sets the compute-task object on the TaskObject and sends the TaskObject to the Worker.

5. The Worker receives the TaskObject and gets the compute-task (e.g. CalculatePi) from the TaskObject.

6. The compute-task object (e.g. CalculatePi) is cast (be deserialized) into the Task interface type and its executeTask() is called.

7. The Worker sends the same TaskObject to the Master, which includes the computing results now.

8. The Master receives the TaskObject and retrieves the results.

9. The Master sets a credit on the TaskObject and sends it to the Worker.

10. The Worker receives the TaskObject and retrieves the awarded credit.

Attachment:- Function_Demonstration.rar

Reference no: EM133189682

Questions Cloud

Are all restrictions on the freedom of speech unjustified : Are all restrictions on the freedom of speech on college campuses morally unjustified? If yes, explain why you think that to be the case
Assignment - Topic - Wanna Cry ransom ware assault : Criminology Essay Assignment - write a paper that considers a criminological theory on why the perpetrator(s) committed the crime(s) they did
Write assurance security plan outline : Select an organization of your choosing to perform an abbreviated assessment on and then write a 3-4 page information assurance security plan outline
Define physical and chemical properties : Define physical and chemical properties, provide three examples of each, discuss their reversibility, and explain the fundamental differences between them
Create the compute-task object : Calculating Pi to 70 decimal digits' and clicking the Calculate button, the following interaction will happen between the Worker and the Master
Provide a detailed comparison of two job positions : Write a 2-3 page paper in which you: Provide a detailed comparison of two job positions from the episode. Perform a job analysis of each position
JGR 100 Finding Your Leadership Purpose Assignment : JGR 100 Finding Your Leadership Purpose Assignment Help and Solution - Strayer University - Homework Help - DiSC Assessment Reflection
Characteristics of and techniques specific to various system : Analyze the characteristics of and techniques specific to various systems architectures and Describe distributed systems and the networks that interconnect
HSA 405 Healthcare Policy and Law Assignment : HSA 405 Healthcare Policy and Law Assignment Help and Solution - Strayer University - Homework Help - Health Insurance - Analyze benefits of health insurance

Reviews

Write a Review

Programming Languages Questions & Answers

  Write program to prompt user to enter a hex digit character

Write a program which will prompt user to enter ahex digit character ("0" ..."9" or "A" .."F") ,display it on next line in decimal, and ask user if he or she wants to do it again.

  Create two objects p and q and generate 10 random numbers

Create Two objects P and Q. in object P the array a is type int and size 10, in Q array a is string type and size 12b. Generate 10 random numbers

  Visual basic programming

Write a 1- to 2-page paper discussing what online groups or sites you will follow to get insight into using Visual Basic® programming in your work or career?

  Learn to use some basic commands

In this lab you will learn to use some basic commands of the gedit, nano, and vim editors, with emphasis on vim.

  Create a software allowing for editing of vec files

CAB302 - Software Development - Vector Design Tool - Queensland university of technology - create new VEC files for the plotters by editing text files

  Write a program that simulates the functionality

Write a program that simulates the functionality of a vending machine having the following characteristics: The vending machine offers 5 products.

  The student class and the examgrades class

The student type should describe student's last name, first name, id ( letter 'N' followed by an 8-digit number), gpa (a real number in the range of 0.0 to 4.0, a whole number of credits completed, and a single letter status indicating full time

  Program to print total balances forward and total withdrawal

At the end of report, print total balances forward, total deposits, total interest earned, total withdrawals and total final account balances.

  Determine the keylength

Conduct digram and trigram analysis and Determine the keylength

  Determine proper lower bound and upper bound on ?nal value

Determine the proper lower bound and upper bound on the ?nal value of the shared variable tally output by this concurrent program.

  Program prompt teacher to input student number

The program must prompt teacher to input student number. Quiz score for that student will be displayed. Program can prompt for each quiz score.

  Create program for hotel room bookings in java and python

Create program for Hotel Room Bookings in Java and Python - Creating the same application in the three programming languages

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd