Implement a remote invocation framework

Assignment Help JAVA Programming
Reference no: EM131499492

The Assignment

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 generic remote servers like the Compute Engine example in Week-3 lecture slides. However, Java RMI needs 2 HTTP servers to transfer Java classes between a RMI client and a RMI server at runtime. In addition, Java RMI applications need a RMI Registry for registering or looking up the remote objects.

In this assignment (assignment-2), you are to implement a remote invocation framework that is similar to Java RMI but lightweight (note: for this assignment, you don't use any Java RMI APIs). To implement the framework, you will need to use Java Interface, Java Objection Serialization, Java Thread and client/server model. Recall you have created some Java examples about these Java components and models for assignment-1; now you will need to use these Java components as a reference to build this framework. Thus if necessary, you may need to review your assignment-1.

This assignment specification is as follows.

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

The framework consists of a compute-server, a compute-client and a codebase repository, which are depicted in the following diagram. The framework is a generic computing architecture because the compute-client and compute-server just need to know the Task and CSMessage components in advance before the framework can start to run. The specification of the components is as follows.

1490_Figure.jpg

1. The interaction contract

The interaction contract between the client and server is defined by the Task interface:

//The Task interface (interaction contract) between clients and the server public interface Task {
public void executeTask(); public Object getResult();}

Every 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.

2. The compute-client and compute-server

The compute-server is used as a generic compute-engine. While running, the server is continuously waiting for the compute-tasks. A compute-task is created by a compute-client and sent as a serialized object to the compute-server. Once the compute-server receives a task, it will cast (deserialize) it into the Task interface type and call its executeTask() method. After executing the task, the compute-server will send the same object back to the compute- client.

The compute-client is continuously accepting a user's requests. Every request specifies a compute-problem and its corresponding parameters. For a request, the compute-client creates a compute-task and sends it as a serialized object to the compute-server. Once receiving the compute-task object back from the server, the compute-client will call the getResult() method of the object to display the result.

The following screenshots show the interaction between a compute-client and the compute- server.

3. The codebase repository

Such a framework makes the compute-server generic. That is, the compute-server just needs to know the Task interface, then it can be compiled and run. If a compute-client implements a new compute-task after the server is run up, the compute-client just needs in some way (in real world application it could be a FTP server, but in this assignment, you just need to copy the files into a directory) to upload the Java class of the compute-task into a pre-determined network location (e.g. the codebase directory), which the compute-server can access from its Java classpath. Then the compute-server can perform such a new compute-task. Therefore, the server never needs to be shut down, recompiled, and restarted.

The following screenshot shows that there are 2 compute-tasks that have been uploaded into the codebase repository.

4. The error message

However, when there is an exception occurred (e.g. a compute-client wants the compute-server to perform a compute-task, but forgets uploading the Java class of the compute-task) onto the codebase of compute-server, the compute-server will create a CSMessage object and sends it back to the compute-client. Note: the CSMessage follows the interaction contract by implementing the Task interface. By calling the getResult() method, the compute-client will know the problem and fix it later on.

import java.io.*;
public class CSMessage implements Task, Serializable {
//The variable that holds the error information private String finalResult;

public CSMessage() {
}
//Return the final computing result public Object getResult() {
return finalResult;
}
//Set the error message
public void setMessage(String msg) { finalResult=msg;
}
public void executeTask() {
}
}

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 these tasks are given on the unit web site. Your compute-server must be multi-threaded and follow the ‘thread-per-connection' architecture (reference Week-4 contents). The communication between the compute-server and the compute-client must use TCP protocol through the Java TCP API Socket and ServerSocket as described in Week-2 contents of this unit and also online at, https://docs.oracle.com/javase/7/docs/api/java/net/Socket.html, and

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

1. A Java application to implement the compute-client;

2. A Java application to implement the compute-server; and

3. A Java class to implement the request processing thread.

