PA2 Examples

2019/02/18

This post will walk you through a few sample invocations of the SurfStore clients to help you ensure that you fully understand what is the expected behavior of your system.

First, we are going to setup a sample environment where we have a server running on port 15112, and we have two clients, Tahani and Jianyu. Each client has their own local data directory (tahani-data and jianyu-data). Initially, these two directories start out empty:

[cs124w@ieng6-203]:src:510$ cat tahani.ini
[ss]
base_dir=./tahani-data
blocksize=4096

[ssd]
enabled=true
server=localhost:15112
[cs124w@ieng6-203]:src:511$ cat jianyu.ini
[ss]
base_dir=./jianyu-data
blocksize=4096

[ssd]
enabled=true
server=localhost:15112
[cs124w@ieng6-203]:src:512$ ls tahani-data/
[cs124w@ieng6-203]:src:513$ ls jianyu-data/
[cs124w@ieng6-203]:src:514$

Let’s start by having Tahani create a new file, and sync it to the cloud. Jianyu will then call sync, and retrive that file:

[cs124w@ieng6-203]:src:514$ vi tahani-data/calendar.txt
(adds content to calendar.txt)

[cs124w@ieng6-203]:src:515$ cat tahani-data/calendar.txt
Monday, 2pm: work on pa2
Wednesday, 11am: go to RIMAC

[cs124w@ieng6-203]:src:517$ ./ss tahani.ini
[13:16:45.412] [info] [thread 25788] Launching SurfStore client
[13:16:45.412] [info] [thread 25788] Server host: localhost
[13:16:45.413] [info] [thread 25788] Server port: 15112
[13:16:45.415] [info] [thread 25788] Calling Sync
...logging output from your program...
[13:16:45.426] [info] [thread 25788] sync complete

[cs124w@ieng6-203]:src:518$ ls jianyu-data/

[cs124w@ieng6-203]:src:519$ ./ss jianyu.ini
[13:17:14.982] [info] [thread 26078] Launching SurfStore client
[13:17:14.983] [info] [thread 26078] Server host: localhost
[13:17:14.983] [info] [thread 26078] Server port: 15112
[13:17:14.985] [info] [thread 26078] Calling Sync
...logging output from your program...
[13:17:14.997] [info] [thread 26078] sync complete

[cs124w@ieng6-203]:src:520$ ls jianyu-data/
calendar.txt  index.txt

[cs124w@ieng6-203]:src:521$ cat jianyu-data/calendar.txt
Monday, 2pm: work on pa2
Wednesday, 11am: go to RIMAC

[cs124w@ieng6-203]:src:523$ diff -s tahani-data/calendar.txt jianyu-data/calenda
r.txt
Files tahani-data/calendar.txt and jianyu-data/calendar.txt are identical
[cs124w@ieng6-203]:src:524$

OK great, the calendar file sync’d from Tahani’s computer to the cloud, then to Jianyu’s computer. Now let’s have Jianyu update calendar.txt, and sync his changes to the cloud, and then Tahani can sync from the cloud to get the changes:

[cs124w@ieng6-203]:src:524$ vi jianyu-data/calendar.txt
(adds a new entry to the calendar)

[cs124w@ieng6-203]:src:525$ cat jianyu-data/calendar.txt
Monday, 2pm: work on pa2
Wednesday, 11am: go to RIMAC
Friday, 9am: study session in Geisel Library

[cs124w@ieng6-203]:src:526$ ./ss jianyu.ini
[13:23:04.465] [info] [thread 1550] Launching SurfStore client
[13:23:04.465] [info] [thread 1550] Server host: localhost
[13:23:04.465] [info] [thread 1550] Server port: 15112
[13:23:04.466] [info] [thread 1550] Calling Sync
...logging output from your program...
[13:23:04.476] [info] [thread 1550] sync complete

[cs124w@ieng6-203]:src:527$ cat tahani-data/calendar.txt
Monday, 2pm: work on pa2
Wednesday, 11am: go to RIMAC

[cs124w@ieng6-203]:src:528$ ./ss tahani.ini
[13:23:16.610] [info] [thread 1848] Launching SurfStore client
[13:23:16.610] [info] [thread 1848] Server host: localhost
[13:23:16.610] [info] [thread 1848] Server port: 15112
[13:23:16.612] [info] [thread 1848] Calling Sync
...logging output from your program...
[13:23:16.622] [info] [thread 1848] sync complete

