journal.h revision 4e68c7c87c30c28490c92937adc112dca5b5d5ae
/*
* Copyright (C) 2004-2009, 2011 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2001 Internet Software Consortium.
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: journal.h,v 1.39 2011/08/30 23:46:53 tbox Exp $ */
#ifndef DNS_JOURNAL_H
#define DNS_JOURNAL_H 1
/*****
***** Module Info
*****/
* \brief
* Database journaling.
*/
/***
*** Imports
***/
/***
*** Defines.
***/
#define DNS_JOURNALOPT_RESIGN 0x00000001
#define DNS_JOURNAL_WRITE 0x00000002
/***
*** Types
***/
/*%
* A dns_journal_t represents an open journal file. This is an opaque type.
*
* A particular dns_journal_t object may be opened for writing, in which case
* it can be used for writing transactions to a journal file, or it can be
* opened for reading, in which case it can be used for reading transactions
* from (iterating over) a journal file. A single dns_journal_t object may
* not be used for both purposes.
*/
typedef struct dns_journal dns_journal_t;
/***
*** Functions
***/
/**************************************************************************/
/*!< brief
* Create a diff tuple for the current database SOA.
* XXX this probably belongs somewhere else.
*/
/*@{*/
#define DNS_SERIAL_GT(a, b) ((int)(((a) - (b)) & 0xFFFFFFFF) > 0)
#define DNS_SERIAL_GE(a, b) ((int)(((a) - (b)) & 0xFFFFFFFF) >= 0)
/*!< brief
* Compare SOA serial numbers. DNS_SERIAL_GT(a, b) returns true iff
* a is "greater than" b where "greater than" is as defined in RFC1982.
* DNS_SERIAL_GE(a, b) returns true iff a is "greater than or equal to" b.
*/
/*@}*/
/**************************************************************************/
/*
* Journal object creation and destruction.
*/
/*%<
* Open the journal file 'filename' and create a dns_journal_t object for it.
*
* DNS_JOURNAL_CREATE open the journal for reading and writing and create
* the journal if it does not exist.
* DNS_JOURNAL_WRITE open the journal for readinge and writing.
* DNS_JOURNAL_READ open the journal for reading only.
*/
void
/*%<
* Destroy a dns_journal_t, closing any open files and freeing its memory.
*/
/**************************************************************************/
/*
* Writing transactions to journals.
*/
/*%<
* Prepare to write a new transaction to the open journal file 'j'.
*
* Requires:
* \li 'j' is open for writing.
*/
/*%<
* Write 'diff' to the current transaction of journal file 'j'.
*
* Requires:
* \li 'j' is open for writing and dns_journal_begin_transaction()
* has been called.
*
*\li 'diff' is a full or partial, correctly ordered IXFR
* difference sequence.
*/
/*%<
* Commit the current transaction of journal file 'j'.
*
* Requires:
* \li 'j' is open for writing and dns_journal_begin_transaction()
* has been called.
*
* \li dns_journal_writediff() has been called one or more times
* to form a complete, correctly ordered IXFR difference
* sequence.
*/
/*%
* Write a complete transaction at once to a journal file,
* sorting it if necessary, and commit it. Equivalent to calling
* dns_diff_sort(), dns_journal_begin_transaction(),
* dns_journal_writediff(), and dns_journal_commit().
*
* Requires:
*\li 'j' is open for writing.
*
* \li 'diff' contains exactly one SOA deletion, one SOA addition
* with a greater serial number, and possibly other changes,
* in arbitrary order.
*/
/**************************************************************************/
/*
* Reading transactions from journals.
*/
/*%<
* Get the first and last addressable serial number in the journal.
*/
/*%<
* Prepare to iterate over the transactions that will bring the database
* from SOA serial number 'begin_serial' to 'end_serial'.
*
* Returns:
*\li ISC_R_SUCCESS
*\li ISC_R_RANGE begin_serial is outside the addressable range.
*\li ISC_R_NOTFOUND begin_serial is within the range of addressable
* serial numbers covered by the journal, but
* this particular serial number does not exist.
*/
/*@{*/
/*%<
* transaction sequence established using dns_journal_iter_init().
*
* Requires:
* \li dns_journal_iter_init() has been called.
*
*/
/*@}*/
void
dns_rdata_t **rdata);
/*%<
* Get the name, ttl, and rdata of the current journal RR.
*
* Requires:
* \li The last call to dns_journal_first_rr() or dns_journal_next_rr()
* returned ISC_R_SUCCESS.
*/
/**************************************************************************/
/*
* Database roll-forward.
*/
const char *filename);
/*%<
* Roll forward (play back) the journal file "filename" into the
* database "db". This should be called when the server starts
* after a shutdown or crash. 'resign' is how many seconds before
* a RRSIG is due to expire it should be scheduled to be regenerated.
*
* Requires:
*\li dns_journal_rollforward() requires that DNS_JOURNALOPT_RESIGN
* is not set.
*\li 'mctx' is a valid memory context.
*\li 'db' is a valid database which does not have a version
* open for writing.
*\li 'filename' is the name of the journal file belonging to 'db'.
*
* Returns:
*\li DNS_R_NOJOURNAL when journal does not exist.
*\li ISC_R_NOTFOUND when current serial in not in journal.
*\li ISC_R_RANGE when current serial in not in journals range.
*\li ISC_R_SUCCESS journal has been applied successfully to database.
* others
*/
/* For debugging not general use */
const char *journal_filename);
/*%<
* Compare the databases 'dba' and 'dbb' and generate a journal
* entry containing the changes to make 'dba' from 'dbb' (note
* the order). This journal entry will consist of a single,
* possibly very large transaction. Append the journal
* entry to the journal file specified by 'journal_filename'.
*/
/*%<
* Attempt to compact the journal if it is greater that 'target_size'.
* Changes from 'serial' onwards will be preserved. If the journal
* exists and is non-empty 'serial' must exist in the journal.
*/
void
/*%<
* Get and set bump in the wire serial.
*/
#endif /* DNS_JOURNAL_H */