<!--$Id: env_event_notify.so,v 10.13 2007/04/05 20:37:29 bostic Exp $--> <!--Copyright (c) 1997,2007 Oracle. All rights reserved.--> <!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv::set_event_notify</title> <meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> <meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> </head> <body bgcolor=white> <table width="100%"><tr valign=top> <td> <h3>DbEnv::set_event_notify</h3> </td> <td align=right> <a href="../../db46-devel-4.6.21/api_cxx/api_core.html"><img src="../../db46-devel-4.6.21/images/api.gif" alt="API"></a> <a href="../../db46-devel-4.6.21/ref/toc.html"><img src="../../db46-devel-4.6.21/images/ref.gif" alt="Ref"></a></td> </tr></table> <hr size=1 noshade> <tt> <h3><pre> #include <db_cxx.h> <p> int DbEnv::set_event_notify(void (*db_event_fcn)(DB_ENV *dbenv, u_int32_t event, void *event_info)); </pre></h3> <hr size=1 noshade> <h3>Description: DbEnv::set_event_notify</h3> <p>The DbEnv::set_event_notify method configures a callback function which is called to notify the process of specific Berkeley DB events.</p> <p>The DbEnv::set_event_notify method configures operations performed using the specified <a href="../../db46-devel-4.6.21/api_cxx/env_class.html">DbEnv</a> handle, not all operations performed on the underlying database environment.</p> <p>The DbEnv::set_event_notify method may be called at any time during the life of the application.</p> <p>The DbEnv::set_event_notify method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. </p> <h3>Parameters</h3> <dl compact> <dt><b>db_event_fcn</b><dd>The <b>db_event_fcn</b> parameter is the application's event notification function. The function takes three parameters: <dl compact> <dt>dbenv<dd>The <b>dbenv</b> parameter is the enclosing database environment handle. <dt>event<dd>The <b>event</b> parameter is one of the following values: <dl compact> <dt><a name="DB_EVENT_PANIC">DB_EVENT_PANIC</a><dd>Errors can occur in the Berkeley DB library where the only solution is to shut down the application and run recovery (for example, if Berkeley DB is unable to allocate heap memory). In such cases, the Berkeley DB methods will either return <a href="../../db46-devel-4.6.21/ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a <a href="../../db46-devel-4.6.21/api_cxx/runrec_class.html">DbRunRecoveryException</a>, depending on the API configuration. It is often easier to simply exit the application when such errors occur rather than gracefully return up the stack. <p>When <b>event</b> is set to DB_EVENT_PANIC, the database environment has failed. All threads of control in the database environment should exit the environment, and recovery should be run.</p> <dt><a name="DB_EVENT_REP_CLIENT">DB_EVENT_REP_CLIENT</a><dd>The local site is now a replication client. <dt><a name="DB_EVENT_REP_ELECTED">DB_EVENT_REP_ELECTED</a><dd>The local replication site has just won an election. An application using the Base replication API should arrange for a call to the <a href="../../db46-devel-4.6.21/api_cxx/rep_start.html">DbEnv::rep_start</a> method after receiving this event, to reconfigure the local environment as a replication master. <p>Replication Manager applications may safely ignore this event. The Replication Manager calls <a href="../../db46-devel-4.6.21/api_cxx/rep_start.html">DbEnv::rep_start</a> automatically on behalf of the application when appropriate (resulting in firing of the DB_EVENT_REP_MASTER event).</p> <dt><a name="DB_EVENT_REP_MASTER">DB_EVENT_REP_MASTER</a><dd>The local site is now the master site of its replication group. It is the application's responsibility to begin acting as the master environment. <dt><a name="DB_EVENT_REP_NEWMASTER">DB_EVENT_REP_NEWMASTER</a><dd>The replication group of which this site is a member has just established a new master; the local site is not the new master. The <b>event_info</b> parameter points to an integer containing the environment ID of the new master. <dt><a name="DB_EVENT_REP_PERM_FAILED">DB_EVENT_REP_PERM_FAILED</a><dd>The replication manager did not receive enough acknowledgements (based on the acknowledgement policy configured with <a href="../../db46-devel-4.6.21/api_cxx/repmgr_ack_policy.html">DbEnv::repmgr_set_ack_policy</a>) to ensure a transaction's durability within the replication group. The transaction will be flushed to the master's local disk storage for durability. <p>The DB_EVENT_REP_PERM_FAILED event is provided only to applications configured for the replication manager.</p> <dt><a name="DB_EVENT_REP_STARTUPDONE">DB_EVENT_REP_STARTUPDONE</a><dd>The client has completed startup synchronization and is now processing live log records received from the master. <dt><a name="DB_EVENT_WRITE_FAILED">DB_EVENT_WRITE_FAILED</a><dd>A Berkeley DB write to stable storage failed. </dl> <dt>event_info<dd>The <b>event_info</b> parameter may reference memory which contains additional information describing an event. By default, <b>event_info</b> is NULL; specific events may pass non-NULL values, in which case the event will also describe the memory's structure. </dl> </dl> <p>Berkeley DB is not re-entrant. Callback functions should not attempt to make library calls (for example, to release locks or close open handles). Re-entering Berkeley DB is not guaranteed to work correctly, and the results are undefined.</p> <hr size=1 noshade> <h3>Class</h3> <a href="../../db46-devel-4.6.21/api_cxx/env_class.html">DbEnv</a> <h3>See Also</h3> <a href="../../db46-devel-4.6.21/api_cxx/env_list.html">Database Environments and Related Methods</a> </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../../db46-devel-4.6.21/api_cxx/api_core.html"><img src="../../db46-devel-4.6.21/images/api.gif" alt="API"></a><a href="../../db46-devel-4.6.21/ref/toc.html"><img src="../../db46-devel-4.6.21/images/ref.gif" alt="Ref"></a> </td></tr></table> <p><font size=1>Copyright (c) 1996,2007 Oracle. All rights reserved.</font> </body> </html>