[cs124w@ieng6-203]:src:529$ cat tahani-data/calendar.txt
Monday, 2pm: work on pa2
Wednesday, 11am: go to RIMAC
Friday, 9am: study session in Geisel Library

[cs124w@ieng6-203]:src:530$

Now let’s imagine that both Tahani and Jianyu locally edit calendar.txt with different entries (a write-write conflict):

[cs124w@ieng6-203]:src:530$ vi tahani-data/calendar.txt
(adds office hours Friday afternoon)

[cs124w@ieng6-203]:src:531$ vi jianyu-data/calendar.txt
(adds a research talk Friday afternoon)

[cs124w@ieng6-203]:src:532$ cat tahani-data/calendar.txt
Monday, 2pm: work on pa2
Wednesday, 11am: go to RIMAC
Friday, 9am: study session in Geisel Library
Friday, 3pm: go to office hours

[cs124w@ieng6-203]:src:533$ cat jianyu-data/calendar.txt
Monday, 2pm: work on pa2
Wednesday, 11am: go to RIMAC
Friday, 9am: study session in Geisel Library
Friday, 3pm: go to a research talk

[cs124w@ieng6-203]:src:534$ diff tahani-data/calendar.txt jianyu-data/calendar.t
xt
4c4
< Friday, 3pm: go to office hours
---
> Friday, 3pm: go to a research talk

[cs124w@ieng6-203]:src:535$

Let’s assume that Jianyu’s changes get sync’d to the cloud first.

[cs124w@ieng6-203]:src:535$ ./ss jianyu.ini
[13:28:35.862] [info] [thread 8778] Launching SurfStore client
[13:28:35.862] [info] [thread 8778] Server host: localhost
[13:28:35.862] [info] [thread 8778] Server port: 15112
[13:28:35.863] [info] [thread 8778] Calling Sync
...output...
[13:28:35.874] [info] [thread 8778] sync complete
[cs124w@ieng6-203]:src:536$

Now what happens when Tahani calls sync?

[cs124w@ieng6-203]:src:536$ ./ss tahani.ini
[13:29:09.080] [info] [thread 9546] Launching SurfStore client
[13:29:09.080] [info] [thread 9546] Server host: localhost
[13:29:09.080] [info] [thread 9546] Server port: 15112
[13:29:09.083] [info] [thread 9546] Calling Sync
...output...
[13:29:09.099] [info] [thread 9546] sync complete

[cs124w@ieng6-203]:src:537$ cat tahani-data/calendar.txt
Monday, 2pm: work on pa2
Wednesday, 11am: go to RIMAC
Friday, 9am: study session in Geisel Library
Friday, 3pm: go to a research talk

[cs124w@ieng6-203]:src:538$ diff -s tahani-data/calendar.txt jianyu-data/calenda
r.txt
Files tahani-data/calendar.txt and jianyu-data/calendar.txt are identical

[cs124w@ieng6-203]:src:539$

Indeed, Tahani’s local copy of calendar.txt was overwritten by Jianyu’s because his calendar was sync’d to the cloud first.

Let’s next assume that Tahani deletes the calendar file:

[cs124w@ieng6-203]:src:539$ rm tahani-data/calendar.txt
[cs124w@ieng6-203]:src:540$ ./ss tahani.ini
[13:30:41.235] [info] [thread 13301] Launching SurfStore client
[13:30:41.235] [info] [thread 13301] Server host: localhost
[13:30:41.236] [info] [thread 13301] Server port: 15112
[13:30:41.238] [info] [thread 13301] Calling Sync
...output...
[13:30:41.252] [info] [thread 13301] sync complete
[cs124w@ieng6-203]:src:541$

What happens to Jianyu’s calendar?

[cs124w@ieng6-203]:src:541$ ls jianyu-data/calendar.txt
jianyu-data/calendar.txt

[cs124w@ieng6-203]:src:542$ ./ss jianyu.ini
[13:31:19.028] [info] [thread 14079] Launching SurfStore client
[13:31:19.029] [info] [thread 14079] Server host: localhost
[13:31:19.029] [info] [thread 14079] Server port: 15112
[13:31:19.031] [info] [thread 14079] Calling Sync
...output...
[13:31:19.043] [info] [thread 14079] sync complete

[cs124w@ieng6-203]:src:543$ ls jianyu-data/
index.txt

[cs124w@ieng6-203]:src:544$

calendar.txt has been deleted for both Jianyu and Tahani.