Skip to content
Snippets Groups Projects
Commit a4d03d7e authored by keleher's avatar keleher
Browse files

auto

parent e87ddbad
No related branches found
No related tags found
No related merge requests found
...@@ -120,30 +120,83 @@ At end-of-text (CTRL-D), `transactionalClient` prints the contents of the K/V ...@@ -120,30 +120,83 @@ At end-of-text (CTRL-D), `transactionalClient` prints the contents of the K/V
store and committed transactions. store and committed transactions.
## Testing ## 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 ### 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 R1 R2
1,1,r,A 1,1,w,A,0
1,1,w,B,nice 1,1,w,B,0
1,1,commit
1,2,r,A
1,2,w,B,nice
2,1,r,A 2,1,r,A
2,1,w,C,foo 2,1,w,B,foo
2,2,w,A 2,2,w,A,bar
2,2,r,B 2,2,r,B
2,2,commit 2,2,commit
2,1,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,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 1.1 commit
trans 2.1 abort trans 2.1 commit
trans 1.1 abort 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 ## Submitting
Submit by uploading tarball `cd /vagrant/go/src/818f19/p5; tar cvfz DIRID.tgz DIRID`, w/ Submit by uploading tarball `cd /vagrant/go/src/818f19/p5; tar cvfz DIRID.tgz DIRID`, w/
your directory ID substituted in for "DIRID". your directory ID substituted in for "DIRID".
......
...@@ -41,6 +41,7 @@ var ( ...@@ -41,6 +41,7 @@ var (
servers []pb.KVClient servers []pb.KVClient
log = []pb.CommandString{} log = []pb.CommandString{}
store = make(map[string]string) store = make(map[string]string)
doPrint = false
) )
//===================================================================== //=====================================================================
...@@ -54,7 +55,7 @@ func main() { ...@@ -54,7 +55,7 @@ func main() {
store["bar"] = "4 2" store["bar"] = "4 2"
for { for {
if c := Getopt("c:dN:r:"); c == EOF { if c := Getopt("c:dN:pr:"); c == EOF {
break break
} else { } else {
switch c { switch c {
...@@ -68,6 +69,9 @@ func main() { ...@@ -68,6 +69,9 @@ func main() {
case 'N': case 'N':
N, _ = strconv.Atoi(OptArg) N, _ = strconv.Atoi(OptArg)
case 'p':
doPrint = !doPrint
case 'r': case 'r':
repID, _ = strconv.Atoi(OptArg) repID, _ = strconv.Atoi(OptArg)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment