Package com.sleepycat.je

Examples of com.sleepycat.je.Environment


      loader.setConfig(config);
      loader.create();
      loader.start();

      /* 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


    }
    if (!resumable) {
      IO.deleteFolderContents(envHome);
    }

    env = new Environment(envHome, envConfig);
    Frontier.init(env, resumable);
    DocIDServer.init(env, resumable);

    PageFetcher.startConnectionMonitorThread();
  }
View Full Code Here

  try
  {
   EnvironmentConfig econfig = new EnvironmentConfig();
   econfig.setAllowCreate(!readOnly); econfig.setReadOnly(readOnly);
   //econfig.setTransactional(true);
   env = new Environment( new File (dirname), econfig);

   //*-- initializes the database hash with the list of databases in the environment
   dbMap = new HashMap<String,Database>();
   List dbList = env.getDatabaseNames();
   for (int i = 0; i < dbList.size(); i++) dbMap.put ( (String) dbList.get(i), null);
View Full Code Here

        envConfig.setTransactional(true);
        envConfig.setAllowCreate(true);
        dbConfig.setAllowCreate(true);
        dbConfig.setTransactional(true);

        env = new Environment(dbHome, envConfig);

        Transaction txn = null;

        try {
            txn = env.beginTransaction(null, null);
View Full Code Here

    public void testPerformXidUpgrade() throws Exception
    {
        File storeLocation = new File(TMP_FOLDER, getName());
        storeLocation.mkdirs();
        Environment environment = createEnvironment(storeLocation);
        try
        {
            populateOldXidEntries(environment);
            UpgradeFrom5To6 upgrade = new UpgradeFrom5To6();
            upgrade.performUpgrade(environment, UpgradeInteractionHandler.DEFAULT_HANDLER, getVirtualHostName());
            assertXidEntries(environment);
        }
        finally
        {
            try
            {
                environment.close();
            }
            finally
            {
                deleteDirectoryIfExists(storeLocation);
            }
View Full Code Here

        _virtualHost = BrokerTestHelper.createVirtualHost(configuration,null,_modelVhost);
        BDBHAMessageStore store = (BDBHAMessageStore) _virtualHost.getMessageStore();

        // test whether JVM system settings were applied
        Environment env = store.getEnvironment();
        assertEquals("Unexpected number of cleaner threads", TEST_NUMBER_OF_THREADS, env.getConfig().getConfigParam(EnvironmentConfig.CLEANER_THREADS));
        assertEquals("Unexpected log file max", TEST_LOG_FILE_MAX, env.getConfig().getConfigParam(EnvironmentConfig.LOG_FILE_MAX));

        ReplicatedEnvironment repEnv = store.getReplicatedEnvironment();
        assertEquals("Unexpected number of elections primary retries", TEST_ELECTION_RETRIES,
                repEnv.getConfig().getConfigParam(ReplicationConfig.ELECTIONS_PRIMARY_RETRIES));
        assertEquals("Unexpected number of elections primary retries", TEST_ENV_CONSISTENCY_TIMEOUT,
View Full Code Here

            throws DatabaseException {
        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);

        long maxCacheUsage = 0;
        for(int i = 0; i <= 10000; i++) {

            byte[] value = new byte[(int) (CACHE_SIZE / 10000)];
            // try to push values in cache
            storeA.put(TestUtils.toByteArray(i + "A"), new Versioned<byte[]>(value), null);
            storeA.get(TestUtils.toByteArray(i + "A"), null);

            storeB.put(TestUtils.toByteArray(i + "B"), new Versioned<byte[]>(value), null);
            storeB.get(TestUtils.toByteArray(i + "B"), null);

            EnvironmentStats statsA = environmentA.getStats(new StatsConfig());
            EnvironmentStats statsB = environmentB.getStats(new StatsConfig());

            long totalCacheSize = statsA.getCacheTotalBytes() + statsB.getCacheTotalBytes();
            System.out.println("A.size:" + statsA.getCacheTotalBytes() + " B.size:"
                               + statsB.getCacheTotalBytes() + " total:" + totalCacheSize + " max:"
                               + maxCacheUsage + " cacheMax:"
View Full Code Here

        final long cacheSize = Long.parseLong(args[1]);
        final int totalSize = Integer.parseInt(args[2]);
        final int increment = Integer.parseInt(args[3]);
        final int threads = Integer.parseInt(args[4]);

        Environment environment;
        EnvironmentConfig environmentConfig;
        DatabaseConfig databaseConfig;

        environmentConfig = new EnvironmentConfig();
        environmentConfig.setCacheSize(cacheSize);
        environmentConfig.setDurability(Durability.COMMIT_NO_SYNC);
        environmentConfig.setConfigParam(EnvironmentConfig.LOG_FILE_MAX, "1000000000");
        environmentConfig.setConfigParam(EnvironmentConfig.CLEANER_MAX_BATCH_FILES, "100");
        environmentConfig.setConfigParam(EnvironmentConfig.CLEANER_READ_SIZE, "52428800");
        environmentConfig.setAllowCreate(true);
        environmentConfig.setTransactional(true);
        databaseConfig = new DatabaseConfig();
        databaseConfig.setAllowCreate(true);
        // databaseConfig.setDeferredWrite(true);
        databaseConfig.setTransactional(true);
        databaseConfig.setNodeMaxEntries(1024);
        File bdbDir = new File(dir);
        if(!bdbDir.exists()) {
            bdbDir.mkdir();
        } 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);
                    }
                }));
            }
            for(int j = 0; j < increment; j++)
                results.get(j).get();
            readTimes[i] = (System.currentTimeMillis() - startTime);
            System.out.println("read: " + (readTimes[i] / (double) increment));

            int cleaned = 0;
            do {
                cleaned += environment.cleanLog();
            } while(cleaned > 0);
            if(cleaned > 0)
                System.out.println("Cleaned " + cleaned + " files.");
            CheckpointConfig cp = new CheckpointConfig();
            cp.setForce(true);
            environment.checkpoint(null);
            environment.compress();
            environment.sync();
            System.out.println("Cleaning, Checkpointing and compression completed.");
        }

        System.out.println();
        System.out.println("iteration read write:");
        for(int i = 0; i < iterations; i++) {
            System.out.print(i);
            System.out.print(" " + readTimes[i] / (double) increment);
            System.out.println(" " + writeTimes[i] / (double) increment);
        }

        System.out.println(environment.getStats(null));

        System.exit(0);
    }
View Full Code Here

        EnvironmentConfig environmentConfig = new EnvironmentConfig();
        environmentConfig.setDurability(Durability.COMMIT_NO_SYNC);
        environmentConfig.setAllowCreate(true);
        environmentConfig.setTransactional(config.isBdbWriteTransactionsEnabled());
        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

        this.envConfig = new EnvironmentConfig();
        this.envConfig.setDurability(Durability.COMMIT_NO_SYNC);
        this.envConfig.setAllowCreate(true);
        this.envConfig.setTransactional(true);
        this.tempDir = TestUtils.createTempDir();
        this.environment = new Environment(this.tempDir, envConfig);
        this.databaseConfig = new DatabaseConfig();
        databaseConfig.setAllowCreate(true);
        databaseConfig.setTransactional(true);
        databaseConfig.setSortedDuplicates(false);
        this.database = environment.openDatabase(null, "test", databaseConfig);
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.