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: DB_ENV-&gt;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>DB_ENV-&gt;set_event_notify</b>
14</td>
15<td align=right>
16<a href="/api_c/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 &lt;db.h&gt;
23<p>
24int
25DB_ENV-&gt;set_event_notify(DB_ENV *dbenv,
26    void (*db_event_fcn)(DB_ENV *dbenv, u_int32_t event, void *event_info));
27</pre></b>
28<hr size=1 noshade>
29<b>Description: DB_ENV-&gt;set_event_notify</b>
30<p>The DB_ENV-&gt;set_event_notify method configures a callback function which
31is called to notify the process of specific Berkeley DB events.</p>
32<p>The DB_ENV-&gt;set_event_notify method configures operations performed using the specified
33<a href="/api_c/env_class.html">DB_ENV</a> handle, not all operations performed on the underlying
34database environment.</p>
35<p>The DB_ENV-&gt;set_event_notify method may be called at any time during the life of the
36application.</p>
37<p>The DB_ENV-&gt;set_event_notify method
38returns a non-zero error value on failure
39and 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
51return <a href="/ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>.
52It is often easier to simply exit the application when such errors occur
53rather than gracefully return up the stack.
54<p>When <b>event</b> is set to DB_EVENT_PANIC, the database
55environment has failed.  All threads of control in the database
56environment should exit the environment, and recovery should be run.</p></ul>
57<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>
58<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
59the Base replication API should arrange for a call to the <a href="/api_c/rep_start.html">DB_ENV-&gt;rep_start</a> method
60after receiving this event, to reconfigure the local environment as a
61replication master.</ul>
62<p>Replication Manager applications may safely ignore this event.  The
63Replication Manager calls <a href="/api_c/rep_start.html">DB_ENV-&gt;rep_start</a> automatically on behalf of
64the application when appropriate (resulting in firing of the
65DB_EVENT_REP_MASTER event).</p>
66<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
67the application's responsibility to begin acting as the master environment.</ul>
68<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
69new master; the local site is not the new master.  The
70<b>event_info</b> parameter points to an integer containing the
71environment ID of the new master.</ul>
72<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
73the acknowledgement policy configured with <a href="/api_c/repmgr_ack_policy.html">DB_ENV-&gt;repmgr_set_ack_policy</a>)
74to ensure a transaction's durability within the replication group.  The
75transaction will be flushed to the master's local disk storage for
76durability.</ul>
77<p>The DB_EVENT_REP_PERM_FAILED event is provided only to applications
78configured for the replication manager.</p>
79<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
80live log records received from the master.</ul>
81<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>
82<br>
83<b>event_info</b><ul compact><li>The <b>event_info</b> parameter may reference memory which contains
84additional information describing an event.  By default,
85<b>event_info</b> is NULL; specific events may pass non-NULL values,
86in which case the event will also describe the memory's structure.</ul>
87<br></ul>
88<br>
89<p>Berkeley DB is not re-entrant.  Callback functions should not attempt to make
90library calls (for example, to release locks or close open handles).
91Re-entering Berkeley DB is not guaranteed to work correctly, and the results
92are undefined.</p>
93<hr size=1 noshade>
94<br><b>Class</b>
95<a href="/api_c/env_class.html">DB_ENV</a>
96<br><b>See Also</b>
97<a href="/api_c/env_list.html">Database Environments and Related Methods</a>
98</tt>
99<table width="100%"><tr><td><br></td><td align=right>
100<a href="/api_c/api_core.html"><img src="/images/api.gif" alt="API"></a><a href="/ref/toc.html"><img src="/images/ref.gif" alt="Ref"></a>
101</td></tr></table>
102<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
103</body>
104</html>
105