08 Jun Course work related Java/Distributed Systems
Question
Distributed Systems: Coursework
A Text Messaging Server
2 Problem Description – Group work (25 marks)
Your task is to implement a text messaging server system that can be used for text messaging. Text messages contain a single line of ASCII text, sent to a single user. The two components of this system are; a message server that manages the messages and a client that can be used to connect to the server and then to send and receive messages.
I have partially implemented the server and, in its current state, it allows users to log in and log out from the server. It is lacking the functionality to tell users when they have messages waiting and messages cannot yet be sent or received. In its current form it can be compiled and run, you can connect to it using telnet and commands 101 and 102 (see below) are completely implemented. The code is available from Message-Server-To-be-Edited.rar included.
The server requires a password file to be available and one is provided at the above address. The location of the password file must be configured in the file MsgProtocol.java. The default location is
WithinMessageservertobeedite.rar”h:pwd.txt”.
2
3 The Protocol
Here is the definition for the commands that a client may send to the message server:
{QUERY} ::= {LOGIN} | {SEND} | {OTHER} {LOGIN} ::= “101” {CR} {U} {CR} {PWD} {CR}
{SEND} ::= “103” {CR} {U} {CR} {U} {CR} {M} {CR} {OTHER} ::= {ID} {CR} {U} {CR}
{U} ::= username {PWD} ::= password
{ID} ::= “102” | “104” | “105” | “106” {M} ::= [<CHAR> | <CHAR> {M}]
{CR} := <CRLF>
Note that <CHAR> is any ASCII character excluding control characters and <CRLF> is carriage return followed by line feed which is “nrnn” in java. Here is a key to the client command IDs:
| ID | Translation | Example | |
| 101 | Login Command | “101 nrnn tony nrnn mypasswd nrnn” | |
| 102 | Logout Command | “102 nrnn tony nrnn” | |
| 103 | Send Command | “103 nrnn tony nrnn fred nrnn A message to fred | |
| nrnn” | |||
| 104 | Do I have waiting messages? | “104 nrnn tony nrnn” | |
| 105 | Get next message | “105 nrnn tony nrnn” | |
| 106 | Get all messages | “106 nrnn tony nrnn” |
4 Server responses
{RESPONSE} ::= {OK} | {MSG} | {ERROR}
{OK} ::= “200” {CR}
{MSG} ::= “201” {CR} <n> {CR} {MSGDATA} {ERROR} ::= “500” {CR} {M} {CR}
{D} ::= Date
{MSGDATA} ::= {U} {CR} {D} {CR} {M} {CR} [{MSGDATA}]
Note <n> is an integer with a value greater than zero Here is a key to the server response IDs:
3
| ID | Translation | ||
| 200 | Request successfully executed | ||
| 201 | n messages are being sent, each message consists | ||
| of the senders username, the date the message | |||
| was sent and the message content. | |||
| 500 | An error response and the accompanying mes- | ||
| sage should explain the error | |||
Examples of Java strings for valid responses are:
200 “200 ”
201 “201 1 fred Thu Feb 27 14:04:32 GMT 2003 A Message ” or, if there is more than one message:
“201 2 fred Thu Feb 27 14:06:32 GMT 2003 Hello from Fred ” “fred Thu Feb 27 14:07:47 GMT 2003 fred Another Message ”
is the only valid logout command.
500 “500 Incorrect Password ”
Commands 101, 102, 103, 104 will all be followed by either an {OK} reponse or an {ERROR} response. Note that for request 104, an {OK} response means
Yes there are messages waiting and an {ERROR} response means
No messages are waiting. Commands 105 and 106 will be followed by either a {MSG} response or an {ERROR} response.
5 Complete the server
Classes relevant to this task are:
3.1 MsgProtocol
The MsgProtocol class defines constants for all of the client and server command identifiers. Use these constants in your code.
3.2 LoginCommand and LogoutCommand
The LoginCommand and LogoutCommand classes process the login and logout commands. You should look at these classes to see how to implement a command.
3.3 CommandFactory
This class exists to read the command identifier sent by the client and return a command class that can process the rest of the command. For example, if the command identifier is 101, a LoginCommand class will be returned. Currently command classes are only implemented for logging in and logging out.
6 Command classes to be written
You need to write command classes that handle the remaining commands that your server must process. These commands are:
4
Send a message (103) – Partially implemented
(3 Marks)
Are there any waiting messages? (104) – Partially implemented
(3 Marks)
Get next message (105) – Partially implemented
(3 Marks)
Get all messages (106) – Partially implemented
(3 Marks)
Discuss how a JSP servlet implementation of the Text Messaging System would differ from the way its being currently implemented. As part of your answer you should discuss the system design and a skeletal of class structure and the purpose of each.
(5 Marks)
Implement an simple interface for the Text Messaging System using JSP and Servlets. Ensure that both the Login and Logout implementation of your system are fully functional.
(5 Marks)
Also3 marks will be awarded based on the presentation of the project work ALL members of each group needs to participate in the presentation, clearly identifying their contribution to the overall implementation of the classes.
7 Handling messages
I have fully implemented the classes you need for storing messages on the server. These are called Message and MessageCollection. The Message class models the individual messages, has sender, date and content. The date is added to a message automatically. The send command should construct a new Message object whenever a new message is sent and that message is then added to the Mes-sageCollection. The MessageCollection class provides a way of holding all the messages that have been sent but not yet read. Those messages can be accessed using the recipient name as a key. The class has all the methods you will need for adding a new message to the collection, retrieving messages for a particular users and finding out how many messages a particular user currently has waiting in the collection. Note that getting a message from the collection also removes it from the collection. You must use the message collection for storing messages on the server. Do not try to write your own code to store the messages.
8 Server connections
The MsgSvrConnection class handles an individual connection between this server and a client. It has methods to set the current user and get the current user which all the commands use to ensure the current user is logged on before the other commands work (see LoginCommand and LogoutCommand). Another method returns the MessageServer object because that object provides access to the message collection. The MessageServer class is the main server class. It knows about the MessageCollection and each MsgSvrConnection. It provides a query that can be used to return the message collection.
5
9 Distribution Issues (Individual work { 25 marks)
The Text Messaging Server is implemented by several servers. Explain why resources might be transferred between them. Would it be satisfactory for clients to multicast all requests to the group of servers as a way of achieving mobility transparency for clients?
(10 marks)
Suppose that the operations of the Text Message application are separated into two categories – public operations that are available to all users and protected operations that are available only to certain named users. State all of the problems involved in ensuring that only the named users can use a protected operation. Supposing that access to a protected operation provides information that should not be revealed to all users, what further problems arise?
(8 marks)
Your Texting Messaging Server is proving to be very successful and you are now thinking of partitioning and/or replicating data among servers. Discuss what is involved to run the server on several hosts.
(7 marks)
10.1 What to submit
Add your code into the client application, modifying only those parts of the code indicated by the comments. Marks will be lost if you modify any other parts of the code.
Marks will be assigned based on the content of your report and also on the performance of your program. I will run your code to see if it works.
Hand in a report listing the code that you added, telling which class that code was added to, and describing what that code does.
Your answers for the questions in section (9) should be detailed showing adequate understanding of design and implementation issues involved in the development of distributed systems.
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.
