首页 > > 详细

ECS 36 b Homework #6

 

ECS 36 b Homework #6 (programming, 12% + 2% bonus)
 
Due: (original) Friday, December 11th, 2020, 11:59 p.m.
 
This homework is a team assignment. Each final project team will work on this project together and submit one single handin (but with all members’ name and ID).
 
Part 1 of HW#6  (8%)
 
For this homework, you will build three C++ programs, hw6server, hw6update and hw6search (the latter two were derived from hw6client), based on the following JSON RPC specification: http://cyrus.cs.ucdavis.edu/sfelixwu/ecs36b/f2020/hw6/ecs36b_hw6.json, which includes two RPC calls, (1) update(std::string post_json_str), and (2) search(std::string keyword). The details are given below:
 
update(std::string post_json_str) takes only one argument, which is a JSON string representing a POST, like what we had for hw5produce in HW#5. Your hw6server program receives it and performs the following actions:
1.check if the ID of the post already exists. Please note that this post might appear as either a C++ Post object with the same ID, or as a Post JSON file for the same ID at the server side. (Hint: for a simplified design, every updated Post object should have been stored as a separate JSON file, while the name of the file should contain the Post ID.) 
2.If the Post doesn’t exist yet, the server program will create a C++ Post object for this JSON Post
3.If this Post already exists, then this newly received post_json_str will be merged into the original Post, similar to hw5merge().
4.In either case, this newly created or merged post will be sent back to the caller client, again in Post JSON format as the response. Also, this new Post will be saved by the server in the JSON file format with the same ID as part of the file name. In other words, now this Post is a Persistent C++ Object.
 
search(std::string keyword) take only one argument, which is a JSON formatted search key word. For example, {“keyword”: “Patrick Jane”}. When the server hw6server receives this call, it will gather all the existing posts containing the same key (each post has a vector of key strings – this will be a new attribute for the Post class you will implement). Then, it will put all the gathered posts into a JSON array (which, BTW, is still a JSON) and sends it back to the client.
 
For testing your programs, a sequence of calls or actions have been attached to THIS document (either update or search, and program restarts), and the expected JSON results from both the client and server sides.
 
Part 2 of HW#6  (4%)
 
(4%) Your hw6client program will check if the server is available, using the try/throw/catch C++ exception handling. If the server is unavailable, it will still continue, accessing only the local cache copy of the Post objects. For example, you can still update your local copies in JSON files with new comments or reactions. Then, when the server is back on-line, the client will then submit the updates to merge on the server. Again, we will provide a sequence of calls or actions to test your programs.
 
Part 3 of HW#6  (2%, bonus)
 
(2%) Instead of obtain the Posts via the search keyword, we can also select posts via GPS_DD locality or timestamp. In other words, we can have the following search clauses 
1.{“distance”: 100.0, “latitude“: 38.5, “longitude”: -121.7}
2.{“updated_time”: “2020-05-02T16:45:18+0000”}
The first clause will return all the Posts within 100 miles range from the given GPS_DD coordinate, while the second clause will match all the posts having any update after the given timestamp. 
 
Please follow the steps on CSIF:
 
Create a subdirectory ecs36b_f2020, and then cd ecs36b_f2020.
Create a subdirectory hw6, and then cd hw6.
Copy all your files (*.cpp, *.h, and Makefile) into the hw6 directory
cd ..
tar zcvf hw6_submission.tar.gz hw6
handin cs36b hw6 hw6_submission.tar.gz
 
 
 
Test Case #1:
 
Step (1)
$ cd ecs36b_hw6
$ mkdir client       (cd client for the client side)
$ mkdir server       (cd server for the server side)
 
Now, open two terminals one for the Client and another for the Server:
 
Step (2)
 Server side
$ ../hw6server
 
 Client side
$ ../hw6search search_clause.json
 
Expected output from the Client side –
{
"status" : "failed"
}
 
Step (3)
 Client side
$ ../hw6update ../json/base_input01_hw6.json
 
Expected output from the Server side –
post_112638136365359060811666331781839957994_262650593813279.json created
 
Expected output from the Client side –
One Post JSON is returned. It should be the same as base_input01_hw6.json
 
Step (4)
 Client side
$ ../hw6search search_clause.json
 
Expected output from the Client side –
Received an array of JSON Posts (in this case only one), and
post_112638136365359060811666331781839957994_262650593813279.json created
 
 
Test Case #2:
 
Step (1)
Now, open two terminals one for the Client and another for the Server, and clean up the post files from previous test runs:
 
cd server
rm -rf post_*.json
 
cd client
rm -rf post_*.json
 
Step (2)
 Server side
$ ../hw6server
 
 Client side
$ ../hw6update ../json/base_input01_hw6.json
 
Expected output from the Server side –
post_112638136365359060811666331781839957994_262650593813279.json created
Expected output from the Client side –
One Post JSON is returned. It should be the same as base_input01_hw6.json
 
Step (3)
 Client side
$ ../hw6update ../json/base_input02_hw6.json
 
Expected output from the Server side –
post_25189023478912653590678189573729103123_1620182359912679.json created
Expected output from the Client side –
One Post JSON is returned. It should be the same as base_input02_hw6.json
 
Step (4)
 Client side
$ ../hw6search search_clause.json
 
Expected output from the Client side –
Received an array of JSON Posts (in this case, two Posts), and
post_112638136365359060811666331781839957994_262650593813279.json created
It should be the same as base_input01_hw6.json
post_25189023478912653590678189573729103123_1620182359912679.json created
It should be the same as base_input02_hw6.json
 
 
Links to test case JSONs –
http://cyrus.cs.ucdavis.edu/sfelixwu/ecs36b/f2020/base_input01_hw6.json 
http://cyrus.cs.ucdavis.edu/sfelixwu/ecs36b/f2020/base_input02_hw6.json
http://cyrus.cs.ucdavis.edu/sfelixwu/ecs36b/f2020/base_input03_hw6.json  (for GPS, location)
 
联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!