Package org.xtreemfs.babudb.api.database

Examples of org.xtreemfs.babudb.api.database.DatabaseInsertGroup


        database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 0, 0, 0, SyncMode.ASYNC, 0,
            0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, LOG_LEVEL));
        Database db = database.getDatabaseManager().createDatabase("test", 3);
       
        for (int i = 1000; i < 2000; i++) {
            DatabaseInsertGroup ir = db.createInsertGroup();
            ir.addInsert(0, (i + "").getBytes(), (i + "").getBytes());
            ir.addInsert(1, (i + "").getBytes(), (i + "").getBytes());
            ir.addInsert(2, (i + "").getBytes(), (i + "").getBytes());
            db.insert(ir, null);
        }
       
        Iterator<Entry<byte[], byte[]>> it = db.prefixLookup(0, new byte[0], null).get();
        for (int i = 1000; i < 2000; i++)
View Full Code Here


        database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 0, 0, 0, SyncMode.ASYNC, 0,
            0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, LOG_LEVEL));
        Database db = database.getDatabaseManager().createDatabase("test", 3);
       
        for (int i = 1000; i < 2000; i++) {
            DatabaseInsertGroup ir = db.createInsertGroup();
            ir.addInsert(0, (i + "").getBytes(), (i + "").getBytes());
            ir.addInsert(1, (i + "").getBytes(), (i + "").getBytes());
            ir.addInsert(2, (i + "").getBytes(), (i + "").getBytes());
            db.insert(ir, null);
        }
       
        Iterator<Entry<byte[], byte[]>> it = db.rangeLookup(0, new byte[0], new byte[0], null).get();
        for (int i = 1000; i < 2000; i++)
View Full Code Here

           
            @Override
            public void initialize(DatabaseManager dbMan, SnapshotManager sMan) {
                try {
                    Database db = dbMan.createDatabase("test", 3);
                    DatabaseInsertGroup ig = db.createInsertGroup();
                    ig.addInsert(0, "Yagga".getBytes(), "Brabbel".getBytes());
                    ig.addInsert(1, "Brabbel".getBytes(), "Blupp".getBytes());
                    ig.addInsert(2, "Blupp".getBytes(), "Blahh".getBytes());
                    db.insert(ig, null).get();
                } catch (Exception e) {
                    e.printStackTrace();
                    fail("No error should occur.");
                }
View Full Code Here

        database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 1, 0, 0,
            SyncMode.SYNC_WRITE, 0, 0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, DEBUG_LEVEL));
        Database db = database.getDatabaseManager().createDatabase("test", 3);
       
        // add some key-value pairs
        DatabaseInsertGroup ir = db.createInsertGroup();
        ir.addInsert(0, "Key1".getBytes(), "Value1".getBytes());
        ir.addInsert(0, "Key2".getBytes(), "Value2".getBytes());
        ir.addInsert(0, "Key3".getBytes(), "Value3".getBytes());
        db.insert(ir, null).get();
       
        // create a snapshot (in memory)
        database.getSnapshotManager().createPersistentSnapshot("test",
            new DefaultSnapshotConfig("snap1", new int[] { 0, 1 }, null, null));
        DatabaseRO snap1 = database.getSnapshotManager().getSnapshotDB("test", "snap1");
       
        // overwrite original values
        ir = db.createInsertGroup();
        ir.addInsert(0, "Key1".getBytes(), "x".getBytes());
        ir.addInsert(0, "Key2".getBytes(), "x".getBytes());
        ir.addInsert(0, "Key3".getBytes(), "x".getBytes());
        ir.addInsert(1, "bla".getBytes(), "blub".getBytes());
        db.insert(ir, null).get();
       
        // check if the snapshot still contains the old values
        for (int i = 1; i < 4; i++)
            assertEquals("Value" + i, new String(snap1.lookup(0, ("Key" + i).getBytes(), null).get()));
