Package com.sleepycat.je

Examples of com.sleepycat.je.Database


        if ((params == null) || (params.length < 3)) {
            return null;
        }
        String dbName = (String)params[2];

        Database db = null;
        try {
            DatabaseConfig dbConfig = new DatabaseConfig();
            dbConfig.setReadOnly(true);
            DbInternal.setUseExistingConfig(dbConfig, true);
            db = targetEnv.openDatabase(null, dbName, dbConfig);
            return db.getStats(getStatsConfig(params));
        } finally {
            if (db != null) {
                db.close();
            }
        }
    }
View Full Code Here


    private Database openDatabaseInternal(Map databaseHandleCache,
            String dbName,
            DatabaseConfig config)
  throws DatabaseException {

  Database db;
  if (config.getExclusiveCreate()) {
      db = env.openDatabase(null, dbName, config);
      databaseHandleCache.put(dbName, db);
  } else {
      db = (Database) databaseHandleCache.get(dbName);
      if (db == null) {
    db = env.openDatabase(null, dbName, config);
    databaseHandleCache.put(dbName, db);
      } else {
    DbInternal.databaseConfigValidate(config, db.getConfig());
      }
  }
  return db;
    }
View Full Code Here

  synchronized (cache) {
      Iterator iter = cache.values().iterator();

      while (iter.hasNext()) {
    Database db = (Database) iter.next();
    db.close();
      }
  }
    }
View Full Code Here

        /* Write db0 and db1. */
        for (int i = 0; i < 2; i += 1) {
            DatabaseConfig dbConfig = new DatabaseConfig();
            dbConfig.setAllowCreate(true);
            dbConfig.setSortedDuplicates(true);
            Database db = env.openDatabase(null, "db" + i, dbConfig);

            /* Write: {0, 0}, {0, 1}, {1, 0}, {2, 0}, {3, 0} */
            for (int j = 0; j < N_ENTRIES; j += 1) {
                db.put(null, entry(j), entry(0));
            }
            db.put(null, entry(0), entry(1));

            /* Delete everything but the last record. */
            for (int j = 0; j < N_ENTRIES - 1; j += 1) {
                db.delete(null, entry(j));
            }

            db.close();
        }

        checkFirstRecord();
        env.compress();
        checkFirstRecord();
View Full Code Here

        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setAllowCreate(false);
        dbConfig.setReadOnly(true);
        dbConfig.setSortedDuplicates(true);
        Database db = env.openDatabase(null, "db1", dbConfig);
        Cursor cursor = db.openCursor(null, null);
        DatabaseEntry key = new DatabaseEntry();
        DatabaseEntry data = new DatabaseEntry();
        OperationStatus status = cursor.getFirst(key, data, null);
        assertEquals(OperationStatus.SUCCESS, status);
        assertEquals(3, value(key));
        assertEquals(0, value(data));
        cursor.close();
        db.close();
    }
View Full Code Here

                break;
            case DBSTATS:
                DatabaseConfig dbConfig = new DatabaseConfig();
                dbConfig.setReadOnly(true);
                DbInternal.setUseExistingConfig(dbConfig, true);
                Database db = env.openDatabase(null, dbName, dbConfig);
                try {
                    System.out.println(db.getStats(new StatsConfig()));
                } finally {
                    db.close();
                }
                break;
            }
            actionEnd = System.currentTimeMillis();
View Full Code Here

   

    private static void preload(Environment env, String dbName)
        throws DatabaseException {
        System.out.println("Preload starting");
        Database db = env.openDatabase(null, dbName, null);
        Cursor cursor = db.openCursor(null, null);
        try {
            DatabaseEntry key = new DatabaseEntry();
            DatabaseEntry data = new DatabaseEntry();
            int count = 0;
            while (cursor.getNext(key, data, LockMode.DEFAULT) ==
                   OperationStatus.SUCCESS) {
                count++;
                if ((count % 50000) == 0) {
                    System.out.println(count + "...");
                }
            }
            System.out.println("Preloaded " + count + " records");
        } finally {
            cursor.close();
            db.close();
        }
    }
View Full Code Here

  DatabaseEntry foundData = new DatabaseEntry();

        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setReadOnly(true);
        DbInternal.setUseExistingConfig(dbConfig, true);
        Database db = env.openDatabase(null, dbName, dbConfig);
  dupSort = db.getConfig().getSortedDuplicates();

  printHeader(outputFile, dupSort, formatUsingPrintable);

  Cursor cursor = db.openCursor(null, null);
  while (cursor.getNext(foundKey, foundData, LockMode.DEFAULT) ==
               OperationStatus.SUCCESS) {
      dumpOne(outputFile, foundKey.getData(), formatUsingPrintable);
      dumpOne(outputFile, foundData.getData(), formatUsingPrintable);
  }
  cursor.close();
  db.close();
  outputFile.println("DATA=END");

  Tracer.trace(Level.INFO, DbInternal.envGetEnvironmentImpl(env),
         "DbDump.dump of " + dbName + " ending");
    }
View Full Code Here

            DatabaseConfig dbConfig = new DatabaseConfig();
            dbConfig.setReadOnly(true);
            dbConfig.setAllowCreate(false);
            DbInternal.setUseExistingConfig(dbConfig, true);
            Database db = env.openDatabase(null, dbName, dbConfig);

            try {
                /* Use DatabaseImpl.verify so we can get a status return. */
                DatabaseImpl dbImpl = DbInternal.dbGetDatabaseImpl(db);
                DatabaseStats stats = dbImpl.getEmptyStats();
                ret = dbImpl.verify(verifyConfig, stats);
                if (verifyConfig.getPrintInfo()) {
                    out.println(stats);
                }
            } finally {
                if (db != null) {
                    db.close();
                }
                Tracer.trace(Level.INFO, envImpl,
                             "DbVerify.verify of " + dbName + " ending");
            }
            closeEnv();
View Full Code Here

             * a db created with a non-default configuration.
             */
            DatabaseConfig dbConfig = new DatabaseConfig();
            dbConfig.setAllowCreate(true);
            dbConfig.setTransactional(true);
            Database db = env.openDatabase(null, "bozo", dbConfig);

            /* insert a record. */
            DatabaseEntry entry = new DatabaseEntry();
            IntegerBinding.intToEntry(1, entry);
            db.put(null, entry, entry);

            validateOperations(mbean, 8, true, "bozo", new String [] {"bozo"});
            db.close();

            env.close();
            validateGetters(mbean, 2);
            validateOperations(mbean, 0, true, null, null);

View Full Code Here

TOP

Related Classes of com.sleepycat.je.Database

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.