Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
98 changed files
with
332,562 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pkg/ | ||
api.key | ||
*-handin.tar.gz | ||
cscope.files | ||
cscope.out |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# This is the Makefile helping you submit the labs. | ||
# Just create 6.824/api.key with your API key in it, | ||
# and submit your lab with the following command: | ||
# $ make [lab1|lab2a|lab2b|lab2c|lab3a|lab3b|lab4a|lab4b] | ||
|
||
LABS=" lab1 lab2a lab2b lab2c lab3a lab3b lab4a lab4b " | ||
|
||
%: | ||
@echo "Preparing $@-handin.tar.gz" | ||
@echo "Checking for committed temporary files..." | ||
@if git ls-files | grep -E 'mrtmp|mrinput' > /dev/null; then \ | ||
echo "" ; \ | ||
echo "OBS! You have committed some large temporary files:" ; \ | ||
echo "" ; \ | ||
git ls-files | grep -E 'mrtmp|mrinput' | sed 's/^/\t/' ; \ | ||
echo "" ; \ | ||
echo "Follow the instructions at http://stackoverflow.com/a/308684/472927" ; \ | ||
echo "to remove them, and then run make again." ; \ | ||
echo "" ; \ | ||
exit 1 ; \ | ||
fi | ||
@if echo $(LABS) | grep -q " $@ " ; then \ | ||
echo "Tarring up your submission..." ; \ | ||
tar cvzf $@-handin.tar.gz \ | ||
"--exclude=src/main/pg-*.txt" \ | ||
"--exclude=src/main/diskvd" \ | ||
"--exclude=src/mapreduce/824-mrinput-*.txt" \ | ||
"--exclude=mrtmp.*" \ | ||
"--exclude=src/main/diff.out" \ | ||
Makefile src; \ | ||
if ! test -e api.key ; then \ | ||
echo "Missing $(PWD)/api.key. Please create the file with your key in it or submit the $@-handin.tar.gz via the web interface."; \ | ||
else \ | ||
echo "Are you sure you want to submit $@? Enter 'yes' to continue:"; \ | ||
read line; \ | ||
if test "$$line" != "yes" ; then echo "Giving up submission"; exit; fi; \ | ||
if test `stat -c "%s" "$@-handin.tar.gz" 2>/dev/null || stat -f "%z" "$@-handin.tar.gz"` -ge 20971520 ; then echo "File exceeds 20MB."; exit; fi; \ | ||
mv api.key api.key.fix ; \ | ||
cat api.key.fix | tr -d '\n' > api.key ; \ | ||
rm api.key.fix ; \ | ||
curl -F file=@$@-handin.tar.gz -F "key=<api.key" \ | ||
https://6824.scripts.mit.edu/2017/handin.py/upload > /dev/null || { \ | ||
echo ; \ | ||
echo "Submit seems to have failed."; \ | ||
echo "Please upload the tarball manually on the submission website."; } \ | ||
fi; \ | ||
else \ | ||
echo "Bad target $@. Usage: make [$(LABS)]"; \ | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
export GOPATH=$PWD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
*.*/ | ||
mrtmp.* | ||
824-mrinput-*.txt | ||
/main/diff.out | ||
/mapreduce/x.txt | ||
/pbservice/x.txt | ||
/kvpaxos/x.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package raftkv | ||
|
||
import "labrpc" | ||
import "crypto/rand" | ||
import "math/big" | ||
|
||
|
||
type Clerk struct { | ||
servers []*labrpc.ClientEnd | ||
// You will have to modify this struct. | ||
} | ||
|
||
func nrand() int64 { | ||
max := big.NewInt(int64(1) << 62) | ||
bigx, _ := rand.Int(rand.Reader, max) | ||
x := bigx.Int64() | ||
return x | ||
} | ||
|
||
func MakeClerk(servers []*labrpc.ClientEnd) *Clerk { | ||
ck := new(Clerk) | ||
ck.servers = servers | ||
// You'll have to add code here. | ||
return ck | ||
} | ||
|
||
// | ||
// fetch the current value for a key. | ||
// returns "" if the key does not exist. | ||
// keeps trying forever in the face of all other errors. | ||
// | ||
// you can send an RPC with code like this: | ||
// ok := ck.servers[i].Call("RaftKV.Get", &args, &reply) | ||
// | ||
// the types of args and reply (including whether they are pointers) | ||
// must match the declared types of the RPC handler function's | ||
// arguments. and reply must be passed as a pointer. | ||
// | ||
func (ck *Clerk) Get(key string) string { | ||
|
||
// You will have to modify this function. | ||
return "" | ||
} | ||
|
||
// | ||
// shared by Put and Append. | ||
// | ||
// you can send an RPC with code like this: | ||
// ok := ck.servers[i].Call("RaftKV.PutAppend", &args, &reply) | ||
// | ||
// the types of args and reply (including whether they are pointers) | ||
// must match the declared types of the RPC handler function's | ||
// arguments. and reply must be passed as a pointer. | ||
// | ||
func (ck *Clerk) PutAppend(key string, value string, op string) { | ||
// You will have to modify this function. | ||
} | ||
|
||
func (ck *Clerk) Put(key string, value string) { | ||
ck.PutAppend(key, value, "Put") | ||
} | ||
func (ck *Clerk) Append(key string, value string) { | ||
ck.PutAppend(key, value, "Append") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package raftkv | ||
|
||
const ( | ||
OK = "OK" | ||
ErrNoKey = "ErrNoKey" | ||
) | ||
|
||
type Err string | ||
|
||
// Put or Append | ||
type PutAppendArgs struct { | ||
Key string | ||
Value string | ||
Op string // "Put" or "Append" | ||
// You'll have to add definitions here. | ||
// Field names must start with capital letters, | ||
// otherwise RPC will break. | ||
} | ||
|
||
type PutAppendReply struct { | ||
WrongLeader bool | ||
Err Err | ||
} | ||
|
||
type GetArgs struct { | ||
Key string | ||
// You'll have to add definitions here. | ||
} | ||
|
||
type GetReply struct { | ||
WrongLeader bool | ||
Err Err | ||
Value string | ||
} |
Oops, something went wrong.