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_set_transport()</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="repset_timeout.html" title="DB_ENV->rep_set_timeout()" /> 12 <link rel="next" href="repstart.html" title="DB_ENV->rep_start()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DB_ENV->rep_set_transport()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="repset_timeout.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 10. 23 Replication Methods 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="repstart.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="reptransport"></a>DB_ENV->rep_set_transport()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB_ENV->rep_set_transport(DB_ENV *env, int envid, 42 int (*send)(DB_ENV *dbenv, 43 const DBT *control, const DBT *rec, const DB_LSN *lsnp, 44 int envid, u_int32_t flags)); </pre> 45 <p> 46 The <code class="methodname">DB_ENV->rep_set_transport()</code> method initializes the communication 47 infrastructure for a database environment participating in a replicated application. 48 </p> 49 <p> 50 The <code class="methodname">DB_ENV->rep_set_transport()</code> method is not called by most 51 replication applications. It should only be called by Base API applications 52 implementing their own network transport layer, explicitly holding 53 replication group elections and handling replication messages outside 54 of the Replication Manager framework. 55 </p> 56 <p> 57 The <code class="methodname">DB_ENV->rep_set_transport()</code> method configures operations 58 performed using the specified <a class="link" href="env.html" title="Chapter 5. The DB_ENV Handle">DB_ENV</a> handle, 59 not all operations performed on the underlying database environment. 60 </p> 61 <p> 62 The <code class="methodname">DB_ENV->rep_set_transport()</code> method may be called at any time 63 during the life of the application. 64 </p> 65 <p> 66 The <code class="methodname">DB_ENV->rep_set_transport()</code> <span> 67 <span> 68 method returns a non-zero error value on failure and 0 on success. 69 </span> 70 71 </span> 72 </p> 73 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> 74 <h3 class="title">Note</h3> 75 <p> 76 Berkeley DB is not re-entrant. The callback function 77for this method should not attempt to make 78 library calls (for example, to release locks or close open handles). Re-entering 79 Berkeley DB is not guaranteed to work correctly, and the results are undefined. 80 </p> 81 </div> 82 <div class="sect2" lang="en" xml:lang="en"> 83 <div class="titlepage"> 84 <div> 85 <div> 86 <h3 class="title"><a id="id1699872"></a>Parameters</h3> 87 </div> 88 </div> 89 </div> 90 <div class="sect3" lang="en" xml:lang="en"> 91 <div class="titlepage"> 92 <div> 93 <div> 94 <h4 class="title"><a id="id1700182"></a>envid</h4> 95 </div> 96 </div> 97 </div> 98 <p> 99 The <span class="bold"><strong>envid</strong></span> parameter is the local 100 environment's ID. It must be a non-negative integer and uniquely identify 101 this Berkeley DB database environment (see 102 <a href="../../programmer_reference/rep_id.html" class="olink">Replication environment IDs</a> 103 for more information). 104 </p> 105 </div> 106 <div class="sect3" lang="en" xml:lang="en"> 107 <div class="titlepage"> 108 <div> 109 <div> 110 <h4 class="title"><a id="id1700185"></a>send</h4> 111 </div> 112 </div> 113 </div> 114 <p> 115 The <span class="bold"><strong>send</strong></span> callback function is used to 116 transmit data using the replication application's communication 117 infrastructure. The parameters to <span class="bold"><strong>send</strong></span> are as follows: 118 </p> 119 <div class="itemizedlist"> 120 <ul type="disc"> 121 <li> 122 <p> 123 <code class="literal">dbenv</code> 124 </p> 125 <p> 126 The <span class="bold"><strong>dbenv</strong></span> parameter is the enclosing 127 database environment handle. 128 </p> 129 </li> 130 <li> 131 <p> 132 <code class="literal">control</code> 133 </p> 134 <p> 135 The <span class="bold"><strong>control</strong></span> parameter is the first of 136 the two data elements to be transmitted by the <span class="bold"><strong>send</strong></span> function. 137 </p> 138 </li> 139 <li> 140 <p> 141 <code class="literal">rec</code> 142 </p> 143 <p> 144 The <span class="bold"><strong>rec</strong></span> parameter is the second of 145 the two data elements to be transmitted by the <span class="bold"><strong>send</strong></span> function. 146 </p> 147 </li> 148 <li> 149 <p> 150 <code class="literal">lsnp</code> 151 </p> 152 <p> 153 If the type of message to be sent has an LSN associated with it, then 154 the <span class="bold"><strong>lsnp</strong></span> parameter contains the LSN 155 of the record being sent. This LSN can be used to determine that 156 certain records have been processed successfully by clients. 157 </p> 158 </li> 159 <li> 160 <p> 161 <code class="literal">envid</code> 162 </p> 163 <p> 164 The <span class="bold"><strong>envid</strong></span> parameter is a positive 165 integer identifier that specifies the replication environment to which 166 the message should be sent (see <a href="../../programmer_reference/rep_id.html" class="olink">Replication environment IDs</a> for more 167 information). 168 </p> 169 <p><a id="transport_DB_EID_BROADCAST"></a> 170 The special identifier <code class="literal">DB_EID_BROADCAST</code> indicates that a message 171 should be broadcast to every environment in the replication group. The application 172 may use a true broadcast protocol or may send the message in sequence to each 173 machine with which it is in communication. In both cases, the sending site should 174 not be asked to process the message. 175 </p> 176 <p> 177 The special identifier 178 <a href="../../programmer_reference/rep_id.html#rep_id.DB_EID_INVALID" class="olink">DB_EID_INVALID</a> 179 indicates an invalid environment ID. This may be used to initialize 180 values that are subsequently checked for validity. 181 </p> 182 </li> 183 <li> 184 <p> 185 <code class="literal">flags</code> 186 </p> 187 <p> 188 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 189 or by bitwise inclusively <span class="bold"><strong>OR</strong></span>'ing 190 together one or more of the following values: 191 </p> 192 <div class="itemizedlist"> 193 <ul type="circle"> 194 <li> 195 <p><a id="transport_DB_REP_ANYWHERE"></a> 196 <code class="literal">DB_REP_ANYWHERE</code> 197 </p> 198 <p> 199 The message is a client request that can be satisfied by another 200 client as well as by the master. 201 </p> 202 </li> 203 <li> 204 <p><a id="transport_DB_REP_NOBUFFER"></a> 205 <code class="literal">DB_REP_NOBUFFER</code> 206 </p> 207 <p> 208 The record being sent should be transmitted immediately and not 209 buffered or delayed. 210 </p> 211 </li> 212 <li> 213 <p><a id="transport_DB_REP_PERMANENT"></a> 214 <code class="literal">DB_REP_PERMANENT</code> 215 </p> 216 <p> 217 The record being sent is critical for maintaining database integrity 218 (for example, the message includes a transaction commit). The 219 application should take appropriate action to enforce the reliability 220 guarantees it has chosen, such as waiting for acknowledgement from one 221 or more clients. 222 </p> 223 </li> 224 <li> 225 <p><a id="transport_DB_REP_REREQUEST"></a> 226 <code class="literal">DB_REP_REREQUEST</code> 227 </p> 228 <p> 229 The message is a client request that has already been made and to 230 which no response was received. 231 </p> 232 </li> 233 </ul> 234 </div> 235 </li> 236 </ul> 237 </div> 238 <p> 239 240 It may sometimes be useful to pass application-specific data to the send 241 function; see <a href="../../programmer_reference/env_faq.html" class="olink">Environment FAQ</a> 242 for a discussion on how to do this. 243 244 </p> 245 <p> 246 The <span class="bold"><strong>send</strong></span> function must return 0 on success and non-zero on failure. 247 If the send function fails, the message being sent is necessary to maintain database integrity, and 248 the local log is not configured for synchronous flushing, the local log will be flushed; otherwise, 249 any error from the <span class="bold"><strong>send</strong></span> function will be ignored. 250 </p> 251 </div> 252 </div> 253 <div class="sect2" lang="en" xml:lang="en"> 254 <div class="titlepage"> 255 <div> 256 <div> 257 <h3 class="title"><a id="id1700556"></a>Errors</h3> 258 </div> 259 </div> 260 </div> 261 <p> 262 The <code class="methodname">DB_ENV->rep_set_transport()</code> <span> 263 <span> 264 method may fail and return one of the following non-zero errors: 265 </span> 266 267 </span> 268 </p> 269 <div class="sect3" lang="en" xml:lang="en"> 270 <div class="titlepage"> 271 <div> 272 <div> 273 <h4 class="title"><a id="id1700302"></a>EINVAL</h4> 274 </div> 275 </div> 276 </div> 277 <p> 278 The method is called from a Replication Manager application; or an invalid flag value or 279 parameter was specified. 280 </p> 281 </div> 282 </div> 283 <div class="sect2" lang="en" xml:lang="en"> 284 <div class="titlepage"> 285 <div> 286 <div> 287 <h3 class="title"><a id="id1700529"></a>Class</h3> 288 </div> 289 </div> 290 </div> 291 <p> 292 <a class="link" href="env.html" title="Chapter 5. The DB_ENV Handle">DB_ENV</a> 293 </p> 294 </div> 295 <div class="sect2" lang="en" xml:lang="en"> 296 <div class="titlepage"> 297 <div> 298 <div> 299 <h3 class="title"><a id="id1700156"></a>See Also</h3> 300 </div> 301 </div> 302 </div> 303 <p> 304 <a class="xref" href="rep.html#replist" title="Replication and Related Methods">Replication and Related Methods</a> 305 </p> 306 </div> 307 </div> 308 <div class="navfooter"> 309 <hr /> 310 <table width="100%" summary="Navigation footer"> 311 <tr> 312 <td width="40%" align="left"><a accesskey="p" href="repset_timeout.html">Prev</a> </td> 313 <td width="20%" align="center"> 314 <a accesskey="u" href="rep.html">Up</a> 315 </td> 316 <td width="40%" align="right"> <a accesskey="n" href="repstart.html">Next</a></td> 317 </tr> 318 <tr> 319 <td width="40%" align="left" valign="top">DB_ENV->rep_set_timeout() </td> 320 <td width="20%" align="center"> 321 <a accesskey="h" href="index.html">Home</a> 322 </td> 323 <td width="40%" align="right" valign="top"> DB_ENV->rep_start()</td> 324 </tr> 325 </table> 326 </div> 327 </body> 328</html> 329