• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang storagerpc.DeleteReply类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cmu440/tribbler/rpc/storagerpc.DeleteReply的典型用法代码示例。如果您正苦于以下问题:Golang DeleteReply类的具体用法?Golang DeleteReply怎么用?Golang DeleteReply使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DeleteReply类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Delete

func (ss *storageServer) Delete(args *storagerpc.DeleteArgs, reply *storagerpc.DeleteReply) error {
	if !ss.IsKeyInRange(args.Key) {
		reply.Status = storagerpc.WrongServer
		return nil
	}

	ss.lockForTableLocks.Lock()
	/* Lock table for writing */
	lock, exist := ss.tableLocks[args.Key]
	if !exist {
		lock = new(sync.Mutex)
		ss.tableLocks[args.Key] = lock
	}
	ss.lockForTableLocks.Unlock()
	lock.Lock()
	defer lock.Unlock()

	ss.RevokeLease(args.Key)

	_, exist = ss.stringTable[args.Key]
	if !exist {
		reply.Status = storagerpc.KeyNotFound
	} else {

		delete(ss.stringTable, args.Key)
		reply.Status = storagerpc.OK
	}
	return nil
}
开发者ID:mallocanswer,项目名称:Tribbler,代码行数:29,代码来源:storageserver_impl.go


示例2: Delete

func (ss *storageServer) Delete(args *storagerpc.DeleteArgs, reply *storagerpc.DeleteReply) error {

	key := args.Key

	if !correctServer(ss, key) {
		reply.Status = storagerpc.WrongServer
		return nil
	}

	leases := getLeases(ss, key)
	if leases != nil {
		ss.editLock.Lock()
		revokeLease(ss, key)
		ss.editLock.Unlock()
	}
	ss.valMapLock.Lock()
	defer ss.valMapLock.Unlock()

	_, in := ss.valMap[key]
	if !in {
		reply.Status = storagerpc.KeyNotFound
	} else {
		delete(ss.valMap, key)
		reply.Status = storagerpc.OK
	}

	return nil

}
开发者ID:jbuckman,项目名称:p2-440,代码行数:29,代码来源:storageserver_impl.go


示例3: Delete

// Delete remove the specified key from the data store.
// If the key does not fall within the storage server's range,
// it should reply with status WrongServer.
// If the key is not found, it should reply with status KeyNotFound.
func (ss *storageServer) Delete(args *storagerpc.DeleteArgs, reply *storagerpc.DeleteReply) error {

	//	fmt.Println("Delete function Called",args)
	if FindPartitionNode(ss.ring, args.Key).NodeID != ss.nodeID {
		reply.Status = storagerpc.WrongServer
		return nil
	}

	// lock the whole storage first
	ss.sMutex.Lock()
	defer ss.sMutex.Unlock()

	// retrieve the data unit
	data, ok := ss.storage[args.Key]
	if ok {
		reply.Status = storagerpc.OK
		data.dMutex.Lock()
		// WARNING: here we might meet the situation of wild pointer.
		// that is the value is already deleted from the map, but the
		ss.RevokeCallBacksForKey(args.Key, data)
		data.dMutex.Unlock()

		// aplly changes
		delete(ss.storage, args.Key)

		return nil
	} else {
		reply.Status = storagerpc.KeyNotFound
		return nil
	}

	return nil
}
开发者ID:wentianqi7,项目名称:15640-distributed-systems,代码行数:37,代码来源:storageserver_impl.go


示例4: Delete

func (ss *storageServer) Delete(args *storagerpc.DeleteArgs, reply *storagerpc.DeleteReply) error {
	if ss.isReady == false {
		reply.Status = storagerpc.NotReady
	} else {
		if ss.getServerID(args.Key) != ss.nodeID {
			reply.Status = storagerpc.WrongServer
			return nil
		}
		ss.serverMutex.Lock()
		if ss.userValueMutex[args.Key] == nil {
			ss.userValueMutex[args.Key] = &sync.Mutex{}
		}
		ss.serverMutex.Unlock()
		ss.userValueMutex[args.Key].Lock()
		defer ss.userValueMutex[args.Key].Unlock()
		_, exist := ss.userValue[args.Key]
		if exist == false {
			reply.Status = storagerpc.KeyNotFound
		} else {
			// revoke all leases if already exist in server before
			err := ss.revokeLease(args.Key, ss.userValueLease[args.Key])
			if err != nil {
				return err
			}
			ss.userValueLease[args.Key] = make(map[string]*lease)

			reply.Status = storagerpc.OK
			delete(ss.userValue, args.Key)
		}
	}
	return nil
}
开发者ID:thuhujin,项目名称:Tribbler,代码行数:32,代码来源:storageserver_impl.go


示例5: Delete

