Debian Codegraph @

docs/programmer_reference/rep_ex_chan.html

raw symbols SCIP
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>Ex_rep_chan: a Replication Manager channel example</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="Berkeley DB Programmer's Reference Guide" />
10 <link rel="up" href="rep.html" title="Chapter 12.  Berkeley DB Replication" />
11 <link rel="prev" href="rep_ex_rq.html" title="Ex_rep_base: putting it all together" />
12 <link rel="next" href="xa.html" title="Chapter 13.  Distributed Transactions" />
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">Ex_rep_chan: a Replication Manager
22 channel example</th>
23 </tr>
24 <tr>
25 <td width="20%" align="left"><a accesskey="p" href="rep_ex_rq.html">Prev</a> </td>
26 <th width="60%" align="center">Chapter 12. 
27 Berkeley DB Replication
28 </th>
29 <td width="20%" align="right"> <a accesskey="n" href="xa.html">Next</a></td>
30 </tr>
31 </table>
32 <hr />
33 </div>
34 <div class="sect1" lang="en" xml:lang="en">
35 <div class="titlepage">
36 <div>
37 <div>
38 <h2 class="title" style="clear: both"><a id="rep_ex_chan"></a>Ex_rep_chan: a Replication Manager
39 channel example</h2>
40 </div>
41 </div>
42 </div>
43 <p>
44 Ex_rep_chan, found in the <code class="filename">examples/c/ex_rep_chan</code>
45 subdirectory of the Berkeley DB distribution, is a simple but complete
46 demonstration of a replicated application that uses the Replication
47 Manager feature of channels to perform write forwarding. The
48 application is a mock stock ticker. Although similar to the ex_rep_mgr
49 example program, this example differs in that it provides an example of
50 using Replication Manager message channels. Any site accepts a command
51 to write data to the database. If the site is a client, then, using
52 the channels feature, the application forwards the request to the
53 master site. If the site is a master then the request is automatically
54 handled locally. You can read and write stock values at any site
55 without needing to know what site is currently the master.
56 </p>
57 <p>
58 The set of supported commands can be viewed with either the
59 <span class="bold"><strong>help</strong></span> or the
60 <span class="bold"><strong>?</strong></span> command. Several commands work with
61 key/data pairs where the key is a stock symbol and the data is its
62 value.
63 </p>
64 <p>
65 The command to retrieve and print the current site's database contents
66 is <span class="bold"><strong>print</strong></span> or simply an empty input
67 line. To read the contents of the master's database from any site use
68 the <span class="bold"><strong>get key key ...</strong></span> command. That
69 command will forward the read request to the master if necessary and
70 return the key/data pairs for all given keys.
71 </p>
72 <p>
73 There are two commands to put data into the database. Both commands
74 take one or more key/data pairs, all of which are written into the
75 database in a single transaction at the master site. The
76 <span class="bold"><strong>put</strong></span> command sends the data to the
77 master site, and simply waits for a status response. The
78 <span class="bold"><strong>put_sync</strong></span> command sends the data to the
79 master site, and uses a transaction token returned by the master to
80 wait for the contents of that put to be available on the local
81 site. This serves as a demonstration of the
82 <a class="link" href="rep_ryw.html" title="Read your writes consistency">read your writes</a> consistency feature.
83 </p>
84 <p>
85 The Makefile created by the standard UNIX configuration will build the
86 ex_rep_chan example on most platforms. Enter "make ex_rep_chan" to
87 build it.
88 </p>
89 <p>
90 The synopsis for the program is as follows:
91 </p>
92 <p>
93 <code class="literal">ex_rep_chan <span class="bold"><strong>-h home</strong></span> <span class="bold"><strong>-l host:port</strong></span> [<span class="bold"><strong>-MC</strong></span>] [<span class="bold"><strong>-r host:port</strong></span>] [<span class="bold"><strong>-R host:port</strong></span>] [<span class="bold"><strong>-p priority</strong></span>] [<span class="bold"><strong>-v</strong></span>]</code>
94 </p>
95 <p>
96 The options are as follows:
97 </p>
98 <div class="variablelist">
99 <dl>
100 <dt>
101 <span class="term">
102 <span class="bold">
103 <strong>-h</strong>
104 </span>
105 </span>
106 </dt>
107 <dd>Specify a home directory for the database environment.</dd>
108 <dt>
109 <span class="term">
110 <span class="bold">
111 <strong>-l</strong>
112 </span>
113 </span>
114 </dt>
115 <dd>Listen on local host "host" at port "port" for incoming connections.</dd>
116 <dt>
117 <span class="term">
118 <span class="bold">
119 <strong>-M</strong>
120 </span>
121 </span>
122 </dt>
123 <dd>Configure this process as a master.</dd>
124 <dt>
125 <span class="term">
126 <span class="bold">
127 <strong>-C</strong>
128 </span>
129 </span>
130 </dt>
131 <dd>Configure this process as a client.</dd>
132 <dt>
133 <span class="term">
134 <span class="bold">
135 <strong>-r</strong>
136 </span>
137 </span>
138 </dt>
139 <dd>
140 Identifies the helper site used for joining the group.
141 </dd>
142 <dt>
143 <span class="term">
144 <span class="bold">
145 <strong>-R</strong>
146 </span>
147 </span>
148 </dt>
149 <dd>
150 Identifies a remote peer to be used for joining the group. This
151 peer is used for syncing purposes. See
152 <a class="xref" href="rep_mastersync.html#rep_c2c_sync" title="Client-to-client synchronization">Client-to-client synchronization</a>
153 for more information.
154 </dd>
155 <dt>
156 <span class="term">
157 <span class="bold">
158 <strong>-p</strong>
159 </span>
160 </span>
161 </dt>
162 <dd>
163 Set the election priority. See
164 <a class="xref" href="rep_elect.html" title="Elections">Elections</a> for more
165 information.
166 </dd>
167 <dt>
168 <span class="term">
169 <span class="bold">
170 <strong>-v</strong>
171 </span>
172 </span>
173 </dt>
174 <dd>
175 Indicates that additional informational and debugging output
176 should be enabled.
177 </dd>
178 </dl>
179 </div>
180 <p>
181 A typical ex_rep_chan session begins with a command such as the
182 following, to start a master:
183 </p>
184 <pre class="programlisting">ex_rep_chan -M -h DIR1 -l localhost:30100</pre>
185 <p>
186 and several clients:
187 </p>
188 <pre class="programlisting">ex_rep_chan -C -h DIR2 -l localhost:30101 -r localhost:30100
189 ex_rep_chan -C -h DIR3 -l localhost:30102 -r localhost:30100
190 ex_rep_chan -C -h DIR4 -l localhost:30103 -r localhost:30100</pre>
191 </div>
192 <div class="navfooter">
193 <hr />
194 <table width="100%" summary="Navigation footer">
195 <tr>
196 <td width="40%" align="left"><a accesskey="p" href="rep_ex_rq.html">Prev</a> </td>
197 <td width="20%" align="center">
198 <a accesskey="u" href="rep.html">Up</a>
199 </td>
200 <td width="40%" align="right"> <a accesskey="n" href="xa.html">Next</a></td>
201 </tr>
202 <tr>
203 <td width="40%" align="left" valign="top">Ex_rep_base: putting it all together </td>
204 <td width="20%" align="center">
205 <a accesskey="h" href="index.html">Home</a>
206 </td>
207 <td width="40%" align="right" valign="top"> Chapter 13. 
208 Distributed Transactions
209 </td>
210 </tr>
211 </table>
212 </div>
213 </body>
214 </html>