Package com.sleepycat.je

Examples of com.sleepycat.je.EnvironmentStats


             * to clear, then read again.
             */
            StatsConfig statsConfig = new StatsConfig();
            statsConfig.setFast(true);
            statsConfig.setClear(true);
            EnvironmentStats stats = env.getStats(statsConfig); // clear stats

            stats = env.getStats(statsConfig)// read again
            assertEquals(0, stats.getNCheckpoints());
            long lastCkptEnd = stats.getLastCheckpointEnd();
            int actualCheckpoints = 0;

            /* Run several checkpoints to ensure they occur as expected.  */
            for (int i = 0; i < N_CHECKPOINTS; i += 1) {

                /* Write enough to prompt a checkpoint. */
                EnvironmentImpl envImpl =
                    DbInternal.envGetEnvironmentImpl(env);
                /*
                 * Extra traces are used to account for the fact that the
                 * CheckpointMonitor only activates the Checkpointer every
                 * 1/10 of the checkpoint byte interval.
                 */
                for (int j = 0; j < N_TRACES + N_EXTRA_TRACES; j += 1) {

                    /* Write to log to wakeup checkpointer. */
                    Tracer.trace(Level.SEVERE, envImpl, traceMsg);

                    /*
                     * Check to see if a checkpoint has started.  We take
                     * advantage of the fact that the NCheckpoints stat is
                     * set at the start of a checkpoint.
                     */
                    stats = env.getStats(statsConfig);
                    if (stats.getNCheckpoints() > 0) {
                        assertEquals(1, stats.getNCheckpoints());
                        actualCheckpoints += 1;

                        /*
                         * Wait for the checkpointer daemon to do its work.
                         * We do not want to continue writing until the
                         * checkpoint is complete, because the amount of data
                         * we write is calculated to be the correct amount
                         * in between checkpoints.  We know the checkpoint is
                         * finished when the LastCheckpointEnd LSN changes.
                         */
                        while (true) {
                            Thread.yield();
                            Thread.sleep(1);
                            stats = env.getStats(statsConfig);
                            assertEquals(0, stats.getNCheckpoints());
                            if (lastCkptEnd != stats.getLastCheckpointEnd()) {
                                lastCkptEnd = stats.getLastCheckpointEnd();
                                break;
                            }
                        }
                    }
                }
View Full Code Here


             * to clear, then read again.
             */
            StatsConfig statsConfig = new StatsConfig();
            statsConfig.setFast(true);
            statsConfig.setClear(true);
            EnvironmentStats stats = env.getStats(statsConfig); // clear stats

            stats = env.getStats(statsConfig)// read again
            assertEquals(0, stats.getNCheckpoints());

            /*
       * From the last checkpoint start LSN, there should be the
       * checkpoint end log entry and a trace message. These take 196
       * bytes.
             */
            CheckpointConfig checkpointConfig = new CheckpointConfig();

            /* Should not cause a checkpoint, too little growth. */
            checkpointConfig.setKBytes(1);
            env.checkpoint(checkpointConfig);
            stats = env.getStats(statsConfig)// read again
            assertEquals(0, stats.getNCheckpoints());

            /* Fill up the log, there should be a checkpoint. */
            String filler = "123456789012345678901245678901234567890123456789";
            EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env);
            for (int i = 0; i < 20; i++) {
                Tracer.trace(Level.SEVERE, envImpl, filler);
            }
            env.checkpoint(checkpointConfig);
            stats = env.getStats(statsConfig)// read again
            assertEquals(1, stats.getNCheckpoints());

            /* Try time based, should not checkpoint. */
            checkpointConfig.setKBytes(0);
            checkpointConfig.setMinutes(1);
            env.checkpoint(checkpointConfig);
            stats = env.getStats(statsConfig)// read again
            assertEquals(0, stats.getNCheckpoints());

            /*
       * Sleep, enough time has passed for a checkpoint, but nothing was
       * written to the log.
             */
            Thread.sleep(1000);
            env.checkpoint(checkpointConfig);
            stats = env.getStats(statsConfig)// read again
            assertEquals(0, stats.getNCheckpoints());

            /* Log something, now try a checkpoint. */
            Tracer.trace(Level.SEVERE,  envImpl, filler);
            env.checkpoint(checkpointConfig);
            stats = env.getStats(statsConfig)// read again
