Package org.xtreemfs.babudb.api.transaction

Examples of org.xtreemfs.babudb.api.transaction.Transaction


    public void testTransactionExecution() throws Exception {
       
        DatabaseManager dbMan = database.getDatabaseManager();
       
        // create and execute a transaction
        Transaction txn = dbMan.createTransaction();
        txn.createDatabase("test", 3);
        txn.insertRecord("test", 0, "hello".getBytes(), "world".getBytes());
        txn.insertRecord("test", 1, "key".getBytes(), "value".getBytes());
        dbMan.executeTransaction(txn);
       
        // check if the database is there
        Database db = dbMan.getDatabase("test");
        assertNotNull(db);
        assertEquals("test", db.getName());
        assertEquals(3, db.getComparators().length);
       
        // check if the records are there
        byte[] value = db.lookup(0, "hello".getBytes(), null).get();
        assertEquals("world", new String(value));
       
        value = db.lookup(1, "key".getBytes(), null).get();
        assertEquals("value", new String(value));
       
        // create and execute a second transaction
        txn = dbMan.createTransaction();
        txn.createDatabase("test2", 1);
        txn.deleteRecord("test", 0, "hello".getBytes());
        dbMan.executeTransaction(txn);
       
        // check if the both databases are there
        db = dbMan.getDatabase("test");
        assertNotNull(db);
        assertEquals("test", db.getName());
        assertEquals(3, db.getComparators().length);
       
        db = dbMan.getDatabase("test2");
        assertNotNull(db);
        assertEquals("test2", db.getName());
        assertEquals(1, db.getComparators().length);
       
        // check if the key got deleted
        value = db.lookup(0, "hello".getBytes(), null).get();
        assertNull(value);
       
        // create and execute a third transaction
        txn = dbMan.createTransaction();
        txn.deleteDatabase("test");
        txn.deleteDatabase("test2");
        dbMan.executeTransaction(txn);
       
        // check if all databases were deleted
        assertEquals(0, dbMan.getDatabases().size());
       
View Full Code Here


    public void testTransactionPersistence() throws Exception {
       
        DatabaseManager dbMan = database.getDatabaseManager();
       
        // create and execute a transaction
        Transaction txn = dbMan.createTransaction();
        txn.createDatabase("test", 2);
        txn.insertRecord("test", 0, "hello".getBytes(), "world".getBytes());
        txn.insertRecord("test", 1, "key".getBytes(), "value".getBytes());
        dbMan.executeTransaction(txn);
       
        // shutdown and restart the database
        database.shutdown();
        database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 1, 0, 0, SyncMode.ASYNC, 0,
View Full Code Here

            db2.insert(ir, null);
        }
       
        // make a transaction to delete the last 3 keys of two of the databases
        // an update anomaly will be visible, if something went wrong
        Transaction txn = database.getDatabaseManager().createTransaction();
        txn.deleteRecord(db0.getName(), 0, "99".getBytes());
        txn.deleteRecord(db0.getName(), 0, "98".getBytes());
        txn.deleteRecord(db0.getName(), 0, "97".getBytes());
        txn.deleteRecord(db2.getName(), 2, "99".getBytes());
        txn.deleteRecord(db2.getName(), 2, "98".getBytes());
        txn.deleteRecord(db2.getName(), 2, "97".getBytes());
        database.getDatabaseManager().executeTransaction(txn);
        assertNull(db0.lookup(0, "99".getBytes(), null).get());
        assertNull(db0.lookup(0, "98".getBytes(), null).get());
        assertNull(db0.lookup(0, "97".getBytes(), null).get());
        assertNull(db2.lookup(2, "99".getBytes(), null).get());
View Full Code Here

            }
        };
        dbMan.addTransactionListener(l0);
       
        // create and execute a transaction
        Transaction txn = dbMan.createTransaction();
        txn.createDatabase("test", 1);
        txn.insertRecord("test", 0, "hello".getBytes(), "world".getBytes());
        txn.insertRecord("test", 0, "key".getBytes(), "value".getBytes());
        dbMan.executeTransaction(txn);
       
        assertEquals(1, count.get());
       
        // create and execute another transaction (which is empty)
View Full Code Here

        // and populates multiple indices
        for (int i = 0; i < numTxns; i++) {
           
            String dbName = i + "";
           
            Transaction txn = dbMan.createTransaction();
            txn.createDatabase(dbName, numIndices);
            for (int j = 0; j < numKVPairs; j++) {
                String kv = intToString(j, ("" + numKVPairs).length());
                txn.insertRecord(dbName, j % numIndices, kv.getBytes(), kv.getBytes());
            }
            dbMan.executeTransaction(txn);
        }
       
        if (errors.size() > 0)
View Full Code Here

TOP

Related Classes of org.xtreemfs.babudb.api.transaction.Transaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.