Package com.sleepycat.je

Examples of com.sleepycat.je.EnvironmentConfig


             * Force the buffers and files to be small. The log buffer is
             * actually too small, will have to grow dynamically. We read in 32
             * byte chunks, will have to re-read only holds one test item (each
             * test item is 50 bytes)
             */
            EnvironmentConfig envConfig = TestUtils.initEnvConfig();
      DbInternal.disableParameterValidation(envConfig);
            envConfig.setConfigParam
    (EnvironmentParams.LOG_MEM_SIZE.getName(),
     EnvironmentParams.LOG_MEM_SIZE_MIN_STRING);
            envConfig.setConfigParam
    (EnvironmentParams.NUM_LOG_BUFFERS.getName(), "2");
            envConfig.setConfigParam
    (EnvironmentParams.LOG_FILE_MAX.getName(), "200");
            envConfig.setConfigParam
    (EnvironmentParams.LOG_FAULT_READ_SIZE.getName(), "32");
            envConfig.setConfigParam
    (EnvironmentParams.NODE_MAX.getName(), "6");
            envConfig.setAllowCreate(true);
            env = new EnvironmentImpl(envHome, envConfig);
            fileManager = env.getFileManager();
            logManager = env.getLogManager();

            logAndRetrieve();
View Full Code Here


        int logBufferMemSize = logBufferSize * numLogBuffers;
        int logFileMax = 1000;
        int okCounter = 0;
       
        try {
            EnvironmentConfig envConfig = TestUtils.initEnvConfig();
      DbInternal.disableParameterValidation(envConfig);
            envConfig.setConfigParam(EnvironmentParams.LOG_MEM_SIZE.getName(),
                                     new Integer(logBufferMemSize).toString());
            envConfig.setConfigParam
    (EnvironmentParams.NUM_LOG_BUFFERS.getName(),
     new Integer(numLogBuffers).toString());
            envConfig.setConfigParam
    (EnvironmentParams.LOG_FILE_MAX.getName(),
     new Integer(logFileMax).toString());
            envConfig.setConfigParam(
                            EnvironmentParams.NODE_MAX.getName(), "6");
            envConfig.setConfigParam
    (EnvironmentParams.JE_LOGGING_LEVEL.getName(), "SEVERE");
           
            /* Don't checkpoint utilization info for this test. */
            DbInternal.setCheckpointUP(envConfig, false);

            /*
             * Don't run any daemons, those emit trace messages and other log
             * entries and mess up our accounting.
             */
            turnOffDaemons(envConfig);
            envConfig.setAllowCreate(true);
            env = new EnvironmentImpl(envHome, envConfig);
            fileManager = env.getFileManager();
            logManager = env.getLogManager();

            /* Keep track of items logged and their LSNs. */
            ArrayList testRecs = new ArrayList();
            ArrayList testLsns = new ArrayList();

            /*
             * Intersperse:
             * - log successfully
             * - log w/failure because the item doesn't fit in the log buffer
             * - have I/O failures writing out the log
             * Verify that all expected items can be read. Some will come
             * from the log buffer pool.
             * Then close and re-open the environment, to verify that
             * all log items are faulted from disk
             */
           
            /* Successful log. */
            addOkayItem(logManager, okCounter++,
                        testRecs, testLsns, logBufferSize);
           
            /* Item that's too big for the log buffers. */
            attemptTooBigItem(logManager, logBufferSize, testRecs, testLsns);

            /* Successful log. */
            addOkayItem(logManager, okCounter++,
                        testRecs, testLsns, logBufferSize);
           
            /*
             * This verify read the items from the log buffers. Note before SR
             * #12638 existed (LSN state not restored properly after exception
             * because of too-small log buffer), this verify hung.
             */
            verifyOkayItems(logManager, testRecs, testLsns, true);

            /* More successful logs, along with a few too-big items. */

            for (;okCounter < 23; okCounter++) {
                addOkayItem(logManager, okCounter, testRecs,
                            testLsns, logBufferSize);

                if ((okCounter % 4) == 0) {
                    attemptTooBigItem(logManager, logBufferSize,
              testRecs, testLsns);
                }
                /*
                 * If we verify in the loop, sometimes we'll read from disk and
                 * sometimes from the log buffer pool.
                 */
                verifyOkayItems(logManager, testRecs, testLsns, true);
            }

            /*
             * Test the case where we flip files and write the old write buffer
             * out before we try getting a log buffer for the new item. We need
             * to
             *
             * - hit a log-too-small exceptin
             * - right after, we need to log an item that is small enough
             *   to fit in the log buffer but big enough to require that
             *   we flip to a new file.
             */
            long nextLsn = fileManager.getNextLsn();
            long fileOffset = DbLsn.getFileOffset(nextLsn);

            assertTrue((logFileMax - fileOffset ) < logBufferSize);
            attemptTooBigItem(logManager, logBufferSize, testRecs, testLsns);
            addOkayItem(logManager, okCounter++,
                        testRecs, testLsns, logBufferSize,
                        ((int)(logFileMax - fileOffset)));
            verifyOkayItems(logManager, testRecs, testLsns, true);
           
            /* Invoke some i/o exceptions. */
            for (;okCounter < 50; okCounter++) {
                attemptIOException(logManager, fileManager, testRecs,
                                   testLsns, false);
                addOkayItem(logManager, okCounter,
                            testRecs, testLsns, logBufferSize);
                verifyOkayItems(logManager, testRecs, testLsns, false);
            }

            /*
             * Finally, close this environment and re-open, and read all
             * expected items from disk.
             */
            env.close();
            envConfig.setAllowCreate(false);
            env = new EnvironmentImpl(envHome, envConfig);
            fileManager = env.getFileManager();
            logManager = env.getLogManager();
            verifyOkayItems(logManager, testRecs, testLsns, false);

View Full Code Here

    /* Create an environment, specifying the log file size. */
    private void initEnv(String logFileSize)
        throws DatabaseException {

        EnvironmentConfig envConfig = TestUtils.initEnvConfig();

        /* Don't run daemons; we do some abrupt shutdowns. */
        envConfig.setConfigParam
            (EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
        envConfig.setConfigParam
            (EnvironmentParams.ENV_RUN_CHECKPOINTER.getName(), "false");
        envConfig.setConfigParam
            (EnvironmentParams.ENV_RUN_EVICTOR.getName(), "false");

        envConfig.setConfigParam
      (EnvironmentParams.NODE_MAX.getName(), "6");
  envConfig.setConfigParam
      (EnvironmentParams.JE_LOGGING_LEVEL.getName(), "CONFIG");
        if (logFileSize != null) {
      DbInternal.disableParameterValidation(envConfig);
            envConfig.setConfigParam
                (EnvironmentParams.LOG_FILE_MAX.getName(), logFileSize);
        }

        /* Don't checkpoint utilization info for this test. */
        DbInternal.setCheckpointUP(envConfig, false);
  envConfig.setAllowCreate(true);
        envImpl = new EnvironmentImpl(envHome, envConfig);
        configManager = envImpl.getConfigManager();
        fileManager = envImpl.getFileManager();
        logManager = envImpl.getLogManager();
    }
View Full Code Here

    }

    private void tempBufferInitEnvInternal(String buffSize, String cacheSize)
  throws DatabaseException {

        EnvironmentConfig envConfig = TestUtils.initEnvConfig();
        envConfig.setTransactional(true);
        envConfig.setAllowCreate(true);
  if (!buffSize.equals("0")) {
      envConfig.setConfigParam("je.log.totalBufferBytes", buffSize);
  }

  if (!cacheSize.equals("0")) {
      envConfig.setConfigParam("je.maxMemory", cacheSize);
  }
        env = new Environment(new File("."), envConfig);

        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setAllowCreate(true);
View Full Code Here

    }

    private void setupEnv(boolean inMemory)
        throws Exception {

        EnvironmentConfig envConfig = TestUtils.initEnvConfig();
  
  DbInternal.disableParameterValidation(envConfig);
        envConfig.setConfigParam(EnvironmentParams.LOG_MEM_SIZE.getName(),
                                 EnvironmentParams.LOG_MEM_SIZE_MIN_STRING);
  envConfig.setConfigParam
      (EnvironmentParams.LOG_FILE_MAX.getName(), "90");
  envConfig.setConfigParam
      (EnvironmentParams.NUM_LOG_BUFFERS.getName(), "2");
  envConfig.setAllowCreate(true);
        if (inMemory) {
            /* Make the bufPool grow some buffers. Disable writing. */
            envConfig.setConfigParam
    (EnvironmentParams.LOG_MEMORY_ONLY.getName(), "true");
        }
        environment = new EnvironmentImpl(envHome, envConfig);

        /* Make a standalone file manager for this test. */
 
View Full Code Here

                         int expectedOverflows)
        throws Exception {

        try {
       
            EnvironmentConfig envConfig = TestUtils.initEnvConfig();
            envConfig.setAllowCreate(true);
            envConfig.setConfigParam(
                     EnvironmentParams.LOG_ITERATOR_MAX_SIZE.getName(),
                                     bufferMaxSize);
            env = new Environment(envHome, envConfig);

            envImpl = DbInternal.envGetEnvironmentImpl(env);
View Full Code Here

     */
    public synchronized void setMutableConfig(EnvironmentMutableConfig config)
        throws DatabaseException {

        /* Clone the current config. */
        EnvironmentConfig newConfig =
            DbInternal.cloneConfig(configManager.getEnvironmentConfig());

        /* Copy in the mutable props. */
        DbInternal.copyMutablePropsTo(config, newConfig);

View Full Code Here

     */
    public static EnvironmentImpl makeUtilityEnvironment(File envHome,
               boolean readOnly)
        throws DatabaseException {
       
        EnvironmentConfig config = new EnvironmentConfig();
        config.setReadOnly(readOnly);
       
        /* Don't debug log to the database log. */
        config.setConfigParam(EnvironmentParams.JE_LOGGING_DBLOG.getName(),
            "false");
        /* Do debug log to the console. */
        config.setConfigParam(EnvironmentParams.JE_LOGGING_CONSOLE.getName(),
            "true");

        /* Set logging level to only show errors. */
        config.setConfigParam(EnvironmentParams.JE_LOGGING_LEVEL.getName(),
            "SEVERE");

        /* Don't run recovery. */
        config.setConfigParam(EnvironmentParams.ENV_RECOVERY.getName(),
            "false");

  EnvironmentImpl envImpl = new EnvironmentImpl(envHome, config);
  return envImpl;
    }
View Full Code Here

     * and we then attempted to read it with DbPrintLog.
     */
    public void testEmptyExtraFile()
        throws Throwable {
 
  EnvironmentConfig envConfig = TestUtils.initEnvConfig();
        envConfig.setAllowCreate(true);
        Environment env = new Environment(envHome, envConfig);

        try {
            /* Make an environment. */
            env.sync();
View Full Code Here

        env.close();
  return infoList;
    }

    private EnvironmentConfig getRecoveryConfig(boolean readOnlyMode) {
        EnvironmentConfig recoveryConfig = TestUtils.initEnvConfig();
        recoveryConfig.setConfigParam
            (EnvironmentParams.NODE_MAX.getName(), "6");
  recoveryConfig.setConfigParam(EnvironmentParams.MAX_MEMORY.getName(),
              new Long(1 << 24).toString());
        recoveryConfig.setReadOnly(readOnlyMode);

        /*
         * Don't run checkLeaks, because verify is running while the system is
         * not quiescent. The other daemons are running.
         */
        recoveryConfig.setConfigParam
      (EnvironmentParams.ENV_CHECK_LEAKS.getName(), "false");
  recoveryConfig.setConfigParam
      (EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
  recoveryConfig.setConfigParam
      (EnvironmentParams.ENV_RUN_EVICTOR.getName(), "false");

        if (DEBUG) {
            recoveryConfig.setConfigParam
                (EnvironmentParams.JE_LOGGING_FILE.getName(), "true");
            recoveryConfig.setConfigParam
                (EnvironmentParams.JE_LOGGING_LEVEL.getName(), "FINE");
        }

  recoveryConfig.setTransactional(true);
  return recoveryConfig;
    }
View Full Code Here

TOP

Related Classes of com.sleepycat.je.EnvironmentConfig

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.