<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 2002-2009 Oracle.  All rights reserved.
 *
 * $Id$
 */

package com.sleepycat.db;

import com.sleepycat.db.internal.DbEnv;
import com.sleepycat.db.internal.DbConstants;

/**
Specifies the attributes of an application invoked checkpoint operation.
*/
public class CheckpointConfig {
    /**
    Default configuration used if null is passed to
    {@link com.sleepycat.db.Environment#checkpoint Environment.checkpoint}.
    */
    public static final CheckpointConfig DEFAULT = new CheckpointConfig();

    private boolean force = false;
    private int kbytes = 0;
    private int minutes = 0;

    /**
    An instance created using the default constructor is initialized
    with the system's default settings.
    */
    public CheckpointConfig() {
    }

    /* package */
    static CheckpointConfig checkNull(CheckpointConfig config) {
        return (config == null) ? DEFAULT : config;
    }

    /**
    Configure the checkpoint log data threshold, in kilobytes.
    &lt;p&gt;
    The default is 0 for this class and the database environment.
    &lt;p&gt;
    @param kbytes
    If the kbytes parameter is non-zero, a checkpoint will be performed if more
    than kbytes of log data have been written since the last checkpoint.
    */
    public void setKBytes(final int kbytes) {
        this.kbytes = kbytes;
    }

    /**
Return the checkpoint log data threshold, in kilobytes.
&lt;p&gt;
This method may be called at any time during the life of the application.
&lt;p&gt;
@return
The checkpoint log data threshold, in kilobytes.
    */
    public int getKBytes() {
        return kbytes;
    }

    /**
    Configure the checkpoint time threshold, in minutes.
    &lt;p&gt;
    The default is 0 for this class and the database environment.
    &lt;p&gt;
    @param minutes
    If the minutes parameter is non-zero, a checkpoint is performed if more than
    min minutes have passed since the last checkpoint.
    */
    public void setMinutes(final int minutes) {
        this.minutes = minutes;
    }

    /**
    Return the checkpoint time threshold, in minutes.
    &lt;p&gt;
    @return
    The checkpoint time threshold, in minutes.
    */
    public int getMinutes() {
        return minutes;
    }

    /**
    Configure the checkpoint force option.
    &lt;p&gt;
    The default is false for this class and the BDB JE environment.
    &lt;p&gt;
    @param force
    If set to true, force a checkpoint, even if there has been no
    activity since the last checkpoint.
    */
    public void setForce(final boolean force) {
        this.force = force;
    }

    /**
    Return the configuration of the checkpoint force option.
    &lt;p&gt;
    @return
    The configuration of the checkpoint force option.
    */
    public boolean getForce() {
        return force;
    }

    /* package */
    void runCheckpoint(final DbEnv dbenv)
        throws DatabaseException {

        dbenv.txn_checkpoint(kbytes, minutes, force ? DbConstants.DB_FORCE : 0);
    }
}
</pre></body></html>