コード例 #1
0
ファイル: GStoreSyncImpl.cs プロジェクト: Opty-MSc/DIDA
        public override Task <LockReply> Lock(LockRequest req, ServerCallContext _)
        {
            man.CheckFreeze();
            try {
                store.Lock(req.IdPart, req.IdObj);
            } catch (DomainException e) {
                throw new GRPCException(StatusCode.NotFound, e.Message);
            }

            Lib.Sleep(new Random().Next(minDelay, maxDelay));
            return(Task.FromResult(new LockReply()));
        }
コード例 #2
0
ファイル: GStoreServicesImpl.cs プロジェクト: Opty-MSc/DIDA
        public override Task <WriteReply> Write(WriteRequest req, ServerCallContext _)
        {
            man.CheckFreeze();

            if (!man.WritePermission(req.IdPart))
            {
                throw new GRPCException(StatusCode.PermissionDenied, ErrorMessage.W_DENIED, req.IdPart);
            }

            store.Lock(req.IdPart, req.IdObj);
            man.Lock(req.IdPart, req.IdObj);

            store.Write(req.IdPart, req.IdObj, req.Val);
            man.Update(req.IdPart, req.IdObj, req.Val);

            Lib.Sleep(new Random().Next(minDelay, maxDelay));
            return(Task.FromResult(new WriteReply()));
        }