Package com.sleepycat.je

Examples of com.sleepycat.je.Database


      /* Verify the database name by trying to open it. */
      Environment env = new Environment(new File(envHome), null);
      DatabaseConfig dbConfig = new DatabaseConfig();
      dbConfig.setTransactional(transactional);
      Database db = env.openDatabase(null, dbName, dbConfig);
      db.close();
      env.close();
   }
View Full Code Here


  try
  { if (env == null) return false;  
  List dbnames = env.getDatabaseNames();
  for (int i = 0; i < dbnames.size(); i++)
  { String dbname = (String) dbnames.get(i);
  Database dbHandle = (Database) dbMap.get(dbname);
  if (dbHandle != null) try { dbHandle.close(); } catch (DatabaseException de) { }
  }
  env.sync(); env.close();
  /*  boolean anyCleaned = false;
     while (env.cleanLog() > 0) anyCleaned = true;
     if (anyCleaned)
View Full Code Here

   //*-- first, get the environment
   if (env == null) { openEnv(DBDIR, false); if (env == null) return retval; }
   if (!(existsDB(dbname))) return retval;

   setCurrentDB(dbname);
   Database dbe = (Database) dbMap.get(dbname);
   if (dbe != null)
   { dbe.close();
   List secDBList = dbe.getSecondaryDatabases();
   for (int i = 0; i < secDBList.size(); i++)
   { String secDBname = (String) secDBList.get(i);
   dropSecDB(secDBname);
   }
   }
   env.removeDatabase(null,  dbname);  
   dbMap.remove(dbname);

   retval = true;
  }
  catch (DatabaseException dbe) { logger.error("Failed to drop " +  dbname + " " + dbe.getMessage())}

  return retval;
}
View Full Code Here

        reportStarting(environment, 6);
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setTransactional(true);
        dbConfig.setAllowCreate(true);

        Database versionDb = environment.openDatabase(null, "CONFIG_VERSION", dbConfig);

        if(versionDb.count() == 0L)
        {
            DatabaseEntry key = new DatabaseEntry();
            DatabaseEntry value = new DatabaseEntry();
            IntegerBinding.intToEntry(DEFAULT_CONFIG_VERSION, value);
            ByteBinding.byteToEntry((byte) 0, key);
            OperationStatus status = versionDb.put(null, key, value);
            if (status != OperationStatus.SUCCESS)
            {
                throw new AMQStoreException("Error initialising config version: " + status);
            }
        }

        versionDb.close();

        reportFinished(environment, 7);
    }
View Full Code Here

        boolean isEmpty = _environment.getDatabaseNames().isEmpty();
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setTransactional(true);
        dbConfig.setAllowCreate(true);

        Database versionDb = null;
        try
        {
            versionDb = _environment.openDatabase(null, VERSION_DB_NAME, dbConfig);

            if(versionDb.count() == 0L)
            {
                int sourceVersion = isEmpty ? AbstractBDBMessageStore.VERSION: identifyOldStoreVersion();
                DatabaseEntry key = new DatabaseEntry();
                IntegerBinding.intToEntry(sourceVersion, key);
                DatabaseEntry value = new DatabaseEntry();
                LongBinding.longToEntry(System.currentTimeMillis(), value);

                versionDb.put(null, key, value);
            }

            int version = getSourceVersion(versionDb);
            if(version > AbstractBDBMessageStore.VERSION)
            {
                throw new AMQStoreException("Database version " + version
                                            + " is higher than the most recent known version: "
                                            + AbstractBDBMessageStore.VERSION);
            }
            performUpgradeFromVersion(version, versionDb);
        }
        finally
        {
            if (versionDb != null)
            {
                versionDb.close();
            }
        }
    }
View Full Code Here

    {
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setTransactional(true);
        dbConfig.setAllowCreate(true);
        int storeVersion = -1;
        Database versionDb = null;
        Cursor cursor = null;
        try
        {
            versionDb = _environment.openDatabase(null, Upgrader.VERSION_DB_NAME, dbConfig);
            cursor = versionDb.openCursor(null, null);
            DatabaseEntry key = new DatabaseEntry();
            DatabaseEntry value = new DatabaseEntry();
            while (cursor.getNext(key, value, null) == OperationStatus.SUCCESS)
            {
                int version = IntegerBinding.entryToInt(key);
                if (storeVersion < version)
                {
                    storeVersion = version;
                }
            }
        }
        finally
        {
            if (cursor != null)
            {
                cursor.close();
            }
            if (versionDb != null)
            {
                versionDb.close();
            }
        }
        return storeVersion;
    }
View Full Code Here

        File dirA = new File(bdbMasterDir + "/" + "storeA");
        if(!dirA.exists()) {
            dirA.mkdirs();
        }
        Environment environmentA = new Environment(dirA, environmentConfig);
        Database databaseA = environmentA.openDatabase(null, "storeA", databaseConfig);
        BdbStorageEngine storeA = BdbStorageEngineTest.makeBdbStorageEngine("storeA",
                                                                            environmentA,
                                                                            databaseA,
                                                                            new BdbRuntimeConfig(),
                                                                            this.prefixPartitionId);

        File dirB = new File(bdbMasterDir + "/" + "storeB");
        if(!dirB.exists()) {
            dirB.mkdirs();
        }
        Environment environmentB = new Environment(dirB, environmentConfig);
        Database databaseB = environmentB.openDatabase(null, "storeB", databaseConfig);
        BdbStorageEngine storeB = BdbStorageEngineTest.makeBdbStorageEngine("storeB",
                                                                            environmentB,
                                                                            databaseB,
                                                                            new BdbRuntimeConfig(),
                                                                            this.prefixPartitionId);
View Full Code Here

        } else {
            for(File f: bdbDir.listFiles())
                f.delete();
        }
        environment = new Environment(bdbDir, environmentConfig);
        final Database db = environment.openDatabase(null, "test", databaseConfig);

        final Random rand = new Random();
        int iterations = totalSize / increment;
        long[] readTimes = new long[iterations];
        long[] writeTimes = new long[iterations];

        ExecutorService service = Executors.newFixedThreadPool(threads);
        for(int i = 0; i < iterations; i++) {
            System.out.println("Starting iteration " + i);
            List<Future<Object>> results = new ArrayList<Future<Object>>(increment);
            long startTime = System.currentTimeMillis();
            final int fi = i;
            for(int j = 0; j < increment; j++) {
                final int fj = j;
                results.add(service.submit(new Callable<Object>() {

                    public Object call() throws Exception {
                        db.put(null,
                               new DatabaseEntry(Integer.toString(fi * increment + fj).getBytes()),
                               new DatabaseEntry(Integer.toString(fi * increment + fj).getBytes()));
                        return null;
                    }
                }));
            }
            for(int j = 0; j < increment; j++)
                results.get(j).get();
            writeTimes[i] = System.currentTimeMillis() - startTime;
            System.out.println("write: " + (writeTimes[i] / (double) increment));
            results.clear();

            startTime = System.currentTimeMillis();
            for(int j = 0; j < increment; j++) {
                results.add(service.submit(new Callable<Object>() {

                    public Object call() throws Exception {
                        int value = rand.nextInt((fi + 1) * increment);
                        return db.get(null,
                                      new DatabaseEntry(Integer.toString(value).getBytes()),
                                      new DatabaseEntry(Integer.toString(value).getBytes()),
                                      null);
                    }
                }));
View Full Code Here

        Environment environment = new Environment(new File(bdbDir), environmentConfig);
        DatabaseConfig databaseConfig = new DatabaseConfig();
        databaseConfig.setAllowCreate(true);
        databaseConfig.setTransactional(config.isBdbWriteTransactionsEnabled());
        databaseConfig.setSortedDuplicates(false);
        Database database = environment.openDatabase(null, storeName, databaseConfig);

        StorageEngine<ByteArray, byte[], byte[]> store = null;
        if(config.getBdbPrefixKeysWithPartitionId()) {
            store = new PartitionPrefixedBdbStorageEngine(storeName,
                                                          environment,
View Full Code Here

         */
        @Override
        public FlumePersistentManager createManager(final String name, final FactoryData data) {
            SecretKey secretKey = null;

            Database database;
            Environment environment;

            Map<String, String> properties = new HashMap<String, String>();
            if (data.properties != null) {
                for (Property property : data.properties) {
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.