Esempio n. 1
0
func (p *Partitioner) MoveObject(obj *storage.MetaDataObj) {
	if obj != nil {
		if !util.Contains(p.serverNode.Node.HashRange, obj.Hash) {
			log.Printf("Moving key = %s\r\n", obj.Key)
			p.outcomingQueue.Enqueu(&command.Command{OpCode: "move", Obj: obj.MetaDataUpdObj()})
		}
	}
}
Esempio n. 2
0
// Add an item to the storage.
func (ks *InMemoryStorage) Put(obj *storage.MetaDataObj) error {
	if obj != nil {
		if len(obj.Key) == 0 {
			return errors.New("Object key is null.")
		}
		if len(obj.Collection) == 0 {
			obj.Collection = "default"
		}
		obj.CreationDate = time.Now()
		ks.collection.Put(obj)
		if obj.TTL > 0 {
			go ks.cleaner.AddElement(obj)
		}
	}
	return errors.New("Object is null.")
}
Esempio n. 3
0
func NewMetaDataObj(req *OvoKVRequest) *storage.MetaDataObj {
	var obj = new(storage.MetaDataObj)
	obj.Key = req.Key
	obj.Data = req.Data
	obj.Collection = req.Collection
	obj.TTL = req.TTL
	obj.Hash = req.Hash
	return obj
}