Package com.sleepycat.je

Examples of com.sleepycat.je.DatabaseConfig


        if (priIndexMap.containsKey(clsName)) {
            throw new IllegalStateException
                ("Cannot set config after DB is open");
        }
        EntityMetadata meta = checkEntityClass(clsName);
        DatabaseConfig dbConfig = getPrimaryConfig(meta);
        if (config.getExclusiveCreate() ||
            config.getAllowCreate() == config.getReadOnly() ||
            config.getSortedDuplicates() ||
            /* <!-- begin JE only --> */
            config.getTemporary() != dbConfig.getTemporary() ||
            /* <!-- end JE only --> */
            config.getBtreeComparator() != dbConfig.getBtreeComparator()) {
            throw new IllegalArgumentException
                ("One of these properties was illegally changed: " +
                 "AllowCreate, ExclusiveCreate, SortedDuplicates, Temporary " +
                 "or BtreeComparator, ");
        }
View Full Code Here


                                               SecondaryKeyMetadata
                                               secKeyMeta) {
        SecondaryConfig config = secConfigMap.get(secName);
        if (config == null) {
            /* Set common properties to match the primary DB. */
            DatabaseConfig priConfig = getPrimaryConfig(entityMeta);
            config = new SecondaryConfig();
            config.setTransactional(priConfig.getTransactional());
            config.setAllowCreate(!priConfig.getReadOnly());
            config.setReadOnly(priConfig.getReadOnly());
            DbCompat.setTypeBtree(config);
            /* <!-- begin JE only --> */
            DbInternal.setReplicated(config,
                                     DbInternal.getReplicated(priConfig));
            config.setTemporary(priConfig.getTemporary());
            config.setDeferredWrite(priConfig.getDeferredWrite());
            config.setOverrideBtreeComparator(true);
            config.setOverrideDuplicateComparator(true);
            /* <!-- end JE only --> */
            /* Set secondary properties based on metadata. */
            config.setAllowPopulate(true);
            Relationship rel = secKeyMeta.getRelationship();
            config.setSortedDuplicates(rel == Relationship.MANY_TO_ONE ||
                                       rel == Relationship.MANY_TO_MANY);
            setBtreeComparator(config, keyClassName);
            config.setDuplicateComparator(priConfig.getBtreeComparator());
            PersistKeyCreator keyCreator = new PersistKeyCreator
                (catalog, entityMeta, keyClassName, secKeyMeta, rawAccess);
            if (rel == Relationship.ONE_TO_MANY ||
                rel == Relationship.MANY_TO_MANY) {
                config.setMultiKeyCreator(keyCreator);
View Full Code Here

        Class entityClass = format.getType();
        String entityClassName = format.getClassName();
        EntityMetadata meta = model.getEntityMetadata(entityClassName);
        String keyClassName = meta.getPrimaryKey().getClassName();
        keyClassName = SimpleCatalog.keyClassName(keyClassName);
        DatabaseConfig dbConfig = getPrimaryConfig(meta);

        PrimaryIndex<Object, Object> index = getPrimaryIndex
            (Object.class, keyClassName, entityClass, entityClassName);
        Database db = index.getDatabase();

        EntityBinding binding = index.getEntityBinding();
        DatabaseEntry key = new DatabaseEntry();
        DatabaseEntry data = new DatabaseEntry();

        CursorConfig cursorConfig = null;
        Transaction txn = null;
        if (dbConfig.getTransactional()) {
            txn = env.beginTransaction(null, autoCommitTxnConfig);
            cursorConfig = CursorConfig.READ_COMMITTED;
        }

        Cursor cursor = null;
View Full Code Here

        envConfig.setTransactional(true);
        envConfig.setAllowCreate(false);
        envConfig.setReadOnly(false);
        envConfig.setCacheSize(1024 * 1024 * 1024);

        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setTransactional(true);
        dbConfig.setAllowCreate(false);
        dbConfig.setSortedDuplicates(areDuplicatesNeededForSrc());
        dbConfig.setReadOnly(true);

        srcEnv = new Environment(new File(sourceEnvPath), envConfig);
        srcDB = srcEnv.openDatabase(null, storeName, dbConfig);

        // Configure dest environment handle
        File newEnvDir = new File(destEnvPath);
        if(!newEnvDir.exists()) {
            newEnvDir.mkdirs();
        }

        envConfig = new EnvironmentConfig();
        envConfig.setTransactional(false);
        envConfig.setAllowCreate(true);
        envConfig.setReadOnly(false);
        envConfig.setCacheSize(1024 * 1024 * 1024);
        envConfig.setConfigParam(EnvironmentConfig.LOG_FILE_MAX,
                                 Long.toString(logFileSize * 1024L * 1024L));
        envConfig.setDurability(Durability.COMMIT_NO_SYNC);

        dbConfig = new DatabaseConfig();
        dbConfig.setTransactional(false);
        dbConfig.setAllowCreate(true);
        dbConfig.setSortedDuplicates(areDuplicatesNeededForDest());
        dbConfig.setDeferredWrite(true);
        dbConfig.setNodeMaxEntries(nodeMax);

        dstEnv = new Environment(newEnvDir, envConfig);
        dstDB = dstEnv.openDatabase(null, storeName, dbConfig);

    }
View Full Code Here

                logger.warn("Error when applying raw BDB property string... Ignoring and moving on..",
                            e);
            }
        }

        databaseConfig = new DatabaseConfig();
        databaseConfig.setAllowCreate(true);
        databaseConfig.setSortedDuplicates(false);
        databaseConfig.setNodeMaxEntries(config.getBdbBtreeFanout());
        databaseConfig.setTransactional(true);
        bdbMasterDir = config.getBdbDataDirectory();
