Example #1
0
        public void TestValidation3Event()
        {
            UpdateVersionMaxCommitTsRequest req = new UpdateVersionMaxCommitTsRequest(TABLE_ID, DEFAULT_KEY, 1L, 5L);

            this.versionDb.GetVersionTable(TABLE_ID).EnqueueVersionEntryRequest(req);

            while (req.Result == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
            }

            TransactionExecution tex = new TransactionExecution(null, this.versionDb);

            tex.DEBUG_MODE = true;
            while (tex.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.InitTx();
            }
            tex.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            tex.Upload();
            while (tex.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Upload();
            }
            tex.maxCommitTsOfWrites = 4L;
            tex.SetCommitTimestamp();
            while (tex.CurrentProc == new Procedure(tex.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.SetCommitTimestamp();
            }

            VersionEntry versionEntry =
                this.versionDb.ReplaceVersionEntry(TABLE_ID, DEFAULT_KEY, 1L, 0L, 4L, -1, -1, long.MaxValue);

            tex.Validate();
            while (tex.CurrentProc == new Procedure(tex.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Validate();
            }
            Assert.AreEqual(new Procedure(tex.Abort), tex.CurrentProc);
        }
Example #2
0
        public void TestReplaceOldCase9Event()
        {
            TransactionExecution texUpdate = new TransactionExecution(null, this.versionDb);

            texUpdate.DEBUG_MODE = true;
            while (texUpdate.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.InitTx();
            }
            texUpdate.Read(TABLE_ID, DEFAULT_KEY, out bool receivedRead, out object payloadRead);
            while (!receivedRead)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.Read(TABLE_ID, DEFAULT_KEY, out receivedRead, out payloadRead);
            }
            texUpdate.Delete(TABLE_ID, DEFAULT_KEY, out object payloadDelete);
            texUpdate.Upload();
            while (texUpdate.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.Upload();
            }
            Assert.AreEqual(new Procedure(texUpdate.SetCommitTimestamp), texUpdate.CurrentProc);

            TransactionExecution texUpdate1 = new TransactionExecution(null, this.versionDb);

            texUpdate1.DEBUG_MODE = true;
            while (texUpdate1.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate1.InitTx();
            }
            texUpdate1.Read(TABLE_ID, DEFAULT_KEY, out bool receivedRead1, out object payloadRead1);
            while (!receivedRead1)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate1.Read(TABLE_ID, DEFAULT_KEY, out receivedRead1, out payloadRead1);
            }

            texUpdate.SetCommitTimestamp();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.SetCommitTimestamp();
            }
            Assert.AreEqual(new Procedure(texUpdate.Validate), texUpdate.CurrentProc);
            texUpdate.Validate();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Validate();
            }
            Assert.AreEqual(new Procedure(texUpdate.WriteToLog), texUpdate.CurrentProc);
            texUpdate.WriteToLog();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.WriteToLog))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.WriteToLog();
            }
            Assert.AreEqual(new Procedure(texUpdate.PostProcessingAfterCommit), texUpdate.CurrentProc);
            texUpdate.PostProcessingAfterCommit();
            while (texUpdate.Progress != TxProgress.Close)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.PostProcessingAfterCommit();
            }

            texUpdate1.Update(TABLE_ID, DEFAULT_KEY, "value_update_1");
            texUpdate1.Upload();
            while (texUpdate1.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate1.Upload();
            }
            Assert.AreEqual(new Procedure(texUpdate1.Abort), texUpdate1.CurrentProc);
        }
Example #3
0
        public void TestPostProcessing4Event()
        {
            TransactionExecution texUpdate = new TransactionExecution(null, this.versionDb);

            texUpdate.DEBUG_MODE = true;
            while (texUpdate.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.InitTx();
            }
            texUpdate.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            texUpdate.Update(TABLE_ID, DEFAULT_KEY, "value_update");
            texUpdate.maxCommitTsOfWrites = 4L;
            texUpdate.Upload();
            while (texUpdate.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Upload();
            }
            texUpdate.SetCommitTimestamp();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.SetCommitTimestamp();
            }
            texUpdate.Validate();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Validate();
            }
            Assert.AreEqual(new Procedure(texUpdate.WriteToLog), texUpdate.CurrentProc);
            texUpdate.WriteToLog();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.WriteToLog))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.WriteToLog();
            }

            TransactionExecution texDelete = new TransactionExecution(null, this.versionDb);

            texDelete.DEBUG_MODE = true;
            while (texDelete.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texDelete.InitTx();
            }
            texDelete.Read(TABLE_ID, DEFAULT_KEY, out bool receivedRead, out object payloadRead);
            while (!receivedRead)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texDelete.Read(TABLE_ID, DEFAULT_KEY, out receivedRead, out payloadRead);
            }
            texDelete.Delete(TABLE_ID, DEFAULT_KEY, out object payloadDelete);
            texDelete.Upload();
            while (texDelete.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texDelete.Upload();
            }

            texUpdate.PostProcessingAfterCommit();
            while (texUpdate.Progress != TxProgress.Close)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.PostProcessingAfterCommit();
            }

            VersionEntry newVersionEntry = this.GetVersionByKey(2L);

            Assert.AreEqual(5L, newVersionEntry.BeginTimestamp);
            Assert.AreEqual(long.MaxValue, newVersionEntry.EndTimestamp);
            Assert.AreEqual(texDelete.txId, newVersionEntry.TxId);

            VersionEntry oldVersionEntry = this.GetVersionByKey(1L);

            Assert.AreEqual(0L, oldVersionEntry.BeginTimestamp);
            Assert.AreEqual(5L, oldVersionEntry.EndTimestamp);
            Assert.AreEqual(-1L, oldVersionEntry.TxId);
        }
