COIT13229 Applied Distributed Systems - Assessment 2
This assessment item is designed to test your understanding in Java TCP networking with multiple servers, Java Object Serialization\Deserialization, Java Class Interface, and Java Remove Method Invocation.
An online store selling two productions (Book and Movie) would like to create an application that allows customer to purchase their productions. The application should be implemented using TCP client/server model, where client can enter basic order information and the system will calculate total bill and return to client. The store needs to server a large number of customers; they need two servers to handle the operations of each product type separately (one Server for Book and another Server for Movie). The communications between client and the system are handled by another server acting as a coordinator. The coordinator server receives order information from client send to the server of the corresponding product type for calculating total bill. The computed information is then sent back to the coordinator to pass onto client.
You can use the following class descriptions as a guideline for your design.
1. The program should have two classes for BookOrder and MovieOrder to stores order details of Book and Movie. Both Classes should contain appropriate properties to store order information such as Quantity, Unit Price, Tax, Total Bill. Constructor(s) and Get and Set functions should be implemented in this class. In addition, these classes should implement two functions executeTask() and getResult() of a Java Class Interface Task (Refer to JavaClassInterface example in Week 6 for reference) to compute the Total Bill Values and output message. Note that there is different tax rates applied to different products. The Book order will have 10% tax, while the Movie order will have 30% tax.
2. OrderClient: This program ask user to select which product to order, and then ask for user inputs for Quantity and Unit Price. The created object will then be sent to as a server named ServerCoordinator using TCP Connection and print out total bill information after receiving returned object from the servers.
3. There are three servers needed in the application:
ServerCoordinator: This program receives object sent from OrderClient and determine whether the order is for Book or Movie. If it is a book order, this coordinator server sends the object to another server named ServerBook for processing. Similarly, if it is a movie order, this coordinator server sends the object to another server named ServerMovie. Returned objects from
ServerBook or ServerMovie are then sent back to OrderClient. This server should keep track and display the number of requests sent from client.
ServerBook: This server receive Book order from ServerCoordinator and then compute the total bill using the executeTask() function. The computed object is then is sent back to the ServerCoordinator. This server should keep track and display the number of Book order sent from client.
ServerMovie: This server receive Movie order from ServerCoordinator and then compute the total bill using the executeTask() function. This server should keep track and display the number of Movie order sent from client.
The communication between the servers and clients are TCP connections. The socket number should be in the following format “xxyy” where xx is the last 2 numbers on your student ID. You can design your own numbers for the values of yy. Java object Serialization/Deserialization should be used in the above programs where appropriate. (Refer to Week 9 and Week 11 Lab Solutions for reference in developing these programs)
Your program should check user inputs for potential error and allow user to re-enter details where appropriate. Exception and error handling should be implemented within your program where necessary. The source code should be formatted properly following good programing practice (appropriate variable names, indentation, comments, etc....)
The following screenshots show example outputs of the above program. You should only use these as references. Your program outputs can be similar but not necessarily the same. You should customize the messages on clients and servers for your own program.
Assume that OrderClient is run on two Java Virtual Machines:
Output of ServerBook:
Output of ServerMovie:
Output of ServerCoordinator:
After the implementing the program, prepare an end user instruction and test manual. Run the program and take screenshot of program outputs, provide description on the outputs and how your program works. The test should demonstrate that your ServerCoordinator can accept connection with more than one OrderClient. The test should show at least 4 orders. Screenshots of the outputs of all server and client programs should be provided.
You should submit one Zip file containing the following files using the Moodle online submission system, by the due date:
Task.java – Source code for the Task Java Class Interface
BookOrder.java – Source code for the BookOrder class
MovieOrder.java – Source code for the MovieOrder class
OrderClient.java – Source code for the OrderClient class
ServerCoordinator.java – Source code for the ServerCoordinator class
ServerBook.java – Source code for the ServerBook class.
ServerMovie.java – Source code for the ServerMovie class.
Report.docx – A document file containing details as outline above.