// GetList // function: // - fetch stored list value with the key // - register lease func (ss *Storageserver) GetList(args *storageproto.GetArgs, reply *storageproto.GetListReply) error { if !ss.isKeyInRange(args.Key) { reply.Status = storageproto.EWRONGSERVER return nil } req := &cacheReq{GET_LIST_VALUE, args.Key, ""} replyc := make(chan interface{}) ss.cacheReqC <- Request{req, replyc} valueList := <-replyc if valueList != nil { lsplog.Vlogf(5, "Return Value List %s", args.Key) reply.Status = storageproto.OK reply.Value = valueList.([]string) // lease if args.WantLease { req := &cacheReq{PUT_LEASE, args.Key, args.LeaseClient} replyc := make(chan interface{}) ss.cacheReqC <- Request{req, replyc} status := (<-replyc).(bool) if status { lsplog.Vlogf(5, "Get Lease successfully %s", args.Key) reply.Lease.Granted = true reply.Lease.ValidSeconds = storageproto.LEASE_SECONDS } else { lsplog.Vlogf(5, "Get Lease failed %s", args.Key) reply.Lease.Granted = false } } else { reply.Lease.Granted = false } } else { lsplog.Vlogf(5, "Value not found %s", args.Key) reply.Status = storageproto.EITEMNOTFOUND } return nil }