Package com.sleepycat.je

Examples of com.sleepycat.je.Environment


    public String getStats(String storeName, boolean fast) {
        try {
            if(environments.containsKey(storeName)) {
                StatsConfig config = new StatsConfig();
                config.setFast(fast);
                Environment env = environments.get(storeName);
                return env.getStats(config).toString();
            } else {
                // return empty string if environment not created yet
                return "";
            }
        } catch(DatabaseException e) {
View Full Code Here


    public void update(StoreDefinition storeDef) {
        if(!useOneEnvPerStore)
            throw new VoldemortException("Memory foot print can be set only when using different environments per store");

        String storeName = storeDef.getName();
        Environment environment = environments.get(storeName);
        // change reservation amount of reserved store
        if(!unreservedStores.contains(environment) && storeDef.hasMemoryFootprint()) {
            EnvironmentMutableConfig mConfig = environment.getMutableConfig();
            long currentCacheSize = mConfig.getCacheSize();
            long newCacheSize = storeDef.getMemoryFootprintMB() * ByteUtils.BYTES_PER_MB;
            if(currentCacheSize != newCacheSize) {
                long newReservedCacheSize = this.reservedCacheSize - currentCacheSize
                                            + newCacheSize;

                // check that we leave a 'minimum' shared cache
                if((voldemortConfig.getBdbCacheSize() - newReservedCacheSize) < voldemortConfig.getBdbMinimumSharedCache()) {
                    throw new StorageInitializationException("Reservation of "
                                                             + storeDef.getMemoryFootprintMB()
                                                             + " MB for store "
                                                             + storeName
                                                             + " violates minimum shared cache size of "
                                                             + voldemortConfig.getBdbMinimumSharedCache());
                }

                this.reservedCacheSize = newReservedCacheSize;
                adjustCacheSizes();
                mConfig.setCacheSize(newCacheSize);
                environment.setMutableConfig(mConfig);
                logger.info("Setting private cache for store " + storeDef.getName() + " to "
                            + newCacheSize);
            }
        } else {
            // we cannot support changing a reserved store to unreserved or vice
View Full Code Here

        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

  @Override
  public void start()
  {
    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

   * @see net.sf.hajdbc.pool.PoolProvider#create()
   */
  @Override
  public Environment create() throws DatabaseException
  {
    return new Environment(this.file, this.config);
  }
View Full Code Here

    void execute(Environment env, Transaction transaction);
  }
 
  private void execute(Operation... operations)
  {
    Environment env = this.pool.take();
    try
    {
      Transaction transaction = env.beginTransaction(null, null);
      try
      {
        for (Operation operation: operations)
        {
          operation.execute(env, transaction);
View Full Code Here

    T execute(Environment env);
  }
 
  private <T> T execute(Query<T> query)
  {
    Environment env = this.pool.take();
    try
    {
      return query.execute(env);
    }
    finally
View Full Code Here

    if(!file.isDirectory()) {
      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
View Full Code Here

            EnvironmentConfig envConf = new EnvironmentConfig();
            envConf.setAllowCreate(true);
            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)
View Full Code Here

        envConfig.setTransactional(true);
        envConfig.setConfigParam("je.lock.nLockTables", "7");
        envConfig.setReadOnly(false);
        envConfig.setSharedCache(false);
        envConfig.setCacheSize(0);
        return new Environment(storeLocation, envConfig);
    }
View Full Code Here

TOP

Related Classes of com.sleepycat.je.Environment

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.