| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>DB_ENV->rep_process_message()</title> |
| 7 | <link rel="stylesheet" href="apiReference.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB C API Reference" /> |
| 10 | <link rel="up" href="rep.html" title="Chapter 10. Replication Methods" /> |
| 11 | <link rel="prev" href="repget_timeout.html" title="DB_ENV->rep_get_timeout()" /> |
| 12 | <link rel="next" href="repclockskew.html" title="DB_ENV->rep_set_clockskew()" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">DB_ENV->rep_process_message()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="repget_timeout.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 10. |
| 26 | Replication Methods |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="repclockskew.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="repmessage"></a>DB_ENV->rep_process_message()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db.h> |
| 42 | |
| 43 | int |
| 44 | DB_ENV->rep_process_message(DB_ENV *env, |
| 45 | DBT *control, DBT *rec, int envid, DB_LSN *ret_lsnp) </pre> |
| 46 | <p> |
| 47 | The <code class="methodname">DB_ENV->rep_process_message()</code> method processes an incoming |
| 48 | replication message sent by a member of the replication group to the |
| 49 | local database environment. |
| 50 | </p> |
| 51 | <p> |
| 52 | The <code class="methodname">DB_ENV->rep_process_message()</code> method is not called by most |
| 53 | replication applications. It should only be called by Base API applications |
| 54 | implementing their own network transport layer, explicitly holding |
| 55 | replication group elections and handling replication messages outside |
| 56 | of the Replication Manager framework. |
| 57 | </p> |
| 58 | <p> |
| 59 | For implementation reasons, all incoming replication messages must be |
| 60 | processed using the same <a class="link" href="env.html" title="Chapter 5. The DB_ENV Handle">DB_ENV</a> handle. It is not |
| 61 | required that a single thread of control process all messages, only |
| 62 | that all threads of control processing messages use the same handle. |
| 63 | </p> |
| 64 | <p> |
| 65 | Before calling this method, the enclosing database environment must |
| 66 | already have been opened by calling the |
| 67 | <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> method and must |
| 68 | already have been configured to send replication messages by |
| 69 | calling the <a class="xref" href="reptransport.html" title="DB_ENV->rep_set_transport()">DB_ENV->rep_set_transport()</a> |
| 70 | method. |
| 71 | </p> |
| 72 | <p> |
| 73 | The <code class="methodname">DB_ENV->rep_process_message()</code> method has additional return |
| 74 | values: |
| 75 | </p> |
| 76 | <div class="itemizedlist"> |
| 77 | <ul type="disc"> |
| 78 | <li> |
| 79 | <p><a id="repmsg_DB_REP_DUPMASTER"></a> |
| 80 | <span class="bold"><strong>DB_REP_DUPMASTER</strong></span> |
| 81 | </p> |
| 82 | <p> |
| 83 | The <code class="methodname">DB_ENV->rep_process_message()</code> method will return |
| 84 | <code class="literal">DB_REP_DUPMASTER</code> if the replication group has more than one |
| 85 | master. The application should reconfigure itself as a client by calling the |
| 86 | <a class="xref" href="repstart.html" title="DB_ENV->rep_start()">DB_ENV->rep_start()</a> method, and then call for an |
| 87 | election by calling <a class="xref" href="repelect.html" title="DB_ENV->rep_elect()">DB_ENV->rep_elect()</a>. |
| 88 | </p> |
| 89 | </li> |
| 90 | <li> |
| 91 | <p><a id="repmsg_DB_REP_HOLDELECTION"></a> |
| 92 | <span class="bold"><strong>DB_REP_HOLDELECTION</strong></span> |
| 93 | </p> |
| 94 | <p> |
| 95 | The <code class="methodname">DB_ENV->rep_process_message()</code> method will return |
| 96 | <code class="literal">DB_REP_HOLDELECTION</code> if an election is needed. The application |
| 97 | should call for an election by calling |
| 98 | <a class="xref" href="repelect.html" title="DB_ENV->rep_elect()">DB_ENV->rep_elect()</a>. |
| 99 | </p> |
| 100 | </li> |
| 101 | <li> |
| 102 | <p><a id="repmsg_DB_REP_IGNORE"></a> |
| 103 | <span class="bold"><strong>DB_REP_IGNORE</strong></span> |
| 104 | </p> |
| 105 | <p> |
| 106 | The <code class="methodname">DB_ENV->rep_process_message()</code> method will return |
| 107 | <code class="literal">DB_REP_IGNORE</code> if this message cannot be processed. This is an |
| 108 | indication that this message is irrelevant to the current replication state (for |
| 109 | example, an old message from a previous generation arrives and is processed late). |
| 110 | </p> |
| 111 | </li> |
| 112 | <li> |
| 113 | <p><a id="repmsg_DB_REP_ISPERM"></a> |
| 114 | <span class="bold"><strong>DB_REP_ISPERM</strong></span> |
| 115 | </p> |
| 116 | <p> |
| 117 | The <code class="methodname">DB_ENV->rep_process_message()</code> method will return |
| 118 | <code class="literal">DB_REP_ISPERM</code> if processing this message results in the |
| 119 | processing of records that are permanent. The maximum LSN of the permanent records |
| 120 | stored is returned. |
| 121 | </p> |
| 122 | </li> |
| 123 | <li> |
| 124 | <p><a id="repmsg_DB_REP_JOIN_FAILURE"></a> |
| 125 | <span class="bold"><strong>DB_REP_JOIN_FAILURE</strong></span> |
| 126 | </p> |
| 127 | <p> |
| 128 | The <code class="methodname">DB_ENV->rep_process_message()</code> method will return |
| 129 | <code class="literal">DB_REP_JOIN_FAILURE</code> if a new master has been chosen but the |
| 130 | client is unable to synchronize with the new master. This is possibly because the client |
| 131 | has turned off automatic internal initialization by setting the |
| 132 | <a class="link" href="repconfig.html#config_DB_REP_CONF_AUTOINIT">DB_REP_CONF_AUTOINIT</a> |
| 133 | flag to <code class="literal">0</code>. |
| 134 | </p> |
| 135 | </li> |
| 136 | <li> |
| 137 | <p><a id="repmsg_DB_REP_NEWSITE"></a> |
| 138 | <span class="bold"><strong>DB_REP_NEWSITE</strong></span> |
| 139 | </p> |
| 140 | <p> |
| 141 | The <code class="methodname">DB_ENV->rep_process_message()</code> method will return |
| 142 | <code class="literal">DB_REP_NEWSITE</code> if the system received contact information from a |
| 143 | new environment. The <span class="bold"><strong>rec</strong></span> parameter contains the |
| 144 | opaque data specified to the <a class="xref" href="repstart.html" title="DB_ENV->rep_start()">DB_ENV->rep_start()</a> |
| 145 | <span class="bold"><strong>cdata</strong></span> parameter. The application should |
| 146 | take whatever action is needed to establish a communication channel with this new |
| 147 | environment. |
| 148 | </p> |
| 149 | </li> |
| 150 | <li> |
| 151 | <p><a id="repmsg_DB_REP_NOTPERM"></a> |
| 152 | <span class="bold"><strong>DB_REP_NOTPERM</strong></span> |
| 153 | </p> |
| 154 | <p> |
| 155 | The <code class="methodname">DB_ENV->rep_process_message()</code> method will return |
| 156 | <code class="literal">DB_REP_NOTPERM</code> if a message carrying a |
| 157 | <a class="link" href="reptransport.html#transport_DB_REP_PERMANENT">DB_REP_PERMANENT</a> |
| 158 | flag was processed successfully, but was not written to disk. The LSN of this |
| 159 | record is returned. The application should take whatever action is deemed |
| 160 | necessary to retain its recoverability characteristics. |
| 161 | </p> |
| 162 | </li> |
| 163 | </ul> |
| 164 | </div> |
| 165 | <p> |
| 166 | Unless otherwise specified, the <code class="methodname">DB_ENV->rep_process_message()</code> |
| 167 | <span> |
| 168 | <span> |
| 169 | method returns a non-zero error value on failure and 0 on success. |
| 170 | </span> |
| 171 | |
| 172 | </span> |
| 173 | </p> |
| 174 | <div class="sect2" lang="en" xml:lang="en"> |
| 175 | <div class="titlepage"> |
| 176 | <div> |
| 177 | <div> |
| 178 | <h3 class="title"><a id="idp54061176"></a>Parameters</h3> |
| 179 | </div> |
| 180 | </div> |
| 181 | </div> |
| 182 | <div class="sect3" lang="en" xml:lang="en"> |
| 183 | <div class="titlepage"> |
| 184 | <div> |
| 185 | <div> |
| 186 | <h4 class="title"><a id="idp54060272"></a>control</h4> |
| 187 | </div> |
| 188 | </div> |
| 189 | </div> |
| 190 | <p> |
| 191 | The <span class="bold"><strong>control</strong></span> parameter should |
| 192 | reference a copy of the <span class="bold"><strong>control</strong></span> |
| 193 | parameter specified by Berkeley DB on the sending environment. |
| 194 | See the <a class="xref" href="reptransport.html" title="DB_ENV->rep_set_transport()">DB_ENV->rep_set_transport()</a> method for more information. |
| 195 | </p> |
| 196 | </div> |
| 197 | <div class="sect3" lang="en" xml:lang="en"> |
| 198 | <div class="titlepage"> |
| 199 | <div> |
| 200 | <div> |
| 201 | <h4 class="title"><a id="idp54068096"></a>rec</h4> |
| 202 | </div> |
| 203 | </div> |
| 204 | </div> |
| 205 | <p> |
| 206 | The <span class="bold"><strong>rec</strong></span> parameter should reference a |
| 207 | copy of the <span class="bold"><strong>rec</strong></span> parameter specified |
| 208 | by Berkeley DB on the sending environment. |
| 209 | See the <a class="xref" href="reptransport.html" title="DB_ENV->rep_set_transport()">DB_ENV->rep_set_transport()</a> method for more information. |
| 210 | </p> |
| 211 | </div> |
| 212 | <div class="sect3" lang="en" xml:lang="en"> |
| 213 | <div class="titlepage"> |
| 214 | <div> |
| 215 | <div> |
| 216 | <h4 class="title"><a id="idp54069544"></a>envid</h4> |
| 217 | </div> |
| 218 | </div> |
| 219 | </div> |
| 220 | <p> |
| 221 | The <span class="bold"><strong>envid</strong></span> parameter should contain |
| 222 | the local identifier that corresponds to the environment that sent the |
| 223 | message to be processed (see <a href="../../programmer_reference/rep_id.html" class="olink">Replication environment IDs</a> for more |
| 224 | information). |
| 225 | </p> |
| 226 | </div> |
| 227 | <div class="sect3" lang="en" xml:lang="en"> |
| 228 | <div class="titlepage"> |
| 229 | <div> |
| 230 | <div> |
| 231 | <h4 class="title"><a id="idp54072224"></a>ret_lsnp</h4> |
| 232 | </div> |
| 233 | </div> |
| 234 | </div> |
| 235 | <p> |
| 236 | If <code class="methodname">DB_ENV->rep_process_message()</code> method returns |
| 237 | <code class="literal">DB_REP_NOTPERM</code> then the |
| 238 | <span class="bold"><strong>ret_lsnp</strong></span> parameter will contain the log sequence |
| 239 | number of this permanent log message that could not be written to disk. If |
| 240 | <code class="methodname">DB_ENV->rep_process_message()</code> method returns |
| 241 | <code class="literal">DB_REP_ISPERM</code> then the |
| 242 | <span class="bold"><strong>ret_lsnp</strong></span> parameter will contain largest log |
| 243 | sequence number of the permanent records that are now written to disk as a |
| 244 | result of processing this message. In all other cases the value of |
| 245 | <span class="bold"><strong>ret_lsnp</strong></span> is undefined. |
| 246 | |
| 247 | </p> |
| 248 | </div> |
| 249 | </div> |
| 250 | <div class="sect2" lang="en" xml:lang="en"> |
| 251 | <div class="titlepage"> |
| 252 | <div> |
| 253 | <div> |
| 254 | <h3 class="title"><a id="idp54056240"></a>Errors</h3> |
| 255 | </div> |
| 256 | </div> |
| 257 | </div> |
| 258 | <p> |
| 259 | The <code class="methodname">DB_ENV->rep_process_message()</code> |
| 260 | <span> |
| 261 | <span> |
| 262 | method may fail and return one of the following non-zero errors: |
| 263 | </span> |
| 264 | |
| 265 | </span> |
| 266 | </p> |
| 267 | <div class="sect3" lang="en" xml:lang="en"> |
| 268 | <div class="titlepage"> |
| 269 | <div> |
| 270 | <div> |
| 271 | <h4 class="title"><a id="idp54077968"></a>EINVAL</h4> |
| 272 | </div> |
| 273 | </div> |
| 274 | </div> |
| 275 | <p> |
| 276 | If the database environment was not already configured to |
| 277 | communicate with a replication group by a call to |
| 278 | <a class="xref" href="reptransport.html" title="DB_ENV->rep_set_transport()">DB_ENV->rep_set_transport()</a>; |
| 279 | if the database environment was not already opened; |
| 280 | if this method is called from a Replication Manager |
| 281 | application; or if an invalid flag value or parameter |
| 282 | was specified. |
| 283 | </p> |
| 284 | </div> |
| 285 | </div> |
| 286 | <div class="sect2" lang="en" xml:lang="en"> |
| 287 | <div class="titlepage"> |
| 288 | <div> |
| 289 | <div> |
| 290 | <h3 class="title"><a id="idp54078824"></a>Class</h3> |
| 291 | </div> |
| 292 | </div> |
| 293 | </div> |
| 294 | <p> |
| 295 | <a class="link" href="env.html" title="Chapter 5. The DB_ENV Handle">DB_ENV</a> |
| 296 | </p> |
| 297 | </div> |
| 298 | <div class="sect2" lang="en" xml:lang="en"> |
| 299 | <div class="titlepage"> |
| 300 | <div> |
| 301 | <div> |
| 302 | <h3 class="title"><a id="idp54080656"></a>See Also</h3> |
| 303 | </div> |
| 304 | </div> |
| 305 | </div> |
| 306 | <p> |
| 307 | <a class="xref" href="rep.html#replist" title="Replication and Related Methods">Replication and Related Methods</a> |
| 308 | </p> |
| 309 | </div> |
| 310 | </div> |
| 311 | <div class="navfooter"> |
| 312 | <hr /> |
| 313 | <table width="100%" summary="Navigation footer"> |
| 314 | <tr> |
| 315 | <td width="40%" align="left"><a accesskey="p" href="repget_timeout.html">Prev</a> </td> |
| 316 | <td width="20%" align="center"> |
| 317 | <a accesskey="u" href="rep.html">Up</a> |
| 318 | </td> |
| 319 | <td width="40%" align="right"> <a accesskey="n" href="repclockskew.html">Next</a></td> |
| 320 | </tr> |
| 321 | <tr> |
| 322 | <td width="40%" align="left" valign="top">DB_ENV->rep_get_timeout() </td> |
| 323 | <td width="20%" align="center"> |
| 324 | <a accesskey="h" href="index.html">Home</a> |
| 325 | </td> |
| 326 | <td width="40%" align="right" valign="top"> DB_ENV->rep_set_clockskew()</td> |
| 327 | </tr> |
| 328 | </table> |
| 329 | </div> |
| 330 | </body> |
| 331 | </html> |