Package com.sleepycat.je

Examples of com.sleepycat.je.Environment


    }

    public void run() {
        EnvironmentConfig envConfig = new EnvironmentConfig();
        envConfig.setReadOnly(true);
        Environment env = new Environment(envHome, envConfig);
        EnvironmentImpl envImpl = DbInternal.getEnvironmentImpl(env);

        try {
            FileReader reader;
            if (vlsnDump) {
                out.println("Dump VLSNIndex LNs");
                reader = new VLSNIndexReader(env, out, startLsn, endLsn);
            } else if (repGroupDump) {
                out.println("Dump RepGroup LNs");
                reader = new RepGroupReader(env, out, startLsn, endLsn);
            } else if (verifyStream) {
                out.println("Replication stream: check that vlsns ascend");
                reader = new VerifyReader(envImpl, out, startLsn, endLsn);
            } else {
                out.println("No action specified.");
                return;
            }

            while (reader.readNextEntry()) {
            }

            if ((!vlsnDump) && (!repGroupDump)) {
                ((VerifyReader) reader).displayLast();
                VLSNIndex.verifyDb(env, out, verbose);
            }

            System.exit(0);
        } catch (Throwable e) {
            e.printStackTrace(out);
            System.exit(1);
        } finally {
            try {
                env.close();
            } catch (Throwable e) {
                e.printStackTrace(out);
                System.exit(1);
            }
        }
View Full Code Here


        }

        if (isAbnormalClose) {
            envInternal = null;
        } else {
            final Environment savedEnvInternal = envInternal;
            /* Blocks recursions resulting from the close operation below */
            envInternal = null;
            DbInternal.closeInternalHandle(savedEnvInternal);
        }
    }
View Full Code Here

         * Initialize the SyncDB. If allowCreate is true, create the SyncDB if
         * it doesn't exist.
         */
        boolean success = false;

        final Environment env = envImpl.getInternalEnvHandle();
        assert env != null;
        final Transaction txn = DbInternal.beginInternalTransaction(env, null);
        try {

            /*
 
View Full Code Here

        EnvironmentConfig envConfig = new EnvironmentConfig();
        /* envConfig.setTransactional(false); */
        envConfig.setAllowCreate(false);
        envConfig.setReadOnly(true);
        try {
            return new Environment(new File(envDir), envConfig);
        } catch (EnvironmentLockedException e) {
            e.printStackTrace();
        } catch (DatabaseException e) {
            e.printStackTrace();
        }
View Full Code Here

        throws Exception {

        EnvironmentConfig envConfiguration = new EnvironmentConfig();
        envConfiguration.setReadOnly(true);
        envConfiguration.setCachePercent(40);
        Environment env1 = new Environment(home1, envConfiguration);

        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setReadOnly(true);
        DbInternal.setUseExistingConfig(dbConfig, true);

        Database db2;
        if (home2 != null) {
            Environment env2 = new Environment(home2, envConfiguration);
            if (file1 == null) {
                /* No dbs given, ldiff the environments. */
                boolean ret = diff(env1, env2);
                env1.close();
                env2.close();
                return ret;
            }
            db2 = env2.openDatabase(null, file2, dbConfig);
        } else {
            db2 = env1.openDatabase(null, file2, dbConfig);
        }
        Database db1 = env1.openDatabase(null, file1, dbConfig);

View Full Code Here

                    (EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
            }

            recoveryStart = System.currentTimeMillis();

            Environment env =
                new Environment(new File(envHome), envConfig);

            CheckpointConfig forceConfig = new CheckpointConfig();
            forceConfig.setForce(true);

            Thread statsPrinter = null;
            if (printStats) {
                statsPrinter = new StatsPrinter(env);
                statsPrinter.start();
            }
           
            boolean promptForShutdown = false;
            actionStart = System.currentTimeMillis();
            switch(doAction) {
            case BATCH_CLEAN:
                /* Since this is batch cleaning, repeat until no progress. */
                while (true) {
                    int nFiles = env.cleanLog();
                    System.out.println("Files cleaned: " + nFiles);
                    if (nFiles == 0) {
                        break;
                    }
                }
                env.checkpoint(forceConfig);
                break;
            case COMPRESS:
                env.compress();
                break;
            case CHECKPOINT:
                env.checkpoint(forceConfig);
                break;
            case EVICT:
                preload(env, dbName);
                break;
            case REMOVEDB:
                removeAndClean(env, dbName, false);
                break;
            case REMOVEDB_AND_CLEAN:
                removeAndClean(env, dbName, true);
                break;
            case ACTIVATE_CLEANER_THREADS:
                EnvironmentImpl envImpl =
                    DbInternal.getEnvironmentImpl(env);
                envImpl.getCleaner().wakeup();
                promptForShutdown = true;
                break;
            case VERIFY_UTILIZATION:
                EnvironmentImpl envImpl2 =
                    DbInternal.getEnvironmentImpl(env);
                VerifyUtils. verifyUtilization
                    (envImpl2,
                     true,  // expectAccurateObsoleteLNCount
                     true,  // expectAccurateObsoleteLNSize
                     true); // expectAccurateDbUtilization
                break;
            }
            actionEnd = System.currentTimeMillis();

            if (promptForShutdown) {

                /*
                 * If the requested action is a daemon driven one, we don't
                 * want the main thread to shutdown the environment until we
                 * say we're ready
                 */
                waitForShutdown();
            }
            if (statsPrinter != null) {
                statsPrinter.interrupt();
                statsPrinter.join();
            }
            env.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(e.getMessage());
            usage();
            System.exit(1);
View Full Code Here

        }
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));

        EnvironmentConfig envConfig = new EnvironmentConfig();
        envConfig.setAllowCreate(true);
        Environment env = new Environment(envHome, envConfig);
        ret.setEnv(env);
        ret.setDbName(dbName);
        ret.setInputReader(reader);
        ret.setNoOverwrite(noOverwrite);
        ret.setTextFileMode(textFileMode);
