Esempio n. 1
0
func (ls *libstore) RevokeLease(args *storagerpc.RevokeLeaseArgs, reply *storagerpc.RevokeLeaseReply) error {
	ls.sMutex.Lock()
	_, ok := ls.sCache[args.Key]
	if ok {
		delete(ls.sCache, args.Key)
		ls.sMutex.Unlock()
		reply.Status = storagerpc.OK
		return nil
	}
	ls.sMutex.Unlock()

	ls.lMutex.Lock()
	_, ok = ls.lCache[args.Key]
	if ok {
		delete(ls.lCache, args.Key)
		ls.lMutex.Unlock()
		reply.Status = storagerpc.OK
		return nil
	}
	ls.lMutex.Unlock()

	// Both not found
	reply.Status = storagerpc.KeyNotFound
	return nil
}
Esempio n. 2
0
func (ls *libstore) RevokeLease(args *storagerpc.RevokeLeaseArgs, reply *storagerpc.RevokeLeaseReply) error {
	err := ls.localCache.Revoke(args.Key)
	if err == nil {
		reply.Status = storagerpc.OK
	} else {
		reply.Status = storagerpc.KeyNotFound
	}
	return nil
}
Esempio n. 3
0
func (ls *libstore) RevokeLease(args *storagerpc.RevokeLeaseArgs, reply *storagerpc.RevokeLeaseReply) error {
	//fmt.Println("Revoke Happened!")
	ok := ls.leases.Revoke(args.Key)

	if ok == true {
		reply.Status = storagerpc.OK
	} else {
		reply.Status = storagerpc.KeyNotFound
	}
	return nil
}
Esempio n. 4
0
func (ls *libstore) RevokeLease(args *storagerpc.RevokeLeaseArgs, reply *storagerpc.RevokeLeaseReply) error {
	key := args.Key
	if !ls.cacheValid[key] {
		delete(ls.cacheGet, key)
		delete(ls.cacheList, key)
		reply.Status = storagerpc.KeyNotFound
	}
	ls.cacheValid[key] = false
	delete(ls.cacheGet, key)
	delete(ls.cacheList, key)
	reply.Status = storagerpc.OK
	return nil
}
Esempio n. 5
0
func (ls *libstore) RevokeLease(args *storagerpc.RevokeLeaseArgs, reply *storagerpc.RevokeLeaseReply) error {
	reply.Status = storagerpc.OK

	if _, ok := ls.stringCache[args.Key]; ok {
		delete(ls.stringCache, args.Key)
	} else if _, ok := ls.listCache[args.Key]; ok {
		delete(ls.listCache, args.Key)
	} else {
		reply.Status = storagerpc.KeyNotFound
	}

	return nil
}
func (ls *libstore) RevokeLease(args *storagerpc.RevokeLeaseArgs, reply *storagerpc.RevokeLeaseReply) error {
	fmt.Println("RevodeLease Called:", args.Key, ls.callback)
	ls.dMutex.Lock()
	defer ls.dMutex.Unlock()

	_, ok := ls.dataCache[args.Key]
	if ok {
		reply.Status = storagerpc.OK
		delete(ls.dataCache, args.Key)
	} else {
		reply.Status = storagerpc.KeyNotFound
	}

	return nil
}
Esempio n. 7
0
func (ls *libstore) RevokeLease(args *storagerpc.RevokeLeaseArgs, reply *storagerpc.RevokeLeaseReply) error {

	_, isInCache := ls.dataMap[args.Key]

	if !isInCache {
		reply.Status = storagerpc.KeyNotFound
		return nil
	}

	ls.dataMapLock.Lock()
	delete(ls.dataMap, args.Key)
	ls.dataMapLock.Unlock()
	reply.Status = storagerpc.OK
	return nil
}
Esempio n. 8
0
func (st *storageTester) RevokeLease(args *storagerpc.RevokeLeaseArgs, reply *storagerpc.RevokeLeaseReply) error {
	st.recvRevoke[args.Key] = true
	st.compRevoke[args.Key] = false
	time.Sleep(time.Duration(st.delay*1000) * time.Millisecond)
	st.compRevoke[args.Key] = true
	reply.Status = storagerpc.OK
	return nil
}
Esempio n. 9
0
func (ls *libstore) RevokeLease(args *storagerpc.RevokeLeaseArgs, reply *storagerpc.RevokeLeaseReply) error {
	ls.cache.Lock()
	defer ls.cache.Unlock()

	delete(ls.cache.c, args.Key)
	reply.Status = storagerpc.OK

	return nil
}
Esempio n. 10
0
func (st *storageTester) RevokeLease(args *storagerpc.RevokeLeaseArgs, reply *storagerpc.RevokeLeaseReply) error {
	LOGE.Println("RevokeLease")
	defer LOGE.Print("RevokeLease Finished")
	st.recvRevoke[args.Key] = true
	st.compRevoke[args.Key] = false
	time.Sleep(time.Duration(st.delay*500) * time.Millisecond)
	st.compRevoke[args.Key] = true
	reply.Status = storagerpc.OK
	return nil
}
Esempio n. 11
0
func (ls *libstore) RevokeLease(args *storagerpc.RevokeLeaseArgs, reply *storagerpc.RevokeLeaseReply) error {
	ls.value_cache_locker.Lock()
	if _, ok := ls.value_cache[args.Key]; ok {
		delete(ls.value_cache, args.Key)
		reply.Status = storagerpc.OK
		ls.value_cache_locker.Unlock()
		return nil
	}
	ls.value_cache_locker.Unlock()
	ls.list_cache_locker.Lock()
	if _, ok := ls.list_cache[args.Key]; ok {
		delete(ls.list_cache, args.Key)
		reply.Status = storagerpc.OK
		ls.list_cache_locker.Unlock()
		return nil
	}
	ls.list_cache_locker.Unlock()
	reply.Status = storagerpc.KeyNotFound
	return nil
}
Esempio n. 12
0
func (ls *libstore) RevokeLease(args *storagerpc.RevokeLeaseArgs, reply *storagerpc.RevokeLeaseReply) error {
	// return errors.New("not implemented")
	key := args.Key
	ls.newGetMutex(key)
	ls.newListMutex(key)
	ls.queryGetMutex[key].Lock()
	ls.queryListMutex[key].Lock()
	defer ls.queryGetMutex[key].Unlock()
	defer ls.queryListMutex[key].Unlock()

	_, isvalue := ls.CacheValueSet[key]
	_, islist := ls.CacheListSet[key]
	if isvalue {
		reply.Status = storagerpc.OK
		delete(ls.CacheValueSet, key)
	} else if islist {
		reply.Status = storagerpc.OK
		delete(ls.CacheListSet, key)
	} else {
		reply.Status = storagerpc.KeyNotFound
	}
	return nil
}
Esempio n. 13
0
func (ls *libstore) RevokeLease(args *storagerpc.RevokeLeaseArgs, reply *storagerpc.RevokeLeaseReply) error {
	ls.initiateKeyValueMutex(args.Key)
	ls.initiateKeyListMutex(args.Key)
	ls.keyValueMutex[args.Key].Lock()
	defer ls.keyValueMutex[args.Key].Unlock()
	ls.keyListMutex[args.Key].Lock()
	defer ls.keyListMutex[args.Key].Unlock()

	_, okvalue := ls.keyValue[args.Key]
	_, oklist := ls.keylist[args.Key]
	if okvalue || oklist {
		reply.Status = storagerpc.OK
		if okvalue {
			delete(ls.keyValue, args.Key)
		} else {
			delete(ls.keylist, args.Key)
		}

	} else {
		reply.Status = storagerpc.KeyNotFound
	}

	return nil
}