4. A number of 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 about how to use your software. The instruction should cover all aspects of the framework as detailed in the marking criteria below.

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 in-line comments on the data structure and program structure in the programs are required. These source code files must be able to be compiled by the standard JDK (Java Development Kit) or NetBeans from Oracle (https://www.oracle.com/technetwork/java/index.html).

2. The compiled Java class files of the source code. These Java classes must be runnable on the standard Java Runtime Environment (JRE) or NetBeans from Oracle (https://www.oracle.com/technetwork/java/index.html).

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

The implementation of the framework

1. Whether the program can be compiled by JDK and executed by JRE or NetBeans
2. Whether the given Task interface is properly used as the unique communication contract between the client and server
3. Whether the 3 compute-tasks have been implemented as Java serializable objects, can be successfully transferred between the client and server and the server can return correct results to the client
4. Whether ‘the task has not been uploaded' exception can be handled by using the CSMessage
5. Whether the client program functions correctly
6. Whether the sever is multi-threaded by using the ‘thread-per-connection' model

Program use and test instruction
1. Whether the program installation is clearly described
2. Whether the codebase is clearly described
3. Whether the test instruction covers all 3 compute- tasks
4. Whether the test instruction covers ‘the task has not been uploaded' exception handling.
5. Whether the necessary screenshots have been provided and helpful for the test instruction.

Attachment:- Java TCP Networking.pdf

Verified Expert

The solution file is prepared in net beans. It is implemented r mi tcp program to compute pi value, prime number and gcd. This folder has client server computeprime computepi and computegcd classes. Two interfaces are used that task and compute for execute and task method used remote and serialisation. The output screen shot of this program attached here

Reference no: EM131499492

Questions Cloud

What are the financial risks taken in your business : What are financial risks taken in your business? What company did you choose? What are the market risks that your selected company encounters?
Explain the differences between high-context and low-context : explain the differences between high-context and low-context cultures and how cultures around world vary widely in the role that context play in communication.
Analysis - dhs right-wing extremism report : Analysis: DHS Right-wing Extremism report. What literature was reviewed in support of this research? What was the research question being addressed
How your companys culture abilities may support : Summarize your review and research. Explain how your company's culture and learning organizational abilities may support or detract from a change initiative.
Implement a remote invocation framework : You are to implement a remote invocation framework that is similar to Java RMI but lightweight - To implement the framework, you will need to use Java Interface.
Explain the evolution of political parties : Explain the evolution of political parties from the Federalists and Democratic-Republicans to the political parties that exist today
Define different types of musical composition styles : Define different types of musical composition styles. Identify Classical composers and their respective compositions.
Explain the implementation challenges for management : Explain the implementation challenges for management and operations, marketing, finance and accounting, research and development, and information systems.
Examines the process of the shared powers : Provide a case study paper, which examines the process of the shared powers between the executive and legislative federal branches

Reviews

inf1499492

6/14/2017 5:41:26 AM

Java is a hard language to learn in 5 weeks, so in spite of experiencing difficulty before utilizing the site I picked up information through observing my finished task, which helped me to see more than my teacher showed me in 5 weeks. The task took around 2 days to finish after I paid, and was so elegantly prepaid and clear it was anything but difficult to perceive what my Expert did and why. I will totally utilize this site again for my other course. Furthermore, I would prescribe this site to any individual who is in a crunch or needs assistance facilitating their work stack.

Write a Review

JAVA Programming Questions & Answers

  Java program that will prompt the user to input a file

Write a Java program that will prompt the user to input a file (document) in order to count the frequency of each word. This program will display the frequency of each word sorted alphabetically or by frequency (depending on the preference of the use..

  Write java program to accept two words as input

Write a Java program that accepts two words as input and determines if one of them is resulting from changing the order of the others' letters.

  Take a position on whether or not an object-oriented

take a position on whether or not an object-oriented approach can be used to develop any type of system. provide two

  Create java program to find number of days left in that year

Create a Java program called "DaysLeftInYear.java" that outputs the number of days left in that year. use the calendar class to represent dates. Use the DateFormat class to display the current date in the output.

  Retrieve an array of all list elements on the page

Function testCountListElements should simply retrieve an array of all list (html tag li) elements on the page and assert that their total count is three

  Implement the hierarchy for a university with java classes

Implement the above hierarchy for a university with Java classes and their appropriate relationship. You can go three levels deep in the hierarchy (community member, employee, student, alumnus, faculty, staff). Use your best judgment of instance v..

  Method summarizesequences that takes a string as a parameter

Now implement the method summarizeSequences that takes a String as a parameter. This method should open the file named by this String, and read a sequence from that file into an array list using the getSequence method you wrote above

  Create a uml class diagram for your class

Create a UML class diagram for your class. Your class should have at least 3 attributes (instance variables). Attributes should be appropriately typed and scoped to incorporate data hiding.

  Way to organize the flowers

Prepare a java program using given conditions- He wanted a way to organize the flowers that he picks for her each day and perform a few basic tasks with them, along with a few restrictions. It is our goal to help him out

  Write a java complete program to access employee profile

SMB4103-Introduction to Programming - write a Java complete program to access employee profile and calculate the tax rate for each employee

  Create a class that holds the service description and price

Create a class that holds the service description, price, and number of minutes it takes to perform the service. Include a constructor that requires arguments for all three data fields.

  Prompts the user to enter 4 numbers for a salesperson

Write a program (SalespersonCommission.java) that prompts the user to enter 4 numbers for a salesperson's items sold for last week and displays that salesperson's earnings.

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