Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for two classes of clients experiment #16

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ fi

# Usage of ./bin/client:
# -c int
# Percentage of conflicts. Defaults to 0%
# Percentage of conflicts. Defaults to 0. If the conflict rate is 142, two classes of clients (conflict and non-conflicting) are created.
# -e Egalitarian (no leader).
# -f Fast Paxos: send message directly to all replicas.
# -id string
# the id of the client. Default is RFC 4122 nodeID.
# -maddr string
# Master address. Defaults to localhost
# -mport int
Expand All @@ -89,7 +87,7 @@ if [ "${TYPE}" == "client" ]; then
mkdir -p logs/

for i in $(seq 1 ${NCLIENTS}); do
${DIR}/client ${args} 2>&1 | tee -a logs/c_${i}.txt ${ALL} >/dev/null &
${DIR}/client -id ${i} ${args} 2>&1 | tee -a logs/c_${i}.txt ${ALL} >/dev/null &
echo "> Client $i of ${NCLIENTS} started!"
done

Expand Down
32 changes: 18 additions & 14 deletions src/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"
)

var clientId string = *flag.String("id", "", "the id of the client. Default is RFC 4122 nodeID.")
var id *int = flag.Int("id", 1, "The id of the client.")
var masterAddr *string = flag.String("maddr", "", "Master address. Defaults to localhost")
var masterPort *int = flag.Int("mport", 7087, "Master port. ")
var reqsNb *int = flag.Int("q", 1000, "Total number of requests. ")
Expand All @@ -22,7 +22,7 @@ var noLeader *bool = flag.Bool("e", false, "Egalitarian (no leader). ")
var fast *bool = flag.Bool("f", false, "Fast Paxos: send message directly to all replicas. ")
var localReads *bool = flag.Bool("l", false, "Execute reads at the closest (local) replica. ")
var procs *int = flag.Int("p", 2, "GOMAXPROCS. ")
var conflicts *int = flag.Int("c", 0, "Percentage of conflicts. Defaults to 0%")
var conflicts *int = flag.Int("c", 0, "Percentage of conflicts. Defaults to 0. If the conflict rate is 142, two classes of clients are created: one that issues conflicting commands, another that doesn't")
var verbose *bool = flag.Bool("v", false, "verbose mode. ")
var scan *bool = flag.Bool("s", false, "replace read with short scan (100 elements)")

Expand All @@ -34,10 +34,6 @@ func main() {

rand.Seed(time.Now().UnixNano())

if *conflicts > 100 {
log.Fatalf("Conflicts percentage must be between 0 and 100.\n")
}

var proxy *bindings.Parameters
for {
proxy = bindings.NewParameters(*masterAddr, *masterPort, *verbose, *noLeader, *fast, *localReads)
Expand All @@ -48,16 +44,13 @@ func main() {
proxy.Disconnect()
}

if clientId == "" {
clientId = uuid.New().String()
}

log.Printf("client: %v (verbose=%v, psize=%v, conflicts=%v)", clientId, *verbose, *psize, *conflicts)
log.Printf("client: %v (verbose=%v, psize=%v, conflicts=%v)", *id, *verbose, *psize, *conflicts)

karray := make([]state.Key, *reqsNb)
put := make([]bool, *reqsNb)

clientKey := state.Key(uint64(uuid.New().Time())) // a command id unique to this client.

for i := 0; i < *reqsNb; i++ {
put[i] = false
if *writes > 0 {
Expand All @@ -66,10 +59,21 @@ func main() {
put[i] = true
}
}

// maybe issue unique key per client
// issue 42 if:
// - two-class experiment and we have an even id
// - normal experiment and the random says so
karray[i] = clientKey
if *conflicts > 0 {
r := rand.Intn(100)
if r <= *conflicts {

if *conflicts == 142 {
// two-class experiment
if *id % 2 == 0 {
karray[i] = 42
}
} else {
// normal experiment
if rand.Intn(100) < *conflicts {
karray[i] = 42
}
}
Expand Down