internal override void Visit(RecycleTxRequest req) { // RecycleTxRequest will be called at the begining of tx, the remoteEntry is supposed to be null TxTableEntry txEntry = null; if (!this.txTable.TryGetValue(req.TxId, out txEntry)) { txEntry = new TxTableEntry(req.TxId); if (!this.txTable.TryAdd(req.TxId, txEntry)) { req.Result = false; req.Finished = true; return; } } while (Interlocked.CompareExchange(ref txEntry.latch, 1, 0) != 0) { ; } txEntry.Reset(); Interlocked.Exchange(ref txEntry.latch, 0); req.RemoteTxEntry = txEntry; req.Result = true; req.Finished = true; }
internal override void Visit(RecycleTxRequest req) { string hashId = req.TxId.ToString(); if (this.redisVersionDbMode == RedisVersionDbMode.Cluster) { hashId = RedisVersionDb.PACK_KEY(RedisVersionDb.TX_KEY_PREFIX, hashId); } byte[][] keysBytes = { Encoding.ASCII.GetBytes(TxTableEntry.TXID_STRING), Encoding.ASCII.GetBytes(TxTableEntry.STATUS_STRING), Encoding.ASCII.GetBytes(TxTableEntry.COMMIT_TIME_STRING), Encoding.ASCII.GetBytes(TxTableEntry.COMMIT_LOWER_BOUND_STRING) }; byte[][] valuesBytes = { Encoding.ASCII.GetBytes(hashId), BitConverter.GetBytes((int)TxStatus.Ongoing), BitConverter.GetBytes(TxTableEntry.DEFAULT_COMMIT_TIME), BitConverter.GetBytes(TxTableEntry.DEFAULT_LOWER_BOUND) }; RedisRequest redisReq = this.NextRedisRequest(); redisReq.Set(hashId, keysBytes, valuesBytes, RedisRequestType.HMSet); redisReq.ParentRequest = req; }
internal override void Visit(RecycleTxRequest req) { // RecycleTxRequest is supposed to has no remoteTxEntry reference TxTableEntry txEntry = null; this.txTable.TryGetValue(req.TxId, out txEntry); if (txEntry == null) { txEntry = new TxTableEntry(req.TxId); this.txTable.Add(req.TxId, txEntry); } else { txEntry.Reset(); req.RemoteTxEntry = txEntry; req.Result = true; req.Finished = true; } }
internal override void Visit(RecycleTxRequest req) { this.HashId = req.TxId.ToString(); byte[][] keysBytes = { Encoding.ASCII.GetBytes(TxTableEntry.STATUS_STRING), Encoding.ASCII.GetBytes(TxTableEntry.COMMIT_TIME_STRING), Encoding.ASCII.GetBytes(TxTableEntry.COMMIT_LOWER_BOUND_STRING) }; byte[][] valuesBytes = { BitConverter.GetBytes((int)TxStatus.Ongoing), BitConverter.GetBytes(TxTableEntry.DEFAULT_COMMIT_TIME), BitConverter.GetBytes(TxTableEntry.DEFAULT_LOWER_BOUND) }; this.RedisReq = new RedisRequest(this.HashId, keysBytes, valuesBytes, RedisRequestType.HMSet) { ParentRequest = req }; }
internal override void Visit(RecycleTxRequest req) { // There is no response from HMSet, always set the result as successful req.Result = true; }
internal virtual void Visit(RecycleTxRequest req) { }