コード例 #1
0
        internal override void Visit(SetCommitTsRequest req)
        {
            TxTableEntry txEntry = req.RemoteTxEntry;

            if (txEntry == null)
            {
                if (!this.txTable.TryGetValue(req.TxId, out txEntry))
                {
                    throw new TransactionException("The specified tx does not exist.");
                }
            }

            while (Interlocked.CompareExchange(ref txEntry.latch, 1, 0) != 0)
            {
                ;
            }
            // read and write
            long commitTime = Math.Max(req.ProposedCommitTs, txEntry.CommitLowerBound);

            txEntry.CommitTime = commitTime;

            Interlocked.Exchange(ref txEntry.latch, 0);

            req.Result   = commitTime;
            req.Finished = true;
        }
コード例 #2
0
        internal override void Visit(SetCommitTsRequest req)
        {
            byte[][] returnBytes = req.Result as byte[][];

            req.Result = returnBytes == null || returnBytes.Length == 0 ?
                         -1L :
                         BitConverter.ToInt64(returnBytes.ValueBytes(), 0);
        }
コード例 #3
0
        internal override void Visit(SetCommitTsRequest req)
        {
            this.HashId = req.TxId.ToString();
            string sha1 = this.redisLuaScriptManager.GetLuaScriptSha1(LuaScriptName.SET_AND_GET_COMMIT_TIME);

            byte[][] keys =
            {
                Encoding.ASCII.GetBytes(this.HashId),
                BitConverter.GetBytes(req.ProposedCommitTs),
                RedisVersionDb.NEGATIVE_ONE_BYTES,
            };

            this.RedisReq = new RedisRequest(keys, sha1, 1, RedisRequestType.EvalSha)
            {
                ParentRequest = req
            };
        }
コード例 #4
0
        internal override void Visit(SetCommitTsRequest req)
        {
            TxTableEntry txEntry = req.RemoteTxEntry;

            if (txEntry == null)
            {
                txEntry = this.txTable[req.TxId];
            }

            // already has a commit time
            if (txEntry.CommitTime != TxTableEntry.DEFAULT_COMMIT_TIME)
            {
                req.Result = -1L;
            }
            else
            {
                txEntry.CommitTime = Math.Max(txEntry.CommitLowerBound, req.ProposedCommitTs);
                req.Result         = txEntry.CommitTime;
            }
            req.Finished = true;
        }
コード例 #5
0
        internal override void Visit(SetCommitTsRequest req)
        {
            string hashId = req.TxId.ToString();

            if (this.redisVersionDbMode == RedisVersionDbMode.Cluster)
            {
                hashId = RedisVersionDb.PACK_KEY(RedisVersionDb.TX_KEY_PREFIX, hashId);
            }

            string sha1 = this.redisLuaScriptManager.GetLuaScriptSha1(LuaScriptName.SET_AND_GET_COMMIT_TIME);

            byte[][] keys =
            {
                Encoding.ASCII.GetBytes(hashId),
                BitConverter.GetBytes(req.ProposedCommitTs),
                RedisVersionDb.NEGATIVE_ONE_BYTES,
            };

            RedisRequest redisReq = this.NextRedisRequest();

            redisReq.Set(keys, sha1, 1, RedisRequestType.EvalSha);
            redisReq.ParentRequest = req;
        }
コード例 #6
0
 internal virtual void Visit(SetCommitTsRequest req)
 {
 }