Skip to content

Commit

Permalink
Back to insert secuentially on Redis. WIP: batch inserts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Luis Lucas committed Nov 29, 2018
1 parent 0575511 commit 6b47c3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/gossip/run_gossip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publisher="http://127.0.0.1:8888"
qed="http://127.0.0.1:8080"
echo Create id_ed25519 key
echo -e 'y\n' | ssh-keygen -t rsa -N '' -f /var/tmp/id_ed25519
go run $GOPATH/src/github.com/bbva/qed/main.go start -k key -l silent --node-id server0 --gossip-addr $master --raft-addr 127.0.0.1:9000 -y $/var/tmp/id_ed25519 &
go run $GOPATH/src/github.com/bbva/qed/main.go start -k key -l silent --node-id server0 --gossip-addr $master --raft-addr 127.0.0.1:9000 &
pids[0]=$!
sleep 1s

Expand Down
14 changes: 8 additions & 6 deletions tests/gossip/test_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ func (c *RedisCli) QueueCommands(key string, value []byte) {

func (c *RedisCli) Execute() {
// err := c.rcli.Set(key, value, 0).Err()
_, err := c.rcli.Pipeline().Exec()
cmds, err := c.rcli.Pipeline().Exec()
if err != nil {
panic(err)
}
fmt.Println(cmds)
}

// TODO: SeMaaS
Expand Down Expand Up @@ -141,15 +142,16 @@ func PublishHandler(w http.ResponseWriter, r *http.Request, client *RedisCli) {
var buf bytes.Buffer
encoder := codec.NewEncoder(&buf, &codec.MsgpackHandle{})

for i, s := range b.Snapshots {
for _, s := range b.Snapshots {
key := strconv.FormatUint(s.Snapshot.Version, 10)

_ = encoder.Encode(s)
_ = client.rcli.Set(key, buf.Bytes(), 0).Err()

client.QueueCommands(key, buf.Bytes())
if i%len(b.Snapshots) == 0 {
go client.Execute()
}
// client.QueueCommands(key, buf.Bytes())
// if i%len(b.Snapshots) == 0 {
// go client.Execute()
// }
}

} else {
Expand Down

0 comments on commit 6b47c3e

Please sign in to comment.