View Full Code Here

        /* Create an environment, database, and insert some data. */
        try {
            initialize(true);

            EnvironmentStats stats = new EnvironmentStats();
            StatsConfig statsConfig = new StatsConfig();
            statsConfig.setClear(true);

            /*
             * Set up the test w/a number of INs that doesn't divide evenly
             * into scan sets.
             */
            int startingNumINs = envImpl.getInMemoryINs().getSize();
            assertTrue((startingNumINs % scanSize) != 0);

            Evictor evictor = envImpl.getEvictor();
            evictor.loadStats(statsConfig, stats);

            /*
             * Test evictBatch, where each batch only evicts one node because
             * we are passing one byte for the currentRequiredEvictBytes
             * parameter.  To predict the evicted nodes when more than one
             * target is selected, we would have to simulate eviction and
             * maintain a parallel IN tree, which is too complex.
             */
            for (int batch = 1;; batch += 1) {

                List expectedCandidates = new ArrayList();
                int expectedNScanned = getExpectedCandidates
                    (envImpl, evictor, expectedCandidates);

                evictor.evictBatch("test", 1);

                evictor.loadStats(statsConfig, stats);
                assertEquals(1, stats.getNEvictPasses());
                assertEquals(expectedNScanned, stats.getNNodesScanned());

                List candidates = evictor.evictProfile.getCandidates();
                assertEquals(expectedCandidates, candidates);

                /* Stop when no more nodes are evictable. */
 
View Full Code Here

             * Check the in compressor queue, we should have some number of
             * bins on. If the queue size is 0, then check the processed stats,
             * the in compressor thread may have already woken up and dealt
             * with the entries.
             */
            EnvironmentStats envStat = env.getStats(TestUtils.FAST_STATS);
            int queueSize = envStat.getInCompQueueSize();
            assertTrue(queueSize > 0);

            // Modify data, abort, check that data is unchanged
            txn = env.beginTransaction(null, null);
            createCursors(txn);
            cursorModifyData(0, numKeys * 2, 1);
            closeCursors();
            txn.abort();
            verifyData(numKeys*2, 0);

            // Delete data, abort, check that data is still there
            txn = env.beginTransaction(null, null);
            createCursors(txn);
            cursorDeleteData(numKeys+1, numKeys*2);
            closeCursors();
            txn.abort();
            verifyData(numKeys*2, 0);
            // Check the in compressor queue, nothing should be loaded
            envStat = env.getStats(TestUtils.FAST_STATS);
            assertEquals(queueSize, envStat.getInCompQueueSize());

            // Delete data, commit, check that data is gone
            txn = env.beginTransaction(null, null);
            createCursors(txn);
            cursorDeleteData(numKeys, numKeys*2);
            closeCursors();
            txn.commit();
            verifyData(numKeys, 0);

            // Check the inCompressor queue, there should be more entries.
            envStat = env.getStats(TestUtils.FAST_STATS);
            assertTrue(envStat.getInCompQueueSize() > queueSize);

            closeAll();

        } catch (Throwable t) {
            // print stacktrace before attempt to run tearDown
View Full Code Here

       * Run checkpoint on empty environment. Should be the second one
       * run, the first was run by recovery when the environment was
       * opened.
       */
            env.checkpoint(forceConfig);
            EnvironmentStats stats = env.getStats(TestUtils.FAST_STATS);
            assertEquals(2, stats.getNCheckpoints());
            assertEquals(2, stats.getLastCheckpointId());

            /* Shutdown, recover. */
            Hashtable expectedData = new Hashtable(); // expected values
            closeEnv()
            recoverAndVerify(expectedData, NUM_DBS); // 0 checkpoints

            /* Another checkpoint. */
            EnvironmentConfig envConfig = TestUtils.initEnvConfig();
            envConfig.setTransactional(true);
      envConfig.setConfigParam
    (EnvironmentParams.JE_LOGGING_LEVEL.getName(), "CONFIG");
            env = new Environment(envHome, envConfig);
            env.checkpoint(forceConfig);
            stats = env.getStats(TestUtils.FAST_STATS);
            assertEquals(2, stats.getNCheckpoints());
            assertEquals(4, stats.getLastCheckpointId());

            /* Shutdown, recover. */
            env.close();
            recoverAndVerify(expectedData, NUM_DBS);
        } catch (Throwable t) {
View Full Code Here

        createEnvAndDbs(1 << 20, true, NUM_DBS);

        try {

            EnvironmentStats stats = env.getStats(TestUtils.FAST_STATS);
            assertEquals(1, stats.getNCheckpoints());
            assertEquals(1, stats.getLastCheckpointId());

            /* Shutdown, recover. */
            Hashtable expectedData = new Hashtable(); // expected values
            Transaction txn = env.beginTransaction(null, null);
      insertData(txn, 0, 1, expectedData, 1, true, NUM_DBS);
      txn.commit();
            closeEnv();   // closes without a checkpoint
            recoverAndVerify(expectedData, NUM_DBS); // 1 checkpoint

            EnvironmentConfig envConfig = TestUtils.initEnvConfig();
            envConfig.setTransactional(true);
            env = new Environment(envHome, envConfig);
            stats = env.getStats(TestUtils.FAST_STATS);
            assertEquals(0, stats.getNCheckpoints());
            assertEquals(2, stats.getLastCheckpointId());
      env.close();
            env = new Environment(envHome, envConfig);
            stats = env.getStats(TestUtils.FAST_STATS);
            assertEquals(0, stats.getNCheckpoints());
            assertEquals(2, stats.getLastCheckpointId());

            /* Shutdown, recover. */
            env.close();
            recoverAndVerify(expectedData, NUM_DBS);
        } catch (Throwable t) {
View Full Code Here

            /*
             * If useDeltas is true, this next checkpoint will end up using a
             * BINDelta to log the last inserted record. It will have
             * practically nothing but the root in the checkpoint.
             */
            EnvironmentStats stats = env.getStats(statsConfig);
            env.checkpoint(deltaConfig);
            stats = env.getStats(statsConfig);
            if (useDeltas) {
                assertTrue(stats.getNDeltaINFlush() > 0);
            } else {
                assertTrue(stats.getNDeltaINFlush() == 0);
            }

            /* Shutdown, recover from a checkpoint that uses BINDeltas. */
            closeEnv();
            recoverAndVerify(expectedData, NUM_DBS);
View Full Code Here

    doClean(false, // invokedFromDaemon
      false, // cleanMultipleFiles
      true); // forceCleaning
        }

        EnvironmentStats stats = exampleEnv.getStats(TestUtils.FAST_STATS);
        assertTrue(stats.getNINsCleaned() > 0);
               
  cursor.close();
        closeEnv();

        initEnv(false, (nDupsPerKey > 1));
View Full Code Here

        Long lastNum = fileManager.getLastFileNum();
        exampleEnv.cleanLog();

        /* Validate after cleaning. */
        checkData(expectedMap);
        EnvironmentStats stats = exampleEnv.getStats(TestUtils.FAST_STATS);

        /* Make sure we really cleaned something.*/
        assertTrue(stats.getNINsCleaned() > 0);
        assertTrue(stats.getNLNsCleaned() > 0);
               
        closeEnv();
        initEnv(false, true);
        checkData(expectedMap);
        assertTrue(fileManager.getLastFileNum().longValue() >
View Full Code Here

        Long lastNum = fileManager.getLastFileNum();
        exampleEnv.cleanLog();
           
        /* Validate after cleaning. */
        checkData(expectedMap);
        EnvironmentStats stats = exampleEnv.getStats(TestUtils.FAST_STATS);

        /* Make sure we really cleaned something.*/
        assertTrue(stats.getNINsCleaned() > 0);
        assertTrue(stats.getNLNsCleaned() > 0);

        closeEnv();
        initEnv(false, true);
        checkData(expectedMap);
        assertTrue(fileManager.getLastFileNum().longValue() >
View Full Code Here

TOP

Related Classes of com.sleepycat.je.EnvironmentStats

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.