public void DatabaseShouldBeDropped()
        {
            _env.MaxDatabases = 2;
            _env.Open();
            _txn = _env.BeginTransaction();
            var db = _txn.OpenDatabase("notmaster", new DatabaseConfiguration {
                Flags = DatabaseOpenFlags.Create
            });

            _txn.Commit();
            _txn.Dispose();
            db.Dispose();

            _txn = _env.BeginTransaction();
            db   = _txn.OpenDatabase("notmaster");

            db.Drop(_txn);
            _txn.Commit();
            _txn.Dispose();

            _txn = _env.BeginTransaction();

            var ex = Assert.Throws <LightningException>(() => _txn.OpenDatabase("notmaster"));

            Assert.Equal(ex.StatusCode, -30798);
        }
        public void TruncatingTheDatabase()
        {
            _env.Open();
            _txn = _env.BeginTransaction();
            var db = _txn.OpenDatabase();

            _txn.Put(db, "hello", "world");
            _txn.Commit();
            _txn.Dispose();
            _txn = _env.BeginTransaction();
            db   = _txn.OpenDatabase();
            db.Truncate(_txn);
            _txn.Commit();
            _txn.Dispose();
            _txn = _env.BeginTransaction();
            db   = _txn.OpenDatabase();
            var result = _txn.Get(db, UTF8.GetBytes("hello"));

            Assert.Equal(MDBResultCode.NotFound, result.resultCode);
        }
Beispiel #3
0
        public void TruncatingTheDatabase()
        {
            _env.Open();
            _txn = _env.BeginTransaction();
            var db = _txn.OpenDatabase();

            _txn.Put(db, "hello", "world");
            _txn.Commit();
            _txn.Dispose();
            _txn = _env.BeginTransaction();
            db   = _txn.OpenDatabase();
            db.Truncate(_txn);
            _txn.Commit();
            _txn.Dispose();
            _txn = _env.BeginTransaction();
            db   = _txn.OpenDatabase();
            var result = _txn.Get(db, UTF8.GetBytes("hello"));

            Assert.Null(result);
        }
 private void MoveToQueue(LightningTransaction tx, string queueName, Message message)
 {
     try
     {
         var idBytes  = message.Id.MessageIdentifier.ToByteArray();
         var original = OpenDatabase(tx, message.Queue);
         var newDb    = OpenDatabase(tx, queueName);
         tx.Delete(original, idBytes).ThrowOnError();
         tx.Put(newDb, idBytes, message.Serialize()).ThrowOnError();
     }
     catch (LightningException ex)
     {
         tx.Dispose();
         if (ex.StatusCode == (int)MDBResultCode.NotFound)
         {
             throw new QueueDoesNotExistException("Queue doesn't exist", ex);
         }
         throw;
     }
 }
Beispiel #5
0
 public void Dispose()
 {
     _tx.Dispose();
 }
        public void TruncatingTheDatabase()
        {
            _env.Open();
            _txn = _env.BeginTransaction();
            var db = _txn.OpenDatabase();

            _txn.Put(db, "hello", "world");
            _txn.Commit();
            _txn.Dispose();
            _txn = _env.BeginTransaction();
            db = _txn.OpenDatabase();
            db.Truncate(_txn);
            _txn.Commit();
            _txn.Dispose();
            _txn = _env.BeginTransaction();
            db = _txn.OpenDatabase();
            var result = _txn.Get(db, UTF8.GetBytes("hello"));

            Assert.Null(result);
        }
        public void DatabaseShouldBeDropped()
        {
            _env.MaxDatabases = 2;
            _env.Open();
            _txn = _env.BeginTransaction();
            var db = _txn.OpenDatabase("notmaster", new DatabaseConfiguration {Flags = DatabaseOpenFlags.Create});
            _txn.Commit();
            _txn.Dispose();
            db.Dispose();

            _txn = _env.BeginTransaction();
            db = _txn.OpenDatabase("notmaster");

            db.Drop(_txn);
            _txn.Commit();
            _txn.Dispose();

            _txn = _env.BeginTransaction();

            var ex = Assert.Throws<LightningException>(() => _txn.OpenDatabase("notmaster"));

            Assert.Equal(ex.StatusCode, -30798);
        }
Beispiel #8
0
 public void Dispose()
 {
     _txn.Dispose();
     _env.Dispose();
 }
 public void Dispose()
 {
     _transaction.Dispose();
 }
Beispiel #10
0
 public void Dispose() => _tx.Dispose();
 void ITransaction.Rollback()
 {
     _transaction.Dispose();
 }