Package com.sleepycat.je.dbi

Examples of com.sleepycat.je.dbi.EnvironmentImpl


            /* Run the root updater while the root latch is held. */
            tree.withRootLatched(rootUpdater);

            /* Update the mapLN if necessary */
            if (rootUpdater.updateDone()) {
                EnvironmentImpl env = db.getDbEnvironment();
                env.getDbMapTree().modifyDbRoot(db);
            }
        } catch (Exception e) {
            success = false;
            throw new DatabaseException("lsnFromLog=" +
                                        DbLsn.getNoFormatString(lsn),
View Full Code Here


  throws DatabaseException {

        EnvironmentConfig envConfig = TestUtils.initEnvConfig();
        envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), "6");
        envConfig.setAllowCreate(true);
        noLogEnv = new EnvironmentImpl(envHome, envConfig);
  initialINCapacity =
      noLogEnv.getConfigManager().getInt(EnvironmentParams.NODE_MAX);
        db = new DatabaseImpl("foo", new DatabaseId(11), noLogEnv,
            new DatabaseConfig());
    }
View Full Code Here

    private static void doEvict(Environment env)
        throws DatabaseException {
     
        /* push the cache size down by half to force eviction. */
        EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env);
        long cacheUsage = envImpl.getMemoryBudget().getCacheMemoryUsage();
        EnvironmentMutableConfig c = new EnvironmentMutableConfig();
        c.setCacheSize(cacheUsage/2);
        env.setMutableConfig(c);

        long start = System.currentTimeMillis();