View Full Code Here

    this.file.mkdirs();
    this.pool = this.poolFactory.createPool(this);
    Environment env = this.pool.take();
    try
    {
      env.openDatabase(null, STATE, new DatabaseConfig().setAllowCreate(true)).close();
      env.openDatabase(null, INVOCATION, new DatabaseConfig().setAllowCreate(true)).close();
      env.openDatabase(null, INVOKER, new DatabaseConfig().setAllowCreate(true)).close();
    }
    finally
    {
      this.pool.release(env);
    }
View Full Code Here

      operations[i] = new Operation()
      {
        @Override
        public void execute(Environment env, Transaction transaction)
        {
          Database database = env.openDatabase(transaction, operation.getDatabaseName(), new DatabaseConfig().setTransactional(true));
          try
          {
            operation.execute(database);
          }
          finally
View Full Code Here

    Query<T> query = new Query<T>()
    {
      @Override
      public T execute(Environment env)
      {
        Database database = env.openDatabase(null, dbQuery.getDatabaseName(), new DatabaseConfig().setReadOnly(true));
        try
        {
          return dbQuery.execute(database);
        }
        finally
View Full Code Here

      if(!file.mkdirs()) {
        throw new DatabaseException("failed mkdirs(" + path + ")");
      }
    }
    env = new Environment(file, environmentConfig);
    DatabaseConfig databaseConfig = new DatabaseConfig();
    databaseConfig.setAllowCreate(true);
    databaseConfig.setTransactional(true);
//databaseConfig.setTransactional(false); TODO MC
//databaseConfig.setReadOnly(true); TODO MC
    // perform other database configurations

    db = env.openDatabase(null, dbName, databaseConfig);
View Full Code Here

            File envDir = new File(dir);
            if (!envDir.exists())
                envDir.mkdirs();
            env = new Environment(envDir, envConf);
           
            DatabaseConfig dbConf = new DatabaseConfig();
            dbConf.setAllowCreate(true);
            dbConf.setSortedDuplicates(false);
            db = env.openDatabase(null, name, dbConf)
        } catch (DatabaseException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

TOP

Related Classes of com.sleepycat.je.DatabaseConfig

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.