Java源码示例:com.sleepycat.je.CheckpointConfig

示例1
@Override
public void checkpoint(final boolean force)
{
    CheckpointConfig ckptConfig = new CheckpointConfig();
    ckptConfig.setForce(force);
    getEnvironment().checkpoint(ckptConfig);
}
 
示例2
public synchronized static void runCleaner(final Environment environment)
{
    if (environment == null || !environment.isValid())
    {
        return;
    }

    boolean cleanerWasRunning = Boolean.parseBoolean(environment.getConfig().getConfigParam(EnvironmentConfig.ENV_RUN_CLEANER));

    try
    {
        if (cleanerWasRunning)
        {
            environment.getConfig().setConfigParam(EnvironmentConfig.ENV_RUN_CLEANER, Boolean.FALSE.toString());
        }

        if (LOGGER.isDebugEnabled())
        {
            LOGGER.debug("Cleaning logs");
        }

        boolean cleaned = false;
        while (environment.cleanLog() > 0)
        {
            cleaned = true;
        }
        if (cleaned)
        {
            LOGGER.debug("Cleaned log");

            CheckpointConfig force = new CheckpointConfig();
            force.setForce(true);
            environment.checkpoint(force);

            LOGGER.debug("Checkpoint force complete");
        }
    }
    finally
    {
        if (cleanerWasRunning)
        {
            environment.getConfig().setConfigParam(EnvironmentConfig.ENV_RUN_CLEANER, Boolean.TRUE.toString());
        }
    }

}
 
示例3
public void startup(HGStore store, HGConfiguration config)
{
	this.store = store;
	this.handleFactory = config.getHandleFactory();
	this.linkBinding = new LinkBinding(handleFactory);
	EnvironmentConfig envConfig = configuration.getEnvironmentConfig();
	envConfig.setConfigParam(EnvironmentConfig.CLEANER_THREADS, "5");
	envConfig.setClassLoader(new HGClassLoaderDelegate(config));
	if (config.isTransactional())
	{
		configuration.configureTransactional();
	}

	File envDir = new File(store.getDatabaseLocation());
	envDir.mkdirs();

	try
	{
		env = new Environment(envDir, envConfig);
		data_db = env.openDatabase(null, DATA_DB_NAME, configuration.getDatabaseConfig().clone());
		primitive_db = env.openDatabase(null, PRIMITIVE_DB_NAME, configuration.getDatabaseConfig().clone());

		DatabaseConfig incConfig = configuration.getDatabaseConfig().clone();
		incConfig.setSortedDuplicates(true);
		incidence_db = env.openDatabase(null, INCIDENCE_DB_NAME, incConfig);

		openIndices = new HashMap<String, HGIndex<?, ?>>(); // force reset
															// since startup
															// can follow a
															// shutdown on
															// same opened
															// class

		if (config.isTransactional())
		{
			CheckpointConfig ckptConfig = new CheckpointConfig();
			// System.out.println("checkpoint kbytes:" +
			// ckptConfig.getKBytes());
			// System.out.println("checkpoint minutes:" +
			// ckptConfig.getMinutes());
			env.checkpoint(null);
			checkPointThread = new CheckPointThread();
			checkPointThread.start();
		}
	}
	catch (Exception ex)
	{
		throw new HGException("Failed to initialize HyperGraph data store: " + ex.toString(), ex);
	}
}