public void TesCurrentLSN()
        {
            testName = "TesCurrentLSN";
            SetUpTest(true);
            RecnoDatabase db;

            Logging(testHome, testName, out env, out db);

            // Get log cursor to read/write log.
            LogCursor logCursor = env.GetLogCursor();

            /*
             * Move the cursor to the beginning of the #1 log file.
             * Get the current LSN and confirm that is the position
             * the cursor is moved to.
             */
            LSN lsn = new LSN(1, 0);

            logCursor.Move(lsn);
            Assert.AreEqual(lsn.LogFileNumber,
                            logCursor.CurrentLSN.LogFileNumber);
            Assert.AreEqual(lsn.Offset, logCursor.CurrentLSN.Offset);

            // Close all.
            logCursor.Close();
            db.Close();
            env.Close();
        }
        public void TestCurrentRecord()
        {
            testName = "TestCurrentRecord";
            SetUpTest(true);
            DatabaseEnvironment env;
            RecnoDatabase       db;

            Logging(testHome, testName, out env, out db);

            // Get log cursor to read/write log.
            LogCursor logCursor = env.GetLogCursor();

            /*
             * Move the cursor to the beginning of the #1 log file.
             * Get the current LSN and confirm that is the position
             * the cursor is moved to.
             */
            LSN lsn = new LSN(1, 0);

            logCursor.Move(lsn);
            Assert.IsNotNull(logCursor.CurrentRecord.Data);

            // Close all.
            logCursor.Close();
            db.Close();
            env.Close();
        }
        public void TestMoveNext()
        {
            testName = "TestMoveNext";
            SetUpTest(true);
            DatabaseEnvironment env;
            RecnoDatabase       db;

            Logging(testHome, testName, out env, out db);

            // Get log cursor to read/write log.
            LogCursor logCursor = env.GetLogCursor();

            logCursor.MoveLast();
            DatabaseEntry curRec = logCursor.CurrentRecord;

            for (int i = 0; i < 1000; i++)
            {
                db.Append(new DatabaseEntry(
                              ASCIIEncoding.ASCII.GetBytes("new data")));
            }

            Assert.IsTrue(logCursor.MoveNext());

            logCursor.MoveNext();

            // Close the log cursor.
            logCursor.Close();
            db.Close();
            env.Close();
        }
Пример #4
0
        static void Main(string[] args)
        {
            LogDbClient client = new LogDbClient();

            client.Connect("localhost", 8888, "araqne", "");
            LogCursor cursor = client.Query("logdb tables");

            foreach (IDictionary o in cursor)
            {
                Console.WriteLine(PrettyPrint(o));
            }
            cursor.Dispose();
            client.Close();
        }
        public void TestMovePrev()
        {
            testName = "TestMovePrev";
            SetUpTest(true);
            DatabaseEnvironment env;
            LSN           lsn;
            RecnoDatabase db;

            Logging(testHome, testName, out env, out db);

            // Get log cursor to read/write log.
            LogCursor logCursor = env.GetLogCursor();

            // Get the last two LSN in log file.
            logCursor.MoveLast();
            Assert.IsTrue(logCursor.MovePrev());

            // Close all.
            logCursor.Close();
            db.Close();
            env.Close();
        }
        public void TestMove()
        {
            testName = "TestMove";
            SetUpTest(true);
            DatabaseEnvironment env;
            RecnoDatabase       db;

            Logging(testHome, testName, out env, out db);

            // Get log cursor to read/write log.
            LogCursor logCursor = env.GetLogCursor();

            // Move the cursor to specified location in log files.
            LSN lsn = new LSN(1, 0);

            Assert.IsTrue(logCursor.Move(lsn));

            // Close all.
            logCursor.Close();
            db.Close();
            env.Close();
        }
        public void TestMoveLast()
        {
            testName = "TestMoveLast";
            SetUpTest(true);
            DatabaseEnvironment env;
            RecnoDatabase       db;

            Logging(testHome, testName, out env, out db);

            // Get log cursor to read/write log.
            LogCursor logCursor = env.GetLogCursor();

            // Move to the last LSN in log file.
            Assert.IsTrue(logCursor.MoveLast());

            // The offset of last LSN shouldn't be 0.
            Assert.AreNotEqual(0, logCursor.CurrentLSN.Offset);

            // Close all.
            logCursor.Close();
            db.Close();
            env.Close();
        }
        public void TestRefresh()
        {
            testName = "TestRefresh";
            SetUpTest(true);
            DatabaseEnvironment env;
            LSN           lsn;
            RecnoDatabase db;

            Logging(testHome, testName, out env, out db);

            // Get log cursor to read/write log.
            LogCursor logCursor = env.GetLogCursor();

            // Move the cursor to the last record.
            logCursor.MoveLast();
            DatabaseEntry curRec = logCursor.CurrentRecord;

            // Put some new records into database.
            for (int i = 0; i < 10; i++)
            {
                db.Append(new DatabaseEntry(
                              ASCIIEncoding.ASCII.GetBytes("new data")));
            }

            // Get the current record that cursor points to.
            logCursor.Refresh();

            // It shouldn't be changed.
            Assert.AreEqual(curRec.Data,
                            logCursor.CurrentRecord.Data);

            // Close all.
            logCursor.Close();
            db.Close();
            env.Close();
        }