Example #4
0
        public void TestValidation7_2Event()
        {
            TransactionExecution tex1 = new TransactionExecution(null, this.versionDb);

            tex1.DEBUG_MODE = true;
            while (tex1.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex1.InitTx();
            }
            tex1.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex1.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            tex1.Upload();
            while (tex1.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex1.Upload();
            }

            TransactionExecution tex = new TransactionExecution(null, this.versionDb);

            tex.DEBUG_MODE = true;
            while (tex.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.InitTx();
            }
            tex.Read(TABLE_ID, DEFAULT_KEY, out bool receivedRead, out object payloadRead);
            while (!receivedRead)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Read(TABLE_ID, DEFAULT_KEY, out receivedRead, out payloadRead);
            }
            tex.Delete(TABLE_ID, DEFAULT_KEY, out object payloadDelete);
            tex.Upload();
            while (tex.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Upload();
            }
            tex.maxCommitTsOfWrites = 4L;
            tex.SetCommitTimestamp();
            while (tex.CurrentProc == new Procedure(tex.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.SetCommitTimestamp();
            }
            tex.Validate();
            while (tex.CurrentProc == new Procedure(tex.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.Validate();
            }
            Assert.AreEqual(new Procedure(tex.WriteToLog), tex.CurrentProc);

            tex1.maxCommitTsOfWrites = 5L;
            tex1.SetCommitTimestamp();
            while (tex1.CurrentProc == new Procedure(tex1.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex1.SetCommitTimestamp();
            }
            tex1.Validate();
            while (tex1.CurrentProc == new Procedure(tex1.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex1.Validate();
            }
            Assert.AreEqual(new Procedure(tex1.Abort), tex1.CurrentProc);
        }
Example #5
0
        public void TestValidation6Event()
        {
            TransactionExecution tex1 = new TransactionExecution(null, this.versionDb);

            tex1.DEBUG_MODE = true;
            while (tex1.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex1.InitTx();
            }
            tex1.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex1.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            tex1.Upload();
            while (tex1.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex1.Upload();
            }

            TransactionExecution tex = new TransactionExecution(null, this.versionDb);

            tex.DEBUG_MODE = true;
            while (tex.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.InitTx();
            }
            tex.Read(TABLE_ID, DEFAULT_KEY, out bool receivedRead, out object payloadRead);
            while (!receivedRead)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Read(TABLE_ID, DEFAULT_KEY, out receivedRead, out payloadRead);
            }
            tex.Delete(TABLE_ID, DEFAULT_KEY, out object payloadDelete);
            tex.Upload();
            while (tex.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Upload();
            }

            tex1.maxCommitTsOfWrites = 3L;
            tex1.SetCommitTimestamp();
            while (tex1.CurrentProc == new Procedure(tex1.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex1.SetCommitTimestamp();
            }
            tex1.Validate();
            while (tex1.CurrentProc == new Procedure(tex1.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex1.Validate();
            }
            Assert.AreEqual(new Procedure(tex1.WriteToLog), tex1.CurrentProc);

            tex.SetCommitTimestamp();
            while (tex.CurrentProc == new Procedure(tex.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.SetCommitTimestamp();
            }
            tex.Validate();
            while (tex.CurrentProc == new Procedure(tex.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.Validate();
            }
            Assert.AreEqual(new Procedure(tex.WriteToLog), tex.CurrentProc);

            GetTxEntryRequest getTxReq = new GetTxEntryRequest(tex.txId);

            this.versionDb.EnqueueTxEntryRequest(tex.txId, getTxReq);
            this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
            while (getTxReq.Result == null)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
            }
            TxTableEntry txEntry = getTxReq.Result as TxTableEntry;

            Assert.AreEqual(5L, txEntry.CommitTime);
        }
Example #6
0
        public void TestValidation4Event()
        {
            TransactionExecution tex = new TransactionExecution(null, this.versionDb);

            tex.DEBUG_MODE = true;
            while (tex.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.InitTx();
            }
            tex.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            tex.Upload();
            while (tex.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                tex.Upload();
            }

            TransactionExecution texUpdate = new TransactionExecution(null, this.versionDb);

            texUpdate.DEBUG_MODE = true;
            while (texUpdate.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.InitTx();
            }
            texUpdate.Read(TABLE_ID, DEFAULT_KEY, out bool receivedUpdate, out object payloadUpdate);
            while (!receivedUpdate)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Read(TABLE_ID, DEFAULT_KEY, out receivedUpdate, out payloadUpdate);
            }
            texUpdate.Delete(TABLE_ID, DEFAULT_KEY, out object payloadDelete);
            texUpdate.Upload();
            while (texUpdate.CurrentProc == null)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texUpdate.Upload();
            }
            Assert.AreEqual(new Procedure(texUpdate.SetCommitTimestamp), texUpdate.CurrentProc);
            texUpdate.SetCommitTimestamp();
            while (texUpdate.CurrentProc == new Procedure(texUpdate.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.SetCommitTimestamp();
            }
            Assert.AreEqual(new Procedure(texUpdate.Validate), texUpdate.CurrentProc);
            texUpdate.Abort();
            while (texUpdate.CurrentProc != new Procedure(texUpdate.PostProcessingAfterAbort))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texUpdate.Abort();
            }

            tex.SetCommitTimestamp();
            while (tex.CurrentProc == new Procedure(tex.SetCommitTimestamp))
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.SetCommitTimestamp();
            }
            Assert.AreEqual(new Procedure(tex.Validate), tex.CurrentProc);
            tex.Validate();
            while (tex.CurrentProc == new Procedure(tex.Validate))
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                tex.Validate();
            }
            Assert.AreEqual(new Procedure(tex.WriteToLog), tex.CurrentProc);
        }