func (ss *storageServer) Delete(args *storagerpc.DeleteArgs, reply *storagerpc.DeleteReply) error {
	if DBG {
		fmt.Println("Entered storageserver delete")
	}
	if !ss.inRange(libstore.StoreHash(args.Key)) {
		reply.Status = storagerpc.WrongServer
		return nil
	}

	_, ok := ss.dataStore[args.Key]
	if !ok {
		reply.Status = storagerpc.KeyNotFound
		return nil
	}

	// Leasing check
	ss.leaseLock.Lock()
	pendingModifications, ok := ss.pendingMap[args.Key]

	if !ok {
		reply.Status = storagerpc.KeyNotFound
		ss.leaseLock.Unlock()
		return nil
	}

	pendingModifications.pending++
	leaseHolders, ok := ss.leaseStore[args.Key]
	ss.leaseLock.Unlock()

	if pendingModifications.pending > 1 { // Block until it's our turn to modify key
		response := make(chan int)
		pendingModifications.pendingCh <- response
		<-response
	}

	if ok {
		ss.revokeLeases(leaseHolders, args.Key)
	}

	ss.dataLock.Lock()
	delete(ss.dataStore, args.Key)
	ss.dataLock.Unlock()
	reply.Status = storagerpc.OK
	pendingModifications.pending--
Loop:
	for {
		select {
		case ch := <-pendingModifications.pendingCh:
			ch <- 1
			break Loop
		default:
			break Loop
		}
	}
	return nil
}
开发者ID:aditij1,项目名称:p2aditijakkamat,代码行数:56,代码来源:storageserver_impl.go


示例6: Delete

func (ss *storageServer) Delete(args *storagerpc.DeleteArgs, reply *storagerpc.DeleteReply) error {
	if args == nil {
		return errors.New("ss: Can't delete nil K/V pair")
	}
	if reply == nil {
		return errors.New("ss: Can't reply with nil in Delete")
	}
	if !(ss.CheckKeyInRange(args.Key)) {
		reply.Status = storagerpc.WrongServer
		return nil
	}

	ss.sMutex.Lock()
	keyLock, exist := ss.keyLockMap[args.Key]
	if !exist {
		// Create new lock for the key
		keyLock = &sync.Mutex{}
		ss.keyLockMap[args.Key] = keyLock
	}
	ss.sMutex.Unlock()

	keyLock.Lock()
	defer keyLock.Unlock()

	_, ok := ss.sMap[args.Key]

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

	hpTimeMap, leaseExists := ss.leaseMap[args.Key]
	if leaseExists {
		// Revoke all issued leases.
		successChan := make(chan int, 1)
		finishChan := make(chan int, 1)
		expected := len(hpTimeMap)
		go ss.CheckRevokeStatus(args.Key, successChan, finishChan, expected)
		for hp, _ := range hpTimeMap {
			go ss.RevokeLeaseAt(hp, args.Key, successChan)
		}

		<-finishChan

		delete(ss.leaseMap, args.Key)
	}

	delete(ss.sMap, args.Key)
	reply.Status = storagerpc.OK
	return nil
}
开发者ID:iedwardwangi,项目名称:Tribbler,代码行数:51,代码来源:storageserver_impl.go


示例7: Delete

func (pc *proxyCounter) Delete(args *storagerpc.DeleteArgs, reply *storagerpc.DeleteReply) error {
	if pc.override {
		reply.Status = pc.overrideStatus
		return pc.overrideErr
	}
	byteCount := len(args.Key)
	err := pc.srv.Call("StorageServer.Delete", args, reply)
	atomic.AddUint32(&pc.rpcCount, 1)
	atomic.AddUint32(&pc.byteCount, uint32(byteCount))
	return err
}
开发者ID:codingfrenzy,项目名称:p2,代码行数:11,代码来源:proxycounter.go


示例8: Delete

func (ss *storageServer) Delete(args *storagerpc.DeleteArgs, reply *storagerpc.DeleteReply) error {

	key := args.Key
	if rightStorageServer(ss, key) == false {
		reply.Status = storagerpc.WrongServer

		return nil
	}
	if _, found := ss.keyLocks[key]; found == false {
		ss.keyLocks[key] = make(chan int, 1)
	} else {
		<-ss.keyLocks[key]
	}

	if _, found := ss.topMap[key]; found {
		delete(ss.topMap, key)
		reply.Status = storagerpc.OK
	} else {
		reply.Status = storagerpc.KeyNotFound
	}
	ss.keyLocks[key] <- 1
	return nil
}
开发者ID:pyurky,项目名称:p2,代码行数:23,代码来源:storageserver_impl.go



注:本文中的github.com/cmu440/tribbler/rpc/storagerpc.DeleteReply类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang storagerpc.GetArgs类代码示例发布时间:2022-05-23
下一篇:
Golang libstore.NewLibstore函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap