1<!--$Id: env_event_notify.so,v 10.13 2007/04/05 20:37:29 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: DbEnv::set_event_notify</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>DbEnv::set_event_notify</b> 14</td> 15<td align=right> 16<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a> 17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db_cxx.h> 23<p> 24int 25DbEnv::set_event_notify(void (*db_event_fcn)(DB_ENV *dbenv, u_int32_t event, void *event_info)); 26</pre></b> 27<hr size=1 noshade> 28<b>Description: DbEnv::set_event_notify</b> 29<p>The DbEnv::set_event_notify method configures a callback function which 30is called to notify the process of specific Berkeley DB events.</p> 31<p>The DbEnv::set_event_notify method configures operations performed using the specified 32<a href="../api_cxx/env_class.html">DbEnv</a> handle, not all operations performed on the underlying 33database environment.</p> 34<p>The DbEnv::set_event_notify method may be called at any time during the life of the 35application.</p> 36<p>The DbEnv::set_event_notify method 37either returns a non-zero error value 38or throws an exception that encapsulates a non-zero error value on 39failure, and returns 0 on success. 40</p> 41<b>Parameters</b> <br> 42 <b>db_event_fcn</b><ul compact><li>The <b>db_event_fcn</b> parameter is the application's event 43notification function. The function takes three parameters: 44<br> 45<b>dbenv</b><ul compact><li>The <b>dbenv</b> parameter is the enclosing database environment handle.</ul> 46<b>event</b><ul compact><li>The <b>event</b> parameter is one of the following values:</ul> 47<br> 48<b><a name="DB_EVENT_PANIC">DB_EVENT_PANIC</a></b><ul compact><li>Errors can occur in the Berkeley DB library where the only solution is to shut 49down the application and run recovery (for example, if Berkeley DB is unable 50to allocate heap memory). In such cases, the Berkeley DB methods will 51either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a <a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, 52depending on the API configuration. 53It is often easier to simply exit the application when such errors occur 54rather than gracefully return up the stack. 55<p>When <b>event</b> is set to DB_EVENT_PANIC, the database 56environment has failed. All threads of control in the database 57environment should exit the environment, and recovery should be run.</p></ul> 58<b><a name="DB_EVENT_REP_CLIENT">DB_EVENT_REP_CLIENT</a></b><ul compact><li>The local site is now a replication client.</ul> 59<b><a name="DB_EVENT_REP_ELECTED">DB_EVENT_REP_ELECTED</a></b><ul compact><li>The local replication site has just won an election. An application using 60the Base replication API should arrange for a call to the <a href="../api_cxx/rep_start.html">DbEnv::rep_start</a> method 61after receiving this event, to reconfigure the local environment as a 62replication master.</ul> 63<p>Replication Manager applications may safely ignore this event. The 64Replication Manager calls <a href="../api_cxx/rep_start.html">DbEnv::rep_start</a> automatically on behalf of 65the application when appropriate (resulting in firing of the 66DB_EVENT_REP_MASTER event).</p> 67<b><a name="DB_EVENT_REP_MASTER">DB_EVENT_REP_MASTER</a></b><ul compact><li>The local site is now the master site of its replication group. It is 68the application's responsibility to begin acting as the master environment.</ul> 69<b><a name="DB_EVENT_REP_NEWMASTER">DB_EVENT_REP_NEWMASTER</a></b><ul compact><li>The replication group of which this site is a member has just established a 70new master; the local site is not the new master. The 71<b>event_info</b> parameter points to an integer containing the 72environment ID of the new master.</ul> 73<b><a name="DB_EVENT_REP_PERM_FAILED">DB_EVENT_REP_PERM_FAILED</a></b><ul compact><li>The replication manager did not receive enough acknowledgements (based on 74the acknowledgement policy configured with <a href="../api_cxx/repmgr_ack_policy.html">DbEnv::repmgr_set_ack_policy</a>) 75to ensure a transaction's durability within the replication group. The 76transaction will be flushed to the master's local disk storage for 77durability.</ul> 78<p>The DB_EVENT_REP_PERM_FAILED event is provided only to applications 79configured for the replication manager.</p> 80<b><a name="DB_EVENT_REP_STARTUPDONE">DB_EVENT_REP_STARTUPDONE</a></b><ul compact><li>The client has completed startup synchronization and is now processing 81live log records received from the master.</ul> 82<b><a name="DB_EVENT_WRITE_FAILED">DB_EVENT_WRITE_FAILED</a></b><ul compact><li>A Berkeley DB write to stable storage failed.</ul> 83<br> 84<b>event_info</b><ul compact><li>The <b>event_info</b> parameter may reference memory which contains 85additional information describing an event. By default, 86<b>event_info</b> is NULL; specific events may pass non-NULL values, 87in which case the event will also describe the memory's structure.</ul> 88<br></ul> 89<br> 90<p>Berkeley DB is not re-entrant. Callback functions should not attempt to make 91library calls (for example, to release locks or close open handles). 92Re-entering Berkeley DB is not guaranteed to work correctly, and the results 93are undefined.</p> 94<hr size=1 noshade> 95<br><b>Class</b> 96<a href="../api_cxx/env_class.html">DbEnv</a> 97<br><b>See Also</b> 98<a href="../api_cxx/env_list.html">Database Environments and Related Methods</a> 99</tt> 100<table width="100%"><tr><td><br></td><td align=right> 101<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 102</td></tr></table> 103<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 104</body> 105</html> 106