Package org.xtreemfs.babudb.api

Examples of org.xtreemfs.babudb.api.StaticInitialization


    }
   
    public void testInitScript() throws BabuDBException {
       
        database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 0, 0, 0, SyncMode.ASYNC, 0,
            0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, LOG_LEVEL), new StaticInitialization() {
           
            @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.");
                }
            }
        });
       
        Database db = database.getDatabaseManager().getDatabase("test");
        byte[] result = db.lookup(0, "Yagga".getBytes(), null).get();
        assertNotNull(result);
        String value = new String(result);
        assertEquals(value, "Brabbel");
       
        result = db.lookup(1, "Brabbel".getBytes(), null).get();
        assertNotNull(result);
        value = new String(result);
        assertEquals(value, "Blupp");
       
        result = db.lookup(2, "Blupp".getBytes(), null).get();
        assertNotNull(result);
        value = new String(result);
        assertEquals(value, "Blahh");
       
        database.shutdown();
       
        database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 0, 0, 0, SyncMode.ASYNC, 0,
            0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, LOG_LEVEL), new StaticInitialization() {
           
            @Override
            public void initialize(DatabaseManager dbMan, SnapshotManager sMan) {
                fail("May not be executed if database is not empty.");
            }
View Full Code Here

TOP

Related Classes of org.xtreemfs.babudb.api.StaticInitialization

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.