Esempio n. 1
0
// RemoveFromList
// function:
// - remove key and list value from storage
func (ss *Storageserver) RemoveFromList(args *storageproto.PutArgs, reply *storageproto.PutReply) error {
	req := &cacheReq{REMOVE_LIST_VALUE, args.Key, args.Value}
	replyc := make(chan interface{})
	ss.cacheReqC <- Request{req, replyc}
	status := (<-replyc).(bool)
	if status {
		lsplog.Vlogf(5, "Remove key successfully %s %s", args.Key, args.Value)
		reply.Status = storageproto.OK
	} else {
		lsplog.Vlogf(5, "Remove key failed %s %s", args.Key, args.Value)
		reply.Status = storageproto.EITEMNOTFOUND
	}

	return nil
}
Esempio n. 2
0
// AppendToList
// function:
// - put key and list value into storage
func (ss *Storageserver) AppendToList(args *storageproto.PutArgs, reply *storageproto.PutReply) error {
	req := &cacheReq{APPEND_LIST_VALUE, args.Key, args.Value}
	replyc := make(chan interface{})
	ss.cacheReqC <- Request{req, replyc}
	status := (<-replyc).(bool)
	if status {
		lsplog.Vlogf(5, "Append key successfully %s %s", args.Key, args.Value)
		reply.Status = storageproto.OK
	} else {
		lsplog.Vlogf(5, "Append key failed %s %s", args.Key, args.Value)
		reply.Status = storageproto.EITEMEXISTS
	}

	return nil
}
Esempio n. 3
0
// Put
// function:
// - put key value into storage
func (ss *Storageserver) Put(args *storageproto.PutArgs, reply *storageproto.PutReply) error {
	req := &cacheReq{PUT_VALUE, args.Key, args.Value}
	replyc := make(chan interface{})
	ss.cacheReqC <- Request{req, replyc}
	<-replyc
	lsplog.Vlogf(5, "Put key successfully %s %s", args.Key, args.Value)
	reply.Status = storageproto.OK

	return nil
}
Esempio n. 4
0
func (pc *ProxyCounter) RemoveFromList(args *storageproto.PutArgs, reply *storageproto.PutReply) error {
	if pc.override {
		reply.Status = pc.overrideStatus
		return pc.overrideErr
	}
	byteCount := len(args.Key) + len(args.Value)
	err := pc.srv.Call("StorageRPC.RemoveFromList", args, reply)
	atomic.AddUint32(&pc.rpcCount, 1)
	atomic.AddUint32(&pc.byteCount, uint32(byteCount))
	return err
}