Examples of DatabaseConfig


Examples of com.sleepycat.je.DatabaseConfig

        }
        db = database;
        try {
            currentTxn =
                CurrentTransaction.getInstanceInternal(db.getEnvironment());
            DatabaseConfig dbConfig;
            if (db instanceof SecondaryDatabase) {
                secDb = (SecondaryDatabase) database;
                SecondaryConfig secConfig = secDb.getSecondaryConfig();
                secKeyCreator = secConfig.getKeyCreator();
                dbConfig = secConfig;
            } else {
                dbConfig = db.getConfig();
            }
            ordered = !DbCompat.isTypeHash(dbConfig);
            keyRangesAllowed = DbCompat.isTypeBtree(dbConfig);
            recNumAllowed = DbCompat.isTypeQueue(dbConfig) ||
                            DbCompat.isTypeRecno(dbConfig) ||
                            DbCompat.getBtreeRecordNumbers(dbConfig);
            recNumRenumber = DbCompat.getRenumbering(dbConfig);
            dupsAllowed = DbCompat.getSortedDuplicates(dbConfig) ||
                          DbCompat.getUnsortedDuplicates(dbConfig);
            dupsOrdered = DbCompat.getSortedDuplicates(dbConfig);
            transactional = currentTxn.isTxnMode() &&
                            dbConfig.getTransactional();
            readUncommittedAllowed = DbCompat.getReadUncommitted(dbConfig);
            btreeRecNumDb = recNumAllowed && DbCompat.isTypeBtree(dbConfig);
            range = new KeyRange(dbConfig.getBtreeComparator());
        } catch (DatabaseException e) {
            throw RuntimeExceptionWrapper.wrapIfNeeded(e);
        }
        this.writeAllowed = writeAllowed;
        this.keyBinding = keyBinding;
View Full Code Here

