1The Assignment 1 Specification and Marking Criteria A Simplified Remote Invocation Framework This assignment is an individual work. Source code similarity is to be checked for plagiarism....










  • 118208








I Need to develop a simplified Remote Invocation Computing Framework. The framework is a typical client/server system to utilise distributed computing power. The purpose of this assignment is to assess your competence in Java multi-threading, TCP streaming, object serialization and client/server model


1 The Assignment 1 Specification and Marking Criteria A Simplified Remote Invocation Framework This assignment is an individual work. Source code similarity is to be checked for plagiarism. The application scenario Java RMI (Remote Method Invocation, reference Chapter 5 of the textbook and Week 3 lecture) enables the local invocation and remote invocation use the same syntax to implement a generic remote server, such as the Compute Engine example in Week 3 lecture slides. The application scenario of such a compute engine is to utilise the compute-power of a high-performance computer or cluster. That is, a client prepares compute-tasks and offloads them to the server for execution. Java RMI framework needs two HTTP servers to transfer Java classes between an RMI client and an RMI server at runtime. In addition, Java RMI applications need an RMI Registry to register or look up remote objects. In this assignment, you are to implement a simplified remote invocation framework that is similar to Java RMI but lightweight (note: for this assignment, you don’t use any Java RMI APIs). Java TCP streaming, object serialization, multithreading and client/server model are the fundamental Java components to build distributed applications. The models and components have been introduced through Week 1 to Week 4 lectures, tutorials, and lab projects of this unit. The models and components are used to develop such a simplified framework of this assignment. You will need review the models and components and practise the relevant lab projects of the weeks for this assignment. Note: 1. A separate document for demonstration of the system functions is available on the unit Moodle site. You will need to use the demonstration document as a part of the assignment specification. You will need to ensure that you fully understand the scenario and project specification before developing the project; you will also need to ensure the developed system fulfilling the functional requirements as shown in the demonstration document. 2. The algorithms of the three-sample compute-tasks are provided on the unit Moodle for the framework. 3. Assignment 2 is the enhanced, secured version of this assignment (Assignment 1). The implementation quality of this assignment is also important for Assignment 2 because the project code of this assignment will be reused by Assignment 2. The assignment specification is as follows. 2 Part 1: Java TCP streaming, Multithreading and Object Serialization Programming The framework consists of a compute-server, a compute-client and a class repository (server side), which are depicted in the following diagram. The framework is a generic computing architecture because the compute-client and compute-server interact only by the communication contract: the Task interface and CFile class via the framework. The specification of the components is as follows. 1. The interaction contract The interaction contract between a compute-client and the compute-server consists of the Task interface and the CFile class. a. The Task interface defines two standard methods that every compute-task must implement. For example, in this assignment, three compute-tasks CalculatePi.class, CalculatePrime.class and CalculateGCD.class must implement the two methods of the Task interface. package Contract; public interface Task { public void executeTask(); public Object getResult(); } Calling the method executeTask()will perform the task and set the result in the task; calling the getResult()method will return the computing result. b. The CFile class is used as the container and carrier to transmit the Java class file of a compute-task from a compute-client to the compute-server. package Contract; public class CFile implements Serializable{ String fname; byte [] fbytes; //Constructors and getters and setters } Compute-client Compute-server Class repository Compute-task objects (Task) Upload compute-task classes by CFile object Download compute-task classes 3 The fname is the name of the Java class file of a compute-task, and the fbytes is the byte array representation of the Java class file of the compute-task. To transmit a compute-task class file, e.g., CalculatePi.class, the compute-client creates a CFile object to hold the file name and the file contents in bytes and sends the object to the compute-server. The compute- server will save the byte array into a file, which has the same name. Note: a code sample about how to use CFile to transmit any binary files is given and can be accessed on the unit Moodle site. 2. The compute-task A compute-task must implement the Task interface. A compute-task must implement java.io.Serializable interface as well so that the compute-task can be transmitted between a compute-client and the compute-server over the network. The structure of a compute-task 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 …… } Every compute-task class is defined/created by compute-clients, and it must be uploaded to the class repository of the compute-server. Every compute-task object is created by compute-clients and submitted to the server to execute. 3. The class repository The compute-server has a class repository that saves the Java classes of available compute-tasks. Before asking the compute-server to perform a compute-task, a compute-client must upload the Java class of the task onto the class repository. The uploading of compute-tasks is automated by the compute-client and the compute-server, not manually done by a user outside the framework. 4. The interaction workflow of the framework When the compute-client starts, it needs to establish a TCP connection to the compute-server for object (Java objects) transfer. Then the workflow between the compute-client and the compute-server goes through the following steps for computing a task. 4 a. The compute-client uploads the class (e.g., CalaulatePi.class) of a compute-task (i.e., Calculate Pi) to the compute-server’s class repository. b. The compute-client creates an object of the compute-task, which encapsulates the arguments of task, e.g., for Calculate Pi, the argument is the number of decimal places to calculate Pi for certain accuracy, and then sends the object to the compute-server. c. The compute-server receives the CalaulatePi object and cast (deserialize) the task into the Task interface type. d. The compute-server calls its executeTask() method, which performs the computation and sets the result on the same object. e. The compute-server sends the same CalaulatePi object back to the compute-client. f. The compute-client receives the CalaulatePi object back from the server. g. The compute-client calls the getResult() method of the object to retrieve and display the result. A demonstration of the interaction workflow between a compute-client and the compute-server is in the demonstration document on the unit Moodle site. 5. 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 sample code of transmitting binary files over networks has been provided on the unit web site as well. The compute-server must be multi-threaded and follow the ‘thread-per-connection’ architecture (reference Week 4 contents). The communication between the compute-client and the compute-server must use TCP streaming (Java TCP API Socket and ServerSocket) as described in Week 2 contents of this unit. Please note use of any other 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 compute-client; graphic user interface (GUI) is required. The GUI should have the necessary components to enable a user of this framework to execute all the functions as described in this assignment specification. When GUI is necessary for the client implementation, it is not the focus of this assignment. This assignment focuses on the communication between the compute- client and the compute-server. Thus, developing the client GUI using Java Swing is enough. Using JavaFX for more features of GUI adds no extra values for this assignment. 5 b. A Java application to implement the compute-server (GUI is not required). c. Several Java classes to implement the processing threads when necessary. Note: to demonstrate your competence of 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. d. A few Java classes to implement Calculate Pi, Calculate Primes and Calculate the Greatest Common Divisor tasks. Note: to simulate compute-client and compute-server 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 server machine can be ‘localhost.’ Part 2: Program use and test instruction After the implementation of the framework, prepare an end user instruction on how to use your software. The instruction should cover all aspects of the framework as detailed in this assignment. Submission You need to provide the following files in your submission. 1. Files of Java source code of the compute-client, the compute-server and the processing thread and the compute-tasks. The inline comments on the data structure and program structure in the Java programs are required. The source code files must be able to be compiled by the standard JDK (Java Development Kit) or NetBeans IDE. 2. The compiled Java class files of the source code. The Java classes must be runnable on the standard Java Runtime Environment (JRE). Note: an easy way to provide the implementation is to submit it in a NetBeans project. 3. A Microsoft Word document to address the issues as specified in Part 2 above. All the required files must be compressed into a zip file for submission. You must submit your assignment via the unit web site. Any hardcopy or email submission will not be accepted. After the marked assignments are returned, any late submissions will not be accepted. The Marking Criteria Marking Criteria Available Marks 6 Part 1: Java TCP streaming, Multi-threading and Object Serialization Programming 21 1. The project can be compiled by JDK or NetBeans IDE and executed by JRE 2 2. The given Task interface and CFile class are properly used as the unique communication contract between the compute-client and compute-server 2 3. The 3 compute-tasks have been implemented as Java serializable objects 3 4. The 3 compute-tasks can be successfully transferred between the compute-client and compute-server 3 5. The 3 compute-tasks can be successfully executed by the compute-server and can return correct results to the compute-client 3 6. The ‘not uploading task’ reminder functions correctly 2 7. The compute-client functions correctly 2 8. The TCP streaming is correctly used for the compute- client and compute-server communication 2 9. The compute-sever structure is sound as a TCP server 2 Part 2: Program use and test instruction 9 1. The program compiling and installation is clearly described 2 2. The code repository in the compute-server is clearly described 1 3. The test instruction covers all 3 compute-tasks 3 4. The test instruction covers ‘not uploading task’ reminder 1 5. The necessary screenshots and source code inline 2 7 comments have been provided Sub Total for Assignment 1 30 Late Penalty -1.5 (5%) each calendar day (either full or partial) Plagiarism Related Penalty Total for Assignment 1 1 The Reference Algorithms for Assignment 1 Check Primes public boolean isPrime(int number){ for(int i=2; i b) a = a - b; else b = b - a; } Return a; } } Calculate Pi to a certain number of digits (from Week-3 examples) public class Pi { private static
Mar 24, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here