From a4d03d7efe9f0f800949a95a5dc02445e290d6ff Mon Sep 17 00:00:00 2001
From: keleher <keleher@cs.umd.edu>
Date: Tue, 3 Dec 2019 17:00:10 -0500
Subject: [PATCH] auto

---
 README.md                                     | 73 ++++++++++++++++---
 .../p5/DIRID/client/transactionalClient.go    |  6 +-
 2 files changed, 68 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 12dfd0d..9123b4b 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 8067ebb..8742cf4 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)
 
-- 
GitLab