Examples of com.sleepycat.je.DatabaseConfig

        throws DatabaseException {

        if (dupsView) {
            synchronized (this) {
                if (dupsRange == null) {
                    DatabaseConfig config =
                        secDb.getPrimaryDatabase().getConfig();
                    dupsRange = new KeyRange(config.getBtreeComparator());
                }
            }
            return dupsRange;
        } else {
            return range;
View Full Code Here

Examples of com.sleepycat.je.DatabaseConfig

     */
    public StoredClassCatalog(Database database)
        throws DatabaseException, IllegalArgumentException {

        db = database;
        DatabaseConfig dbConfig = db.getConfig();
        EnvironmentConfig envConfig = db.getEnvironment().getConfig();

        writeLockMode = (DbCompat.getInitializeLocking(envConfig) ||
                         envConfig.getTransactional()) ? LockMode.RMW
                                                       : LockMode.DEFAULT;
        cdbMode = DbCompat.getInitializeCDB(envConfig);
        txnMode = dbConfig.getTransactional();

        if (!DbCompat.isTypeBtree(dbConfig)) {
            throw new IllegalArgumentException
                ("The class catalog must be a BTREE database.");
        }
        if (DbCompat.getSortedDuplicates(dbConfig) ||
            DbCompat.getUnsortedDuplicates(dbConfig)) {
            throw new IllegalArgumentException
                ("The class catalog database must not allow duplicates.");
        }

        /*
         * Create the class format and class info maps. Note that these are not
         * synchronized, and therefore the methods that use them are
         * synchronized.
         */
        classMap = new HashMap<String, ClassInfo>();
        formatMap = new HashMap<BigInteger, ObjectStreamClass>();

        DatabaseEntry key = new DatabaseEntry(LAST_CLASS_ID_KEY);
        DatabaseEntry data = new DatabaseEntry();
        if (dbConfig.getReadOnly()) {
            /* Check that the class ID record exists. */
            OperationStatus status = db.get(null, key, data, null);
            if (status != OperationStatus.SUCCESS) {
                throw DbCompat.unexpectedState
                    ("A read-only catalog database may not be empty");
View Full Code Here

Examples of com.sleepycat.je.DatabaseConfig

        }
        String dbName = (String)params[2];

        Database db = null;
        try {
            DatabaseConfig dbConfig = new DatabaseConfig();
            dbConfig.setReadOnly(true);
            DbInternal.setUseExistingConfig(dbConfig, true);
            try {
                db = targetEnv.openDatabase(null, dbName, dbConfig);
            } catch (DatabaseExistsException e) {
                /* Should never happen, ExlcusiveCreate is false. */
 
View Full Code Here

Examples of com.sleepycat.je.DatabaseConfig

        List<String> databaseNames = new LinkedList<String>();
        databaseNames.addAll(env.getDatabaseNames());
        for (String dbName : databaseNames) {

            DatabaseConfig dbCfg = new DatabaseConfig();
            dbCfg.setAllowCreate(false);
            dbCfg.setReadOnly(true);
            DbInternal.setUseExistingConfig(dbCfg, true);

            Database db = env.openDatabase(null, dbName, dbCfg);
            out.println("Database: " + dbName + ", Count: " + db.count());
            db.close();
View Full Code Here

Examples of com.sleepycat.je.DatabaseConfig

                    targetMap.put(entryType.getTypeNum(),
                                  (LNLogEntry) entryType.getNewLogEntry());
                }
            }

            DatabaseConfig dbConfig = new DatabaseConfig();
            dbConfig.setReadOnly(true);
            DbInternal.setUseExistingConfig(dbConfig, true);
            Database db = env.openDatabase(null, dbName, dbConfig);
            targetDbId = DbInternal.getDatabaseImpl(db).getId();
            db.close();
        }
View Full Code Here

Examples of com.sleepycat.je.DatabaseConfig

                txn = new MasterTxn(this,
                                    txnConfig,
                                    getNameIdPair());

                /* Database should not exist yet, create it now */
                DatabaseConfig dbConfig = new DatabaseConfig();
                dbConfig.setAllowCreate(true);
                dbConfig.setTransactional(true);
                dbConfig.setExclusiveCreate(true);
                DbInternal.setReplicated(dbConfig, true);

                newDbImpl = getDbTree().createInternalDb
                    (txn, DbType.REP_GROUP.getInternalName(), dbConfig);
                txn.commit();
View Full Code Here

Examples of com.sleepycat.je.DatabaseConfig

            /*
             * TODO: Need to call close, or make SyncDB a singleton, to avoid
             * leaving a Database handle open every time the SyncDB is
             * constructed.
             */
            DatabaseConfig dbConfig = new DatabaseConfig();
            dbConfig.setAllowCreate(allowCreate);
            dbConfig.setTransactional(true);
          
            /* Set the trigger for updating the SyncCleanerBarrier. */
            SyncTrigger trigger = new SyncTrigger(SYNC_TRIGGER_NAME);
            ArrayList<Trigger> list = new ArrayList<Trigger>();
            list.add(trigger);
            dbConfig.setTriggers(list);

            DbInternal.setReplicated(dbConfig, true);

            db = DbInternal.openInternalDatabase
                (env, txn, DbType.SYNC.getInternalName(), dbConfig);
View Full Code Here

Examples of com.sleepycat.je.DatabaseConfig

    }

    public static Database openDb(Environment env, String dbName) {

        /* Open the remote database within that environment. */
        DatabaseConfig dbConfig = new DatabaseConfig();
        /* dbConfig.setTransactional(false); */
        dbConfig.setAllowCreate(false);
        dbConfig.setReadOnly(true);
        dbConfig.setSortedDuplicates(true);
        try {
            return env.openDatabase(null, dbName, dbConfig);
        } catch (DatabaseException e) {
            e.printStackTrace();
        }
View Full Code Here

Examples of com.sleepycat.je.DatabaseConfig

        DatabaseImpl dbImpl = null;
        try {
            switch (opType) {
                case CREATE:
                {
                    DatabaseConfig dbConfig =
                        repContext.getCreateConfig().getReplicaConfig(repImpl);

                    dbImpl = repImpl.getDbTree().createReplicaDb
                      (repTxn, databaseName, dbConfig, nameLN, repContext);

                    /*
                     * We rely on the RepGroupDB.DB_ID value, so make sure
                     * it's what we expect for this internal replicated
                     * database.
                     */
                    if ((dbImpl.getId().getId() == RepGroupDB.DB_ID) &&
                        !DbType.REP_GROUP.getInternalName().equals
                        (databaseName)) {
                        throw EnvironmentFailureException.unexpectedState
                            ("Database: " +
                             DbType.REP_GROUP.getInternalName() +
                             " is associated with id: " +
                             dbImpl.getId().getId() +
                             " and not the reserved database id: " +
                             RepGroupDB.DB_ID);
                    }

                    TriggerManager.runOpenTriggers(repTxn, dbImpl, true);
                    break;
                }

                case REMOVE: {
                    dbImpl = repImpl.getDbTree().getDb(nameLN.getId());
                    try {
                        repImpl.getDbTree().removeReplicaDb
                            (repTxn, databaseName, nameLN.getId(), repContext);
                        TriggerManager.runRemoveTriggers(repTxn, dbImpl);
                    } catch (DatabaseNotFoundException e) {
                        throw EnvironmentFailureException.unexpectedState
                            ("Database: " + dbImpl.getName() +
                             " Id: " + nameLN.getId() +
                             " not found on the Replica.");
                    }
                    break;
                }

                case TRUNCATE: {
                    dbImpl = repImpl.getDbTree().getDb
                        (repContext.getTruncateOldDbId());
                    try {
                        TruncateDbResult result =
                        repImpl.getDbTree().truncateReplicaDb
                            (repTxn, databaseName, false, nameLN, repContext);
                        TriggerManager.runTruncateTriggers(repTxn, result.newDb);
                    } catch (DatabaseNotFoundException e) {
                        throw EnvironmentFailureException.unexpectedState
                            ("Database: " + dbImpl.getName() +
                             " Id: " + nameLN.getId() +
                             " not found on the Replica.");
                    }

                    break;
                }

                case RENAME: {
                    dbImpl = repImpl.getDbTree().getDb(nameLN.getId());
                    try {
                        dbImpl =
                        repImpl.getDbTree().renameReplicaDb
                            (repTxn, dbImpl.getName(), databaseName, nameLN,
                             repContext);
                        TriggerManager.runRenameTriggers(repTxn, dbImpl,
                                                         databaseName);
                    } catch (DatabaseNotFoundException e) {
                        throw EnvironmentFailureException.unexpectedState
                            ("Database rename from: " + dbImpl.getName() +
                             " to " + databaseName +
                             " failed, name not found on the Replica.");
                    }
                    break;
                }

                case UPDATE_CONFIG: {
                    /* Get the replicated database configurations. */
                    DatabaseConfig dbConfig =
                        repContext.getCreateConfig().getReplicaConfig(repImpl);

                    /* Update the NameLN and write it to the log. */
                    dbImpl = repImpl.getDbTree().getDb(nameLN.getId());
                    final String dbName = dbImpl.getName();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.