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>The Replication APIs</title> 7 <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Getting Started with Replicated Berkeley DB Applications" /> 10 <link rel="up" href="introduction.html" title="Chapter��1.��Introduction" /> 11 <link rel="prev" href="repadvantage.html" title="Replication Benefits" /> 12 <link rel="next" href="elections.html" title="Holding Elections" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">The Replication APIs</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="repadvantage.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��1.��Introduction</th> 23 <td width="20%" align="right">��<a accesskey="n" href="elections.html">Next</a></td> 24 </tr> 25 </table> 26 <hr /> 27 </div> 28 <div class="sect1" lang="en" xml:lang="en"> 29 <div class="titlepage"> 30 <div> 31 <div> 32 <h2 class="title" style="clear: both"><a id="apioverview"></a>The Replication APIs</h2> 33 </div> 34 </div> 35 </div> 36 <div class="toc"> 37 <dl> 38 <dt> 39 <span class="sect2"> 40 <a href="apioverview.html#repframeworkoverview">Replication Manager Overview</a> 41 </span> 42 </dt> 43 <dt> 44 <span class="sect2"> 45 <a href="apioverview.html#repapioverview">Replication Base API Overview</a> 46 </span> 47 </dt> 48 </dl> 49 </div> 50 <p> 51 There are two ways that you can choose to implement 52 replication in your transactional application. The first, 53 and preferred, mechanism is to use the pre-packaged 54 Replication Manager that comes with the 55 DB distribution. This framework should be sufficient 56 for most customers. 57 </p> 58 <p> 59 If for some reason the Replication Manager 60 does not meet your application's technical requirements, 61 you will have to use the Replication Base APIs available 62 through the Berkeley DB library to write your own custom 63 replication framework. 64 </p> 65 <p> 66 Both of these approaches are described in slightly greater 67 detail in this section. The bulk of the chapters later in 68 this book are dedicated to these two replication 69 implementation mechanisms. 70 </p> 71 <div class="sect2" lang="en" xml:lang="en"> 72 <div class="titlepage"> 73 <div> 74 <div> 75 <h3 class="title"><a id="repframeworkoverview"></a>Replication Manager Overview</h3> 76 </div> 77 </div> 78 </div> 79 <p> 80 DB's pre-packaged Replication Manager exists 81 as a layer on top of the DB library. The Replication Manager is a 82 multi-threaded implementation that allows you to easily add 83 replication to your existing transactional application. 84 <span> 85 You access and manage the Replication Manager using methods that are 86 available off the 87 88 <code class="classname">DbEnv</code> 89 class. 90 </span> 91 92 </p> 93 <p> 94 The Replication Manager: 95 </p> 96 <div class="itemizedlist"> 97 <ul type="disc"> 98 <li> 99 <p> 100 Provides a multi-threaded communications layer 101 using pthreads (on Unix-style systems and 102 similar derivatives such as Mac OS X), or 103 Windows threads on Microsoft Windows systems. 104 </p> 105 </li> 106 <li> 107 <p> 108 Uses TCP/IP sockets. Network traffic is 109 handled via threads that handle inbound and 110 outbound messages. However, each 111 process uses a single socket 112 that is shared using <code class="function">select()</code>. 113 </p> 114 <p> 115 Note that for this reason, the Replication Manager is 116 limited to a maximum of 60 replicas (on 117 Windows) and approximately 1000 replicas (on 118 Unix and related systems), depending on how 119 your system is configured. 120 </p> 121 </li> 122 <li> 123 <p> 124 Requires that only one instance of the 125 environment handle be used. 126 </p> 127 </li> 128 <li> 129 <p> 130 Upon application startup, a master can be 131 selected either manually or via elections. 132 After startup time, however, during the course of 133 normal operations it is possible for the 134 replication group to need to locate a new master (due 135 to network or other hardware related problems, 136 for example) and in this scenario elections are 137 always used to select the new master. 138 </p> 139 </li> 140 </ul> 141 </div> 142 <p> 143 If your application has technical requirements that do 144 not conform to the implementation provided by the 145 Replication Manager, you must write implement replication 146 using the DB Replication Base APIs. See 147 the next section for introductory details. 148 </p> 149 </div> 150 <div class="sect2" lang="en" xml:lang="en"> 151 <div class="titlepage"> 152 <div> 153 <div> 154 <h3 class="title"><a id="repapioverview"></a>Replication Base API Overview</h3> 155 </div> 156 </div> 157 </div> 158 <p> 159 The Replication Base API is a series of Berkeley DB library 160 classes and methods that you can use to build your own 161 replication infrastructure. You should use the 162 Base API only if the Replication Manager does not meet your 163 application's technical requirements. 164 </p> 165 <p> 166 To make use of the Base API, you must write your 167 own networking code. This frees you from the technical 168 constraints imposed by the Replication Manager. For example, by 169 writing your own framework, you can: 170 </p> 171 <div class="itemizedlist"> 172 <ul type="disc"> 173 <li> 174 <p> 175 Use a threading package other than 176 pthreads (Unix) or Windows threads 177 (Microsoft Windows). This might be interesting 178 to you if you are using a platform 179 whose preferred threading package 180 is something other than (for 181 example) pthreads, such as is the case for 182 Sun Microsystem's Solaris operating systems. 183 </p> 184 </li> 185 <li> 186 <p> 187 Implement your own sockets. The 188 Replication Manager uses TCP/IP sockets. While 189 this should be acceptable for the 190 majority of applications, sometimes 191 UDP or even raw sockets might be 192 desired. 193 </p> 194 </li> 195 </ul> 196 </div> 197 <p> 198 For information on writing a replicated application 199 using the Berkeley DB Replication Base APIs, see the 200 <em class="citetitle">Berkeley DB Programmer's Reference Guide</em>. 201 </p> 202 </div> 203 </div> 204 <div class="navfooter"> 205 <hr /> 206 <table width="100%" summary="Navigation footer"> 207 <tr> 208 <td width="40%" align="left"><a accesskey="p" href="repadvantage.html">Prev</a>��</td> 209 <td width="20%" align="center"> 210 <a accesskey="u" href="introduction.html">Up</a> 211 </td> 212 <td width="40%" align="right">��<a accesskey="n" href="elections.html">Next</a></td> 213 </tr> 214 <tr> 215 <td width="40%" align="left" valign="top">Replication Benefits��</td> 216 <td width="20%" align="center"> 217 <a accesskey="h" href="index.html">Home</a> 218 </td> 219 <td width="40%" align="right" valign="top">��Holding Elections</td> 220 </tr> 221 </table> 222 </div> 223 </body> 224</html> 225