程序代写代做代考 distributed system Hive Java scheme data structure Department of Computer Science
Department of Computer Science
COMP212 – 2017 – CA Assignment 1
Distributed Communications
Java RMI
Assessment Information
Assignment Number 1 (of 3)
Weighting 7%
Assignment Circulated 16th February 2017
Deadline 16th March 2017, 15:00 UK Time (UTC)
Submission Mode Electronic via Departmental submission system
Learning outcome assessed (1) An appreciation of the main principles underlying
distributed systems: processes, communication, nam-
ing, synchronisation, consistency, fault tolerance, and
security.
Purpose of assessment This assignment assesses the understanding of Java
RMI.
Marking criteria Marks for each question are indicated under the corre-
sponding question.
Submission necessary in order No
to satisfy Module requirements?
Late Submission Penalty Standard UoL Policy.
1 Overall marking scheme
The coursework for COMP212 consists of two assignments and a class test contributing
altogether 20% of the final mark. The contribution of the single assignments is as follows:
1
Assignment 1 7%
Assignment 2 7%
Class test 6%
TOTAL 20%
2 Objectives
This assignment requires you to write a Java program implementing client-server communi-
cation using Remote Method Invocation.
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 applications: While the server is running, a
client can connect to the server and vote for one of the 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, I suggest the following remote object interface (however, feel free to
modify it to your needs):
castVote.java:
interface castVote extends java.rmi.Remote {
public void vote (int choice) throws java.rmi.RemoteException;
public String getVotingResults() throws java.rmi.RemoteException;
}
You have to implement the following classes.
3.1.1 Class castVoteImp.java
This class has to implement the castVote interface.
2
3.1.2 Server side
The server has to 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 on screen.
Hint. Start with downloading the RMI example from the module site (http://www.csc.
liv.ac.uk/~michailo/teaching/comp212). Following the instructions, make sure it works
on your computer. Then use my code as a basis for your implementation.
3.2 Program logic—50% of the assignment mark
To get further 30%, you have to implement in the remote object the counting of votes
and returning voting results and also implement the client side functionality. To get the
remaining 20%, you have 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 functionality can be achieved, for example, by assigning every client a ticket
(a randomly generated integer number). A client without a ticket will be denied all com-
munication. 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 the first assignment is, 16th March at 15:00 (UK time).
• Submission is via the departmental submission system accessible (within the depart-
ment) from
http://intranet.csc.liv.ac.uk/teaching/modules/module.php?code=comp212
Please submit an archive containing all the appropriate .java and .class files of the
client side and server side in two separate directories, one for the client code and the
other for the server code. Each directory has to contain all the necessary files to run
the example including the interface file.
• Please write a client and a server that run on the same host (localhost) in order to
facilitate the execution of the code on my computer.
3