-
Notifications
You must be signed in to change notification settings - Fork 0
S24_AmazonOrderProcessing_Hard
Using ArrayBlockingQueue (which was discussed in class) as a buffer, you will construct a program that will emulate the processing of an order from Amazon.com (or any online order) from when you place the order to when it gets put on the truck for delivery to your home.
Your program will be structured as shown in the tree below:
Each node must:
- Run in its own thread
- Contain one input buffer and 1-2 output buffers. Two exceptions:
- The Web Server node reads from a file and does not have an input buffer
- The Delivery Truck Nodes print to the screen and do not have output buffers.
Additional Specifications:
- The buffer between two nodes must be shared.
- The only means of communication between nodes is the buffer between them.
Receives orders containing the following information:
- Delivery address
- Name on order
- Item ordered
- Item category
This node must read these orders from the S24_AmazonOrderProcessing_OrdersFile.csv
the document file which resembles the following table:
address | city | state | zip | name | item | category |
---|---|---|---|---|---|---|
1234 Iowa Avenue | Denver | Iowa | 52234 | Jane Doe | Laptop | Computer |
.......plus 19 more entries....... |
For each order received, it decides which Shipping Center to send it to based on the following logic:
- Orders to the following cities got to Shipping Center 1:
- Los Angeles
- San Francisco
- Seattle
- Denver
- Orders to the following cities go to Shipping Center 2
- Des Moines
- Chicago
- St. Louis
- Any other city not already mentioned
Also, when this node reaches the end of orders in the .csv file, it must send some sort of indication to all the Shipping Center nodes through the shared buffer that the end has been reached and then terminate.
The Shipping Center must decide which part of the warehouse the item is in and send a command to the appropriate forklift to go get it and deliver it to the shipping dock.
The Shipping Center organizes items based on the first letter of their category. It will also append the Shipping Center number to the order for tracking purposes.
The processing is as follows:
- Orders with categories beginning with A-P go to Section 1
- Orders with categories beginning with Q-Z go to Section 2
The Shipping Center Sections will do the following:
- Receive order
- Append the Shipping Center Section number to the order for tracking purposes
- Pause for 0-5 seconds. This period must be decided randomly
- Put order on the Shipping Dock's buffer
The Shipping Dock nodes will fill up the buffers to the trucks as there is room available. They will start with truck 1. If the buffer for Truck 1 is full, then try truck 2. If they are all full, then wait until one buffer becomes available.
The trucks perform the following sequence:
- Read from their input buffer until they have received 4 deliveries or receive notification that there are no more deliveries. On each delivery, they must append the truck number for tracking purposes.
- For each of the four deliveries (or less if the "no more deliveries" notification was received), do the following:
- Sleep for 0-10 seconds. This period must be decided randomly.
- Print out the information on the shipping order to the screen
The truck also must also print out a message to the screen after it has received the “no more deliveries” notification and delivered its last order indicating that it is done delivering. This message should specify the truck’s number and the number of its associated shipping center.
The Shipping order information printed to the screen must include the following information:
- Delivery address
- Name on order
- Item ordered
- Item category
- Shipping Center the order went through
- Shipping Center Section the order went through
- Delivery Truck the order was delivered on
- Your program MUST be multi-threaded or you will not meet the homework requirements for Oral Exam 2.
- The program must not continue on indefinitely. All threads must stop on their own once all orders have been processed. All orders received must be delivered.
- Only the Delivery Truck nodes should print to the screen and they should print ONLY what is specified in their specifications. This requirement is to allow us to grade this problem easily.
UML Diagram:
The java documents are served from a local web server on this machine. To start the web server, navigate to the directory immediately above where the source code is checked out (i.e. ~/git ) and then use "python -m SimpleHTTPServer" in that directory.
cd ~/git
python -m SimpleHTTPServer&
Note: if you are running python 3 (which you can check via opening a terminal and typing: python --version), then the command is:
python3 -m http.server