Package org.xtreemfs.babudb.api.dev

Examples of org.xtreemfs.babudb.api.dev.DatabaseInternal


                comparators[i] = defaultComparator;
            }
        }
       
        if (!dbsByName.containsKey(databaseName)) {
            DatabaseInternal result = new DatabaseMock(databaseName, numIndices, comparators);
            dbsByName.put(databaseName, result);
            return result;
        } else {
            throw new BabuDBException(ErrorCode.BROKEN_PLUGIN, "Test-create failed!");
        }
View Full Code Here


                    if (result instanceof Object[] &&
                      ((Object[]) result).length > 0 &&
                      ((Object[]) result)[0] != null &&
                      ((Object[]) result)[0] instanceof DatabaseInternal) {
                       
                        DatabaseInternal dbInternal = (DatabaseInternal) ((Object[]) result)[0];
                        dbId = dbInternal.getLSMDB().getDatabaseId();
                        dbName = dbInternal.getName();
                    }
                   
                    rq.sendSuccess(Database.newBuilder()
                            .setDatabaseId(dbId).setDatabaseName(dbName).build());
                }
View Full Code Here

       
        // as soon as the snapshot has been completed, replace the entry in the
        // snapshot DB map with a disk index-based BabuDB instance if necessary
        synchronized (snapshotDBs) {
         
          DatabaseInternal db = dbs.getDatabaseManager().getDatabase(dbName);
          boolean compressed = db.getLSMDB().getIndex(0).isCompressed();
          boolean mmaped = db.getLSMDB().getIndex(0).isMMapEnabled();
         
            Snapshot s = snapshotDBs.get(dbName).get(snap.getName());
            s.setView(new DiskIndexView(getSnapshotDir(dbName, snap.getName()), dbs.getDatabaseManager()
                    .getDatabase(dbName).getComparators(), compressed, mmaped));
        }
View Full Code Here

     * @see org.xtreemfs.babudb.api.dev.DatabaseManagerInternal#getDatabase(java.lang.String)
     */
    @Override
    public DatabaseInternal getDatabase(String dbName) throws BabuDBException {
       
        DatabaseInternal db = dbsByName.get(dbName);
       
        if (db == null) {
            throw new BabuDBException(ErrorCode.NO_SUCH_DB, "database with name " + dbName +
                    " does not exist");
        }
View Full Code Here

    /* (non-Javadoc)
     * @see org.xtreemfs.babudb.api.dev.DatabaseManagerInternal#getDatabase(int)
     */
    @Override
    public DatabaseInternal getDatabase(int dbId) throws BabuDBException {
        DatabaseInternal db = dbsById.get(dbId);
       
        if (db == null) {
            throw new BabuDBException(ErrorCode.NO_SUCH_DB, "database (" + dbId +
                    ") does not exist");
        }
View Full Code Here

            public Object process(OperationInternal operation) throws BabuDBException {
               
                // parse args
                String destDB = (String) operation.getParams()[0];
               
                DatabaseInternal sDB = getDatabase(operation.getDatabaseName());
               
                int dbId;
                synchronized (getDBModificationLock()) {
                    synchronized (dbs.getCheckpointer()) {
                        if (dbsByName.containsKey(destDB)) {
                            throw new BabuDBException(ErrorCode.DB_EXISTS, "database '" + destDB
                                + "' already exists");
                        }
                        dbId = nextDbId++;
                        // just "reserve" the name
                        dbsByName.put(destDB, null);
                        dbs.getDBConfigFile().save();
                    }
                }
                // materializing the snapshot takes some time, we should not
                // hold the
                // lock meanwhile!
                try {
                    sDB.proceedSnapshot(destDB);
                } catch (InterruptedException i) {
                    throw new BabuDBException(ErrorCode.INTERNAL_ERROR,
                            "Snapshot creation was interrupted.", i);
                }
               
                // create new DB and load from snapshot
                DatabaseInternal newDB = new DatabaseImpl(dbs, new LSMDatabase(destDB, dbId,
                        dbs.getConfig().getBaseDir() + destDB + File.separatorChar,
                        sDB.getLSMDB().getIndexCount(), true, sDB.getComparators(),
                        dbs.getConfig().getCompression(),
                        dbs.getConfig().getMaxNumRecordsPerBlock(),
                        dbs.getConfig().getMaxBlockFileSize(), dbs.getConfig().getDisableMMap(),
View Full Code Here

                        comps[idx] = comp;
                    }
                   
                    ids.add(dbId);
                   
                    DatabaseInternal db;
                    try {
                        // reset existing DBs
                        db = dbman.getDatabase(dbId);
                        db.setLSMDB(new LSMDatabase(dbName, dbId, dbs.getConfig().getBaseDir()
                                + dbName + File.separatorChar, numIndex, true, comps,
                                dbs.getConfig().getCompression(),
                                dbs.getConfig().getMaxNumRecordsPerBlock(),
                                dbs.getConfig().getMaxBlockFileSize(),
                                dbs.getConfig().getDisableMMap(),
                                dbs.getConfig().getMMapLimit()));
                    } catch (BabuDBException e) {
                        db = new DatabaseImpl(dbs, new LSMDatabase(dbName, dbId,
                                dbs.getConfig().getBaseDir() + dbName + File.separatorChar,
                                numIndex, true, comps, dbs.getConfig().getCompression(),
                                dbs.getConfig().getMaxNumRecordsPerBlock(),
                                dbs.getConfig().getMaxBlockFileSize(),
                                dbs.getConfig().getDisableMMap(),
                                dbs.getConfig().getMMapLimit()));
                       
                        dbman.putDatabase(db);
                    }
                   
                    Logging.logMessage(Logging.LEVEL_INFO, this, "loaded DB %s" + " successfully. [LSN %s]",
                        dbName, db.getLSMDB().getOndiskLSN());
                }
            }
           
            // delete remaining outdated DBs
            Set<Integer> outdatedIds = dbman.getAllDatabaseIds();
View Full Code Here

                        assert (comp != null);
                        comps[idx] = comp;
                    }
                   
                    if (!conversionRequired) {
                        DatabaseInternal db = new DatabaseImpl(this.dbs,
                                new LSMDatabase(dbName, dbId, this.dbs.getConfig().getBaseDir()
                            + dbName + File.separatorChar, numIndex, true, comps, dbs.getConfig()
                                .getCompression(), this.dbs.getConfig().getMaxNumRecordsPerBlock(),
                                dbs.getConfig().getMaxBlockFileSize(), dbs.getConfig().getDisableMMap(),
                                dbs.getConfig().getMMapLimit()));
View Full Code Here

TOP

Related Classes of org.xtreemfs.babudb.api.dev.DatabaseInternal

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.