View Full Code Here

        database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 1, 0, 0,
            SyncMode.SYNC_WRITE, 0, 0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, DEBUG_LEVEL));
        Database db = database.getDatabaseManager().createDatabase("test", 4);
       
        // add some key-value pairs
        DatabaseInsertGroup ir = db.createInsertGroup();
        ir.addInsert(0, "testxyz".getBytes(), "v1".getBytes());
        ir.addInsert(0, "test".getBytes(), "v2".getBytes());
        ir.addInsert(0, "testabc".getBytes(), "v3".getBytes());
        ir.addInsert(0, "yagga".getBytes(), "bla".getBytes());
        ir.addInsert(3, "foo".getBytes(), "v1".getBytes());
        ir.addInsert(3, "bar".getBytes(), "v2".getBytes());
        db.insert(ir, null).get();
       
        // create a snapshot (in memory)
        database.getSnapshotManager().createPersistentSnapshot(
            "test",
            new DefaultSnapshotConfig("snap1", new int[] { 0, 3 }, new byte[][][] { { "test".getBytes() },
                { "ba".getBytes(), "blub".getBytes(), "f".getBytes() } }, new byte[][][] {
                { "testabc".getBytes() }, null }));
        DatabaseRO snap1 = database.getSnapshotManager().getSnapshotDB("test", "snap1");
       
        // overwrite original values
        ir = db.createInsertGroup();
        ir.addInsert(0, "testxyz".getBytes(), null);
        ir.addInsert(0, "test".getBytes(), "x".getBytes());
        ir.addInsert(0, "test2".getBytes(), "x".getBytes());
        ir.addInsert(0, "yagga".getBytes(), "x".getBytes());
        ir.addInsert(3, "foo".getBytes(), "x".getBytes());
        ir.addInsert(3, "bar".getBytes(), "x".getBytes());
        db.insert(ir, null).get();
       
        // check whether the snapshot contains exactly the specified key-value
        // pairs
        assertEquals("v1", new String(snap1.lookup(0, "testxyz".getBytes(), null).get()));
View Full Code Here

        Database db1 = database.getDatabaseManager().createDatabase("workerTest1", 2);
        Database db2 = database.getDatabaseManager().createDatabase("workerTest2", 3);
       
        // make some inserts to fill up the worker queue
        for (int i = 0; i < 100; i++) {
            DatabaseInsertGroup ir = db0.createInsertGroup();
            ir.addInsert(0, (i + "").getBytes(), "bla".getBytes());
            db0.insert(ir, null);
           
            ir = db1.createInsertGroup();
            ir.addInsert(0, (i + "").getBytes(), "bla".getBytes());
            ir.addInsert(1, (i + "").getBytes(), "blubb".getBytes());
            db1.insert(ir, null);
           
            ir = db2.createInsertGroup();
            ir.addInsert(0, (i + "").getBytes(), "bla".getBytes());
            ir.addInsert(1, (i + "").getBytes(), "blubb".getBytes());
            ir.addInsert(2, (i + "").getBytes(), "yagga".getBytes());
            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
View Full Code Here

        database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 1, 0, 0,
            SyncMode.SYNC_WRITE, 0, 0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, DEBUG_LEVEL));
        Database db = database.getDatabaseManager().createDatabase("test", 4);
       
        // add some key-value pairs
        DatabaseInsertGroup ir = db.createInsertGroup();
        ir.addInsert(0, "testxyz".getBytes(), "v1".getBytes());
        ir.addInsert(0, "test".getBytes(), "v2".getBytes());
        ir.addInsert(0, "yagga".getBytes(), "bla".getBytes());
        ir.addInsert(3, "foo".getBytes(), "v1".getBytes());
        ir.addInsert(3, "bar".getBytes(), "v2".getBytes());
        db.insert(ir, null).get();
       
        // create a snapshot (in memory)
        database.getSnapshotManager().createPersistentSnapshot("test",
            new DefaultSnapshotConfig("snap1", new int[] { 0, 3 }, null, null));
        DatabaseRO snap1 = database.getSnapshotManager().getSnapshotDB("test", "snap1");
       
        // overwrite original values
        ir = db.createInsertGroup();
        ir.addInsert(0, "testxyz".getBytes(), "x".getBytes());
        ir.addInsert(0, "test".getBytes(), "x".getBytes());
        ir.addInsert(3, "foo".getBytes(), "x".getBytes());
        ir.addInsert(3, "bar".getBytes(), "x".getBytes());
        db.insert(ir, null).get();
       
        // restart the database
        database.shutdown();
        database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 1, 0, 0,
            SyncMode.SYNC_WRITE, 0, 0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, DEBUG_LEVEL));
        db = database.getDatabaseManager().getDatabase("test");
        snap1 = database.getSnapshotManager().getSnapshotDB("test", "snap1");
       
        // check whether the snapshot exists and contains the correct value
        assertEquals("v1", new String(snap1.lookup(0, "testxyz".getBytes(), null).get()));
        assertEquals("v2", new String(snap1.lookup(0, "test".getBytes(), null).get()));
        assertEquals("v1", new String(snap1.lookup(3, "foo".getBytes(), null).get()));
        assertEquals("v2", new String(snap1.lookup(3, "bar".getBytes(), null).get()));
       
        // create a checkpoint and restart the database again
        database.getCheckpointer().checkpoint();
        database.shutdown();
        database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 1, 0, 0,
            SyncMode.SYNC_WRITE, 0, 0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, DEBUG_LEVEL));
        db = database.getDatabaseManager().getDatabase("test");
        snap1 = database.getSnapshotManager().getSnapshotDB("test", "snap1");
       
        // check whether the snapshot exists and contains the correct value
        assertEquals("v1", new String(snap1.lookup(0, "testxyz".getBytes(), null).get()));
        assertEquals("v2", new String(snap1.lookup(0, "test".getBytes(), null).get()));
        assertEquals("v1", new String(snap1.lookup(3, "foo".getBytes(), null).get()));
        assertEquals("v2", new String(snap1.lookup(3, "bar".getBytes(), null).get()));
       
        ir = db.createInsertGroup();
        ir.addInsert(0, "te".getBytes(), "x".getBytes());
        ir.addInsert(0, "key".getBytes(), "x".getBytes());
        db.insert(ir, null).get();
       
        // create a partial user-defined snapshot
        database.getSnapshotManager().createPersistentSnapshot("test", new TestSnapshotConfig());
       