View Full Code Here

    public StorageEngine<ByteArray, byte[], byte[]> getStore(StoreDefinition storeDef,
                                                             RoutingStrategy strategy) {
        synchronized(lock) {
            try {
                String storeName = storeDef.getName();
                Environment environment = getEnvironment(storeDef);
                Database db = environment.openDatabase(null, storeName, databaseConfig);
                BdbRuntimeConfig runtimeConfig = new BdbRuntimeConfig(voldemortConfig);
                BdbStorageEngine engine = null;
                if(voldemortConfig.getBdbPrefixKeysWithPartitionId()) {
                    engine = new PartitionPrefixedBdbStorageEngine(storeName,
                                                                   environment,
View Full Code Here

            // Only cleanup the environment if it is per store. We cannot
            // cleanup a shared 'Environment' object
            if(useOneEnvPerStore) {

                Environment environment = this.environments.get(storeName);
                if(environment == null) {
                    // Nothing to clean up.
                    return;
                }

                // Remove from the set of unreserved stores if needed.
                if(this.unreservedStores.remove(environment)) {
                    logger.info("Removed environment for store name: " + storeName
                                + " from unreserved stores");
                } else {
                    logger.info("No environment found in unreserved stores for store name: "
                                + storeName);
                }

                // Try to delete the BDB directory associated
                File bdbDir = environment.getHome();
                if(bdbDir.exists() && bdbDir.isDirectory()) {
                    String bdbDirPath = bdbDir.getPath();
                    try {
                        FileUtils.deleteDirectory(bdbDir);
                        logger.info("Successfully deleted BDB directory : " + bdbDirPath
                                    + " for store name: " + storeName);
                    } catch(IOException e) {
                        logger.error("Unable to delete BDB directory: " + bdbDirPath
                                     + " for store name: " + storeName);
                    }
                }

                // Remove the reference to BdbEnvironmentStats, which holds a
                // reference to the Environment
                BdbEnvironmentStats bdbEnvStats = bdbEngine.getBdbEnvironmentStats();
                this.aggBdbStats.unTrackEnvironment(bdbEnvStats);

                // Unregister the JMX bean for Environment
                if(voldemortConfig.isJmxEnabled()) {
                    ObjectName name = JmxUtils.createObjectName(JmxUtils.getPackageName(bdbEnvStats.getClass()),
                                                                storeName);
                    // Un-register the environment stats mbean
                    JmxUtils.unregisterMbean(name);
                }

                // Cleanup the environment
                environment.close();
                this.environments.remove(storeName);
                logger.info("Successfully closed the environment for store name : " + storeName);

            }
        }
View Full Code Here

                    environmentConfig.setSharedCache(true);
                    environmentConfig.setCacheSize(voldemortConfig.getBdbCacheSize()
                                                   - this.reservedCacheSize);
                }

                Environment environment = new Environment(bdbDir, environmentConfig);
                logger.info("Creating environment for " + storeName + ": ");
                logEnvironmentConfig(environment.getConfig());
                environments.put(storeName, environment);

                // save this up so we can adjust later if needed
                if(!storeDef.hasMemoryFootprint())
                    this.unreservedStores.add(environment);

                return environment;
            } else {
                if(!environments.isEmpty())
                    return environments.get(SHARED_ENV_KEY);

                File bdbDir = new File(bdbMasterDir);
                createBdbDirIfNecessary(bdbDir);

                Environment environment = new Environment(bdbDir, environmentConfig);
                logger.info("Creating shared BDB environment: ");
                logEnvironmentConfig(environment.getConfig());
                environments.put(SHARED_ENV_KEY, environment);
                return environment;
            }
        }
    }
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.