001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2013 ForgeRock AS
025 */
026package org.opends.server.replication.server.changelog.api;
027
028
029
030/**
031 * This interface is the entry point for the changelog database which stores the
032 * replication data on persistent storage. It allows to control the overall
033 * database or access more specialized interfaces.
034 */
035public interface ChangelogDB
036{
037
038  /**
039   * Initializes the replication database by reading its previous state and
040   * building the relevant ReplicaDBs according to the previous state. This
041   * method must be called once before using the ChangelogDB.
042   */
043  void initializeDB();
044
045  /**
046   * Sets the purge delay for the replication database. Can be called while the
047   * database is running.
048   * <p>
049   * Purging happens on a best effort basis, i.e. the purge delay is used by the
050   * replication database to know which data can be purged, but there are no
051   * guarantees on when the purging will actually happen.
052   *
053   * @param delayInMillis
054   *          the purge delay in milliseconds
055   */
056  void setPurgeDelay(long delayInMillis);
057
058  /**
059   * Sets whether the replication database must compute change numbers for
060   * replicated changes. Change numbers are computed using a separate new
061   * thread.
062   *
063   * @param computeChangeNumber
064   *          whether to compute change numbers for replicated changes
065   * @throws ChangelogException
066   *           If a database problem happened
067   */
068  void setComputeChangeNumber(boolean computeChangeNumber)
069      throws ChangelogException;
070
071  /**
072   * Shutdown the replication database.
073   *
074   * @throws ChangelogException
075   *           If a database problem happened
076   */
077  void shutdownDB() throws ChangelogException;
078
079  /**
080   * Removes the changelog database directory.
081   *
082   * @throws ChangelogException
083   *           If a database problem happened
084   */
085  void removeDB() throws ChangelogException;
086
087  /**
088   * Returns the {@link ChangeNumberIndexDB} object.
089   *
090   * @return the {@link ChangeNumberIndexDB} object
091   */
092  ChangeNumberIndexDB getChangeNumberIndexDB();
093
094  /**
095   * Returns the {@link ReplicationDomainDB} object.
096   *
097   * @return the {@link ReplicationDomainDB} object
098   */
099  ReplicationDomainDB getReplicationDomainDB();
100}