• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src/router/db-4.8.30/docs/api_reference/CXX/
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>DbEnv::repmgr_start()</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 11.  Replication Methods" />
11    <link rel="prev" href="repmgrsite_list.html" title="DbEnv::repmgr_site_list()" />
12    <link rel="next" href="repmgrstat.html" title="DbEnv::repmgr_stat()" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">DbEnv::repmgr_start()</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="repmgrsite_list.html">Prev</a> </td>
22          <th width="60%" align="center">Chapter 11. 
23                Replication Methods
24        </th>
25          <td width="20%" align="right"> <a accesskey="n" href="repmgrstat.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="repmgrstart"></a>DbEnv::repmgr_start()</h2>
35          </div>
36        </div>
37      </div>
38      <pre class="programlisting">#include &lt;db_cxx.h&gt;
39 
40int
41DbEnv::repmgr_start(int nthreads, u_int32_t flags);</pre>
42      <p>
43         The <code class="methodname">DbEnv::repmgr_start()</code> method starts the Replication Manager.
44    </p>
45      <p>
46         There are two ways to build Berkeley DB replication applications: the
47         most common approach is to use the Berkeley DB library Replication
48         Manager, where the Berkeley DB library manages the
49         replication group, including network transport, all replication
50         message processing and acknowledgment, and group elections. 
51         Applications using the Replication Manager generally make the
52         following calls:
53    </p>
54      <div class="orderedlist">
55        <ol type="1">
56          <li>
57            <p>
58                    Call 
59                    <a class="xref" href="repmgrlocal_site.html" title="DbEnv::repmgr_set_local_site()">DbEnv::repmgr_set_local_site()</a>
60                    to configure the local site in the replication group.     
61                </p>
62          </li>
63          <li>
64            <p>
65                        Call
66                        <a class="xref" href="repmgrremote_site.html" title="DbEnv::repmgr_add_remote_site()">DbEnv::repmgr_add_remote_site()</a>
67                        to configure the remote site(s) in the replication group.     
68                </p>
69          </li>
70          <li>
71            <p>
72                        Call
73                        <a class="xref" href="repmgrset_ack_policy.html" title="DbEnv::repmgr_set_ack_policy()">DbEnv::repmgr_set_ack_policy()</a>
74                        to configure the message acknowledgment policy which best supports the
75                        replication group's transactional needs.
76                </p>
77          </li>
78          <li>
79            <p>
80                    Call 
81                    <a class="xref" href="reppriority.html" title="DbEnv::rep_set_priority()">DbEnv::rep_set_priority()</a>
82                    to configure the local site's election priority.
83                </p>
84          </li>
85          <li>
86            <p>
87                    Call <code class="methodname">DbEnv::repmgr_start()</code> to start the replication application.
88                </p>
89          </li>
90        </ol>
91      </div>
92      <p>
93            For more information on building Replication Manager applications,
94            please see the <em class="citetitle">Replication Getting Started Guide</em> 
95            included in the Berkeley DB documentation.
96         </p>
97      <p>
98         Applications with special needs (for example, applications using
99         network protocols not supported by the Berkeley DB Replication
100         Manager), must perform additional configuration and call other
101         Berkeley DB replication Base API methods.  For more information on building
102         Base API applications, please see the 
103         <a href="../../programmer_reference/rep_base_meth.html" class="olink">Base API Methods</a> section in the 
104         <em class="citetitle">Berkeley DB Programmer's Reference Guide</em>.
105    </p>
106      <p>
107        Starting the Replication Manager consists of opening the TCP/IP listening socket to accept
108        incoming connections, and starting all necessary background threads. When multiple processes
109        share a database environment, only one process can open the listening socket; the
110        <code class="methodname">DbEnv::repmgr_start()</code> method automatically opens the socket in the
111        first process to call it, and skips this step in the later calls from other processes.
112    </p>
113      <p>
114         The <code class="methodname">DbEnv::repmgr_start()</code> method 
115         may not be called before the <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a>  method is 
116         called to open the local environment and the
117<a class="xref" href="repmgrlocal_site.html" title="DbEnv::repmgr_set_local_site()">DbEnv::repmgr_set_local_site()</a> 
118 method is called to configure the local site.
119In addition, the local environment must be opened with the 
120 <a class="link" href="envopen.html#envopen_DB_THREAD">DB_THREAD</a>
121flag set.
122    </p>
123      <p>
124         The <code class="methodname">DbEnv::repmgr_start()</code> method will return 
125         <code class="literal">DB_REP_IGNORE</code>
126         as an informational, non-error return code, if another process has previously become the
127         TCP/IP listener (though the current call has nevertheless successfully started Replication
128         Manager's background threads). Unless otherwise specified, the
129         <code class="methodname">DbEnv::repmgr_start()</code> <span>
130            
131            <span>
132                method either returns a non-zero error value or throws an
133                exception that encapsulates a non-zero error value on
134                failure, and returns 0 on success.
135            </span>
136        </span>
137    </p>
138      <div class="sect2" lang="en" xml:lang="en">
139        <div class="titlepage">
140          <div>
141            <div>
142              <h3 class="title"><a id="id1707605"></a>Parameters</h3>
143            </div>
144          </div>
145        </div>
146        <div class="sect3" lang="en" xml:lang="en">
147          <div class="titlepage">
148            <div>
149              <div>
150                <h4 class="title"><a id="id1708227"></a>flags</h4>
151              </div>
152            </div>
153          </div>
154          <p>
155                          The <span class="bold"><strong>flags</strong></span> parameter must be set to
156                          one of the following values:
157                     </p>
158          <div class="itemizedlist">
159            <ul type="disc">
160              <li>
161                <p><a id="repmgrstart_DB_REP_MASTER"></a>
162                  <code class="literal">DB_REP_MASTER</code>
163            </p>
164                <p>
165                 Start as a master site, and do not call for an election.  Note there
166                 must never be more than a single master in any replication group, and
167                 only one site at a time should ever be started with the DB_REP_MASTER
168                 flag specified.
169            </p>
170              </li>
171              <li>
172                <p><a id="repmgrstart_DB_REP_CLIENT"></a>
173                  <code class="literal">DB_REP_CLIENT</code>
174            </p>
175                <p>
176                 Start as a client site, and do not call for an election.
177            </p>
178              </li>
179              <li>
180                <p>
181                  <code class="literal">DB_REP_ELECTION</code>
182            </p>
183                <p>
184                 Start as a client, and call for an election if no master is found.
185            </p>
186              </li>
187            </ul>
188          </div>
189        </div>
190        <div class="sect3" lang="en" xml:lang="en">
191          <div class="titlepage">
192            <div>
193              <div>
194                <h4 class="title"><a id="id1708433"></a>nthreads</h4>
195              </div>
196            </div>
197          </div>
198          <p>
199                          Specify the number of threads of control created and dedicated to
200                          processing replication messages.  In addition to these message
201                          processing threads, the Replication Manager creates and manages a few
202                          of its own threads of control.
203                     </p>
204        </div>
205      </div>
206      <div class="sect2" lang="en" xml:lang="en">
207        <div class="titlepage">
208          <div>
209            <div>
210              <h3 class="title"><a id="id1708606"></a>Errors</h3>
211            </div>
212          </div>
213        </div>
214        <p>
215            The <code class="methodname">DbEnv::repmgr_start()</code> <span>
216            
217            <span>
218                method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 
219                exception, encapsulating one of the following non-zero errors, or return one
220                of the following non-zero errors:
221            </span>
222        </span>
223        </p>
224        <div class="sect3" lang="en" xml:lang="en">
225          <div class="titlepage">
226            <div>
227              <div>
228                <h4 class="title"><a id="id1708076"></a>EINVAL</h4>
229              </div>
230            </div>
231          </div>
232          <p>
233                If the database environment was not already opened or was
234opened without the <code class="literal">DB_THREAD</code> flag set; a local
235                site has not already been configured, this method is called
236                from a Base API application; or if an invalid
237                flag value or parameter was specified.
238            </p>
239        </div>
240      </div>
241      <div class="sect2" lang="en" xml:lang="en">
242        <div class="titlepage">
243          <div>
244            <div>
245              <h3 class="title"><a id="id1708077"></a>Class</h3>
246            </div>
247          </div>
248        </div>
249        <p>
250                 <a class="link" href="env.html" title="Chapter 5.  The DbEnv Handle">DbEnv</a>  
251            </p>
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="id1708132"></a>See Also</h3>
258            </div>
259          </div>
260        </div>
261        <p>
262                     <a class="xref" href="rep.html#replist" title="Replication and Related Methods">Replication and Related Methods</a> 
263                </p>
264      </div>
265    </div>
266    <div class="navfooter">
267      <hr />
268      <table width="100%" summary="Navigation footer">
269        <tr>
270          <td width="40%" align="left"><a accesskey="p" href="repmgrsite_list.html">Prev</a> </td>
271          <td width="20%" align="center">
272            <a accesskey="u" href="rep.html">Up</a>
273          </td>
274          <td width="40%" align="right"> <a accesskey="n" href="repmgrstat.html">Next</a></td>
275        </tr>
276        <tr>
277          <td width="40%" align="left" valign="top">DbEnv::repmgr_site_list() </td>
278          <td width="20%" align="center">
279            <a accesskey="h" href="index.html">Home</a>
280          </td>
281          <td width="40%" align="right" valign="top"> DbEnv::repmgr_stat()</td>
282        </tr>
283      </table>
284    </div>
285  </body>
286</html>
287