View Full Code Here

        database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 1, 0, 0,
            SyncMode.SYNC_WRITE, 0, 0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, DEBUG_LEVEL));
        Database db = database.getDatabaseManager().createDatabase("test", 4);
       
        // add some key-value pairs
        DatabaseInsertGroup ir = db.createInsertGroup();
        ir.addInsert(0, "testxyz".getBytes(), "v1".getBytes());
        ir.addInsert(0, "test".getBytes(), "v2".getBytes());
        ir.addInsert(0, "yagga".getBytes(), "bla".getBytes());
        ir.addInsert(1, "foo".getBytes(), "v1".getBytes());
        ir.addInsert(1, "bar".getBytes(), "v2".getBytes());
        db.insert(ir, null).get();
       
        // create a snapshot
        database.getSnapshotManager().createPersistentSnapshot("test",
            new DefaultSnapshotConfig("snap1", new int[] { 0, 3 }, null, null));
       
        // delete the snapshot
        database.getSnapshotManager().deletePersistentSnapshot("test", "snap1");
        try {
            database.getSnapshotManager().getSnapshotDB("test", "snap1");
            fail();
        } catch (Exception exc) {
            // ok
        }
       
        ir = db.createInsertGroup();
        ir.addInsert(0, "testxyz".getBytes(), "ggg".getBytes());
        ir.addInsert(0, "test".getBytes(), "ggg".getBytes());
        db.insert(ir, null).get();
       
        // restart the database w/o checkpointing
        database.shutdown();
        database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 1, 0, 0,
View Full Code Here

                ;
                break;
            case 1: {
                // groupInsert
                final int numInGroup = (int) Math.round(Math.random() * (9)) + 1;
                final DatabaseInsertGroup ig = db.createInsertGroup();
                for (int i = 0; i < numInGroup; i++) {
                    final int index = getRandomIndex();
                    final String key = getRandomDictEntry();
                    final String value = getRandomDictEntry();
//                    controlIndices[index].put(key, value);
                    ig.addInsert(index, key.getBytes(), value.getBytes());
                }
               
                db.insert(ig, null).get();
               
                numInsGroup++;
View Full Code Here

        boolean[] contents = new boolean[10000];
       
        for (;;) {
           
            final int numInGroup = (int) Math.round(Math.random() * 9) + 1;
            final DatabaseInsertGroup ig = db.createInsertGroup();
            for (int i = 0; i < numInGroup; i++) {
                final byte[] key = generateData(30);
                final byte[] value = generateData(10000);
                ig.addInsert((int) (Math.random() * 5), key, value);
                dbSize += key.length + value.length;
            }
           
            db.insert(ig, null).get();
           
View Full Code Here

TOP

Related Classes of org.xtreemfs.babudb.api.database.DatabaseInsertGroup

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.