View Full Code Here

         * we would truncate before it.
         */
        closeEnv(false);

        /* Truncate the log. */
        EnvironmentImpl cmdEnv =
      CmdUtil.makeUtilityEnvironment(envHome, false);
        cmdEnv.getFileManager().truncateLog(DbLsn.getFileNumber(truncateLsn),
                                            DbLsn.getFileOffset(truncateLsn));
        cmdEnv.close(false);

        /* Delete files following the truncated file. */
        String[] fileNames = envHome.list();
        for (int i = 0; i < fileNames.length; i += 1) {
            String name = fileNames[i];
View Full Code Here

    }

    private void doCleanerTest(int nKeys, int nDupsPerKey)
        throws DatabaseException {

        EnvironmentImpl environment =
            DbInternal.envGetEnvironmentImpl(exampleEnv);
        FileManager fileManager = environment.getFileManager();
        Map expectedMap = new HashMap();
        doLargePut(expectedMap, nKeys, nDupsPerKey, true);
        Long lastNum = fileManager.getLastFileNum();

        /* Read the data back. */
 
View Full Code Here

        throws DatabaseException {

        initEnv(true, true);
        int nKeys = 200;
       
        EnvironmentImpl environment =
            DbInternal.envGetEnvironmentImpl(exampleEnv);
        FileManager fileManager = environment.getFileManager();
        /* Insert a lot of keys. ExpectedMap holds the expected data */
        Map expectedMap = new HashMap();
        doLargePut(expectedMap, nKeys, 1, true);

        /* Modify every other piece of data. */
 
View Full Code Here

        initEnv(true, true);

        int nKeys = 20; // test ends up inserting 2*nKeys
        int nDupsPerKey = 30;

        EnvironmentImpl environment =
            DbInternal.envGetEnvironmentImpl(exampleEnv);
        FileManager fileManager = environment.getFileManager();

        /* Insert some non dup data, modify, insert dup data. */
        Map expectedMap = new HashMap();
        doLargePut(expectedMap, nKeys, 1, true);
        modifyData(expectedMap, 10, true);
View Full Code Here

        EnvironmentConfig envConfig = TestUtils.initEnvConfig();
        envConfig.setAllowCreate(true);
        envConfig.setConfigParam
      (EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
        Environment env = new Environment(envHome, envConfig);
  EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env);
  FileManager fileManager =
      DbInternal.envGetEnvironmentImpl(env).getFileManager();

        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setAllowCreate(true);
        Database db1 =
      env.openDatabase(null, "db1", dbConfig);

        Database db2 =
      env.openDatabase(null, "db2", dbConfig);

  DatabaseEntry key = new DatabaseEntry();
  DatabaseEntry data = new DatabaseEntry();
  IntegerBinding.intToEntry(1, key);
  data.setData(new byte[100000]);
        for (int i = 0; i < 50; i++) {
            assertEquals(OperationStatus.SUCCESS, db2.put(null, key, data));
  }
  db1.close();
  db2.close();
        assertEquals("Should have 0 as current file", 0L,
                     fileManager.getCurrentFileNum());
  envImpl.forceLogFileFlip();
  env.close();

        env = new Environment(envHome, envConfig);
  fileManager = DbInternal.envGetEnvironmentImpl(env).getFileManager();
        assertEquals("Should have 1 as current file", 1L,
View Full Code Here

    */
    private void addData(Database db)
        throws DatabaseException {

  DatabaseImpl dbImpl = DbInternal.dbGetDatabaseImpl(db);
        EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env);
        CheckpointConfig ckptConfig = new CheckpointConfig();
        ckptConfig.setForce(true);

  /*
   * Create a one element dup tree by making a dupe and then reducing it
   * back to one element.
   */
  put(db, "cfhaa", "yrhwlvlgvq");
  put(db, "cfhaa", "blort");
  delete(db, "cfhaa", "blort");
  env.compress();
        env.sync();

  /* Same thing for cfgaa. */   
  put(db, "cfgaa", "urhwlvlgvq");
  put(db, "cfgaa", "blort");
  delete(db, "cfgaa", "blort");
  put(db, "cfiaa", "yrhwlvlgvq");
  put(db, "cffaa", "yrhwlvlgvq");
        env.sync();
        env.sync();

  /* Write out the DelDupLN and DupCountLN. */
  delete(db, "cfhaa", "yrhwlvlgvq");
  BIN bin = (BIN) dbImpl.getTree().search("cfhaa".getBytes(),
            SearchType.NORMAL,
            -1,
                                                null,
                                                true);
  assertNotNull(bin);
  int idx = bin.findEntry("cfhaa".getBytes(), false, true);
  DIN din = (DIN) bin.getTarget(idx);
  assertNotNull(din);
  idx = din.findEntry("yrhwlvlgvq".getBytes(), false, true);
  DBIN dbin = (DBIN) din.getTarget(idx);
  Key.DUMP_BINARY = false;
  dbin.log(envImpl.getLogManager());
  din.log(envImpl.getLogManager());
  bin.releaseLatch();
  env.compress();
  bin.log(envImpl.getLogManager());
    }
View Full Code Here

          long endLsn,
          boolean verbose,
                      boolean stats)
        throws IOException, DatabaseException {

        EnvironmentImpl env =
      CmdUtil.makeUtilityEnvironment(envHome, true);
        FileManager fileManager = env.getFileManager();
        fileManager.setIncludeDeletedFiles(true);
        int readBufferSize =
            env.getConfigManager().getInt
            (EnvironmentParams.LOG_ITERATOR_READ_SIZE);
       
        // Make a reader.
        DumpFileReader reader = null;
        if (stats) {
            reader = new StatsFileReader(env, readBufferSize, startLsn, endLsn,
                                         entryTypes, txnIds, verbose);
        } else {
            reader =  new PrintFileReader(env, readBufferSize, startLsn,
            endLsn, entryTypes, txnIds, verbose);
        }

        // Enclose the output in a tag to keep proper XML syntax.
        System.out.println("<DbPrintLog>");
        while (reader.readNextEntry()) {
        }
        reader.summarize();
        System.out.println("</DbPrintLog>");
        env.close();
    }
View Full Code Here

TOP

Related Classes of com.sleepycat.je.dbi.EnvironmentImpl

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.