func (self *BitcaskStore) migrate(host string, left, right uint32) { keyChan := self.bc.Keys() target := protocol.NewHost(host) for key := range keyChan { v := crc32hash([]byte(key)) if (left < right && v >= left && v < right) || (left > right && !(v >= left && v < right)) { v, e := self.bc.Get(key) if e == nil { target.Set(key, &protocol.Item{Body: v}, false) } } } }
func (self *BitcaskStore) Set(key string, item *protocol.Item, noreply bool) (bool, error) { if len(key) > 3 && strings.Contains(key, "@#$") { pos := strings.Index(key, "@#$") target := protocol.NewHost(key[pos+3:]) key = key[:pos] self.chF <- func() { for { if ok, _ := target.Set(key, item, noreply); ok { break } } } } e := self.bc.Set(key, item.Body) if e != nil { return false, e } return true, nil }