static void LoadYcsbData(SingletonVersionDb versionDb, int recordCount)
        {
            TransactionExecution txExec = versionDb.MakeTxExec();

            for (int i = 0; i < recordCount; ++i)
            {
                txExec.Reset();
                if (!txExec.Insert(i, YcsbHelper.NewPayload()).IsAborted())
                {
                    txExec.Commit();
                }
            }
        }
Example #2
0
        // case1: upload new inserted entry successfully under event-driven senario.
        public void TestUploadNewCase1Event()
        {
            TransactionExecution texDelete = new TransactionExecution(null, this.versionDb);

            while (texDelete.Progress == TxProgress.Initi)
            {
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texDelete.InitTx();
            }
            texDelete.Read(TABLE_ID, DEFAULT_KEY, out bool received, out object payload);
            while (!received)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                texDelete.Read(TABLE_ID, DEFAULT_KEY, out received, out payload);
            }
            texDelete.Delete(TABLE_ID, DEFAULT_KEY, out object payloadDelete);
            texDelete.Commit();
            while (texDelete.Progress != TxProgress.Close)
            {
                this.versionDb.Visit(TABLE_ID, 0);
                this.versionDb.Visit(RedisVersionDb.TX_TABLE, 0);
                texDelete.CurrentProc();
            }

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

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