Java代写 | COMP212 – 2020 – CA Assignment 2 Distributed Communications Java RMI

COMP212 – 2020 – CA Assignment 2
Distributed Communications
2 Objectives
This assignment requires you to write a Java program implementing client-server communication using Remote Method Invocation (RMI).
Note that no credit will be given for implementing any other form of
client-server communication!
3 Explanation of coursework
Imagine you are designing a distributed voting application: While the server is running, a
client can connect to the server and vote for 1 out of 3 choices (by means of the method
vote, see below). After voting, the client can request the voting results so far.
3.1 Basic Java RMI communication—50% of the assignment mark
As a first step, you are required to implement client-server communication only. At this stage
you can ignore the program logic, but you should show some evidence that your program
works and that communication between the client and server actually takes place.
For your convenience, we suggest the following remote object interface (however, feel free to
modify it to your needs):
interface castVote extends java.rmi.Remote {
public void vote (int choice) throws java.rmi.RemoteException;
public String getVotingResults() throws java.rmi.RemoteException;
You must implement the following classes.
3.1.1 Class
This class should implement the castVote interface.
3.1.2 Server side
The server should initiate and register the remote object.
3.1.3 Client side
The client should submit the user choice to the remote server and then print the current
vote and voting results on screen.
Hint. Start with downloading the RMI example from VITAL under the “Assessment Submission” tab. Following the instructions, make sure it works on your computer. Then use
that code as a basis for your implementation.
3.2 Program logic—50% of the assignment mark
To get further 30%, you need to implement the remote object, the counting of votes and returning voting results, and also implement the client side functionality. To get the remaining
20%, you need to extend the communication model to make sure that the server will only
allow a client to see the current voting results after submitting its own vote.
Hint. Such a functionality can be achieved, for example, by assigning to every client a
ticket (a randomly generated integer number). A client without a ticket will be denied all
communication. A client first requests a ticket from the server and then passes this ticket
as an extra parameter to all remote methods. When the server issues a ticket, it saves the
ticket to a data structure (for example, a hash table) so that all remote methods (vote,
getVotingResults, etc) will be able to check that the ticket is valid.
You are more than welcome to suggest your own method to control the right order of calls.
4 Deadline and Submission Instructions
• The deadline for submitting this assignment is Thursday, 26th March 2020, 17:00
UK time (UTC).


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:itcsdx