Пример #1
0
func (pc *ProxyCounter) GetList(args *storageproto.GetArgs, reply *storageproto.GetListReply) error {
	if pc.override {
		reply.Status = pc.overrideStatus
		return pc.overrideErr
	}
	byteCount := len(args.Key)
	if args.WantLease {
		atomic.AddUint32(&pc.leaseRequestCount, 1)
	}
	if pc.disableLease {
		args.WantLease = false
	}
	err := pc.srv.Call("StorageRPC.GetList", args, reply)
	for _, s := range reply.Value {
		byteCount += len(s)
	}
	if reply.Lease.Granted {
		if pc.overrideLeaseSeconds > 0 {
			reply.Lease.ValidSeconds = pc.overrideLeaseSeconds
		}
		atomic.AddUint32(&pc.leaseGrantedCount, 1)
	}
	atomic.AddUint32(&pc.rpcCount, 1)
	atomic.AddUint32(&pc.byteCount, uint32(byteCount))
	return err
}
Пример #2
0
func (ss *StorageServer) GetList(args *sp.GetArgs, reply *sp.GetListReply) error {
	ss.mu.RLock()
	value, present := ss.hashmap[args.Key]
	ss.mu.RUnlock()

	if !present {
		lsplog.Vlogf(3, "[StorageServer] GetList key: %s nonexist\n", args.Key)
		reply.Status = sp.EKEYNOTFOUND
		return nil
	}

	json.Unmarshal(value, &(reply.Value))
	if args.WantLease {
		ss.addLeasePool(args, &reply.Lease)
	}
	reply.Status = sp.OK
	return nil
}