Example #1
0
func (self *Slave) spinner() {
	var kv []byte
	for self.hasState(started) {
		kv = murmur.HashInt64(rand.Int63n(self.maxKey))
		self.client.Put(kv, kv)
		atomic.AddInt64(&self.req, 1)
	}
}
Example #2
0
func (self *Slave) Prepare(command PrepareCommand, x *Nothing) error {
	if self.hasState(stopped) {
		fmt.Printf("Preparing %+v\n", command)
		self.client = client.MustConn(command.Addr)
		var kv []byte
		for i := command.Range[0]; i < command.Range[1]; i++ {
			kv = murmur.HashInt64(i)
			self.client.Put(kv, kv)
			if i%1000 == 0 {
				fmt.Print(".")
			}
		}
		fmt.Println("done!")
	}
	return nil
}