diff --git a/README.md b/README.md index 12dfd0d4935fb2929b289f1326bc633b3ec93a94..9123b4bb5abf05bd6c3a8735039c26b30508e959 100644 --- a/README.md +++ b/README.md @@ -120,30 +120,83 @@ At end-of-text (CTRL-D), `transactionalClient` prints the contents of the K/V store and committed transactions. ## Testing - +Your `transactionalClient.go` should take a `-p` option, which will tell your code to do +two things: +- write a commit/abort notification for each transaction as it's fate is decided +- at end-of-text write out the contents of your KV store, ordered lexicographically by key value. Only + written values need be printed. ### Strict Serializability -One example. Time is going downwards. Note that transaction *1* of client *1* is different from transaction *1* of client *2*. +One example. Time is going downwards. Note that transaction *1* of client *1* is different +from transaction *1* of client *2*. You can type these in interactively. R1 R2 - 1,1,r,A - 1,1,w,B,nice + 1,1,w,A,0 + 1,1,w,B,0 + 1,1,commit + 1,2,r,A + 1,2,w,B,nice 2,1,r,A - 2,1,w,C,foo - 2,2,w,A + 2,1,w,B,foo + 2,2,w,A,bar 2,2,r,B 2,2,commit 2,1,commit + 1,2,commit + +If one of the clients was invoked with option `-p`, it should print: +``` +trans 1.1 commit +trans 2.2 commit +trans 2.1 abort +trans 1.2 abort +A='bar' +B='0' +``` +--- +And another: + + R1 R2 + 1,1,w,A,0 + 1,1,w,B,0 1,1,commit + 1,2,w,A,1 + 1,1,r,B + 2,1,w,B,1 + 2,1,r,A + 2,1,commit + 1,2,commit -Your client should print: +Your client w/ `-p` should print: ``` - trans 2.2 commit - trans 2.1 abort - trans 1.1 abort +trans 1.1 commit +trans 2.1 commit +trans 1.2 abort +A='0' +B='1' ``` +### Snapshot Isolation +Under snapshot isolation, the above two examples will print: + +``` +trans 1.1 commit +trans 2.2 commit +trans 2.1 commit +trans 1.2 abort +A='bar' +B='foo' +``` +and +``` +trans 1.1 commit +trans 2.1 commit +trans 1.2 abort +A='1' +B='1' +``` + ## Submitting Submit by uploading tarball `cd /vagrant/go/src/818f19/p5; tar cvfz DIRID.tgz DIRID`, w/ your directory ID substituted in for "DIRID". diff --git a/go/src/818f19/p5/DIRID/client/transactionalClient.go b/go/src/818f19/p5/DIRID/client/transactionalClient.go index 8067ebbd168e08809aeccd19bb750965e25315b5..8742cf4681f84c9d9a9ac599352cfcffa19d92e6 100644 --- a/go/src/818f19/p5/DIRID/client/transactionalClient.go +++ b/go/src/818f19/p5/DIRID/client/transactionalClient.go @@ -41,6 +41,7 @@ var ( servers []pb.KVClient log = []pb.CommandString{} store = make(map[string]string) + doPrint = false ) //===================================================================== @@ -54,7 +55,7 @@ func main() { store["bar"] = "4 2" for { - if c := Getopt("c:dN:r:"); c == EOF { + if c := Getopt("c:dN:pr:"); c == EOF { break } else { switch c { @@ -68,6 +69,9 @@ func main() { case 'N': N, _ = strconv.Atoi(OptArg) + case 'p': + doPrint = !doPrint + case 'r': repID, _ = strconv.Atoi(OptArg)