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>Managing Election Times</title> 7 <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.62.4" /> 9 <link rel="home" href="index.html" title="Getting Started with Replicated Berkeley DB Applications" /> 10 <link rel="up" href="repapp.html" title="Chapter��3.��The DB Replication Framework" /> 11 <link rel="previous" href="fwrkpermmessage.html" title="Permanent Message Handling" /> 12 <link rel="next" href="fmwrkconnectretry.html" title="Managing Connection Retries" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">Managing Election Times</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="fwrkpermmessage.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��3.��The DB Replication Framework</th> 23 <td width="20%" align="right">��<a accesskey="n" href="fmwrkconnectretry.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="electiontimes"></a>Managing Election Times</h2> 33 </div> 34 </div> 35 <div></div> 36 </div> 37 <p> 38 Where it comes to elections, there are two timeout 39 values with which you should be concerned: election 40 timeouts and election retries. 41 </p> 42 <div class="sect2" lang="en" xml:lang="en"> 43 <div class="titlepage"> 44 <div> 45 <div> 46 <h3 class="title"><a id="electiontimeout"></a>Managing Election Timeouts</h3> 47 </div> 48 </div> 49 <div></div> 50 </div> 51 <p> 52 When a environment calls for an election, it will wait 53 some amount of time for the other replicas in the 54 replication group to respond. The amount of time 55 that the environment will wait before declaring the 56 election completed is the <span class="emphasis"><em>election timeout</em></span>. 57 </p> 58 <p> 59 If the environment hears from all other known replicas before 60 the election timeout occurs, the election is considered 61 a success and a master is elected. 62 </p> 63 <p> 64 If only a subset of replicas respond, then the success 65 or failure of the election is determined by (1) 66 how many replicas have responded and (2) the 67 election policy that is in place at the time. 68 For example, usually it only takes a simple 69 majority of replicas to elect a master. If 70 there are enough votes for a given environment to 71 meet that standard, then the master has been 72 elected and the election is considered a 73 success. 74 </p> 75 <p> 76 However, upon application startup you can 77 require that all known replicas must participate in the 78 election. Or, it is possible that not enough 79 votes are cast to select a master even with a 80 simple majority. If either of these conditions 81 occur when the election timeout value is 82 reached, the election is considered a failure 83 and a master is not elected. At this point, 84 your replication group is operating without a 85 master, which means that, essentially, 86 your replicated application has been placed in 87 read-only mode. 88 </p> 89 <p> 90 Note, however, that the replication framework will attempt a 91 new election after a given amount of time has 92 passed. See the next section for details. 93 </p> 94 <p> 95 You set the election timeout value using 96 <span><tt class="methodname">DB_ENV->rep_set_timeout()</tt>.</span> 97 98 To do so, specify the 99 <tt class="literal">DB_REP_ELECTION_TIMEOUT</tt> 100 flag to the <tt class="literal">which</tt> parameter and then a 101 timeout value in microseconds to the 102 <tt class="literal">timeout</tt> parameter. 103 </p> 104 </div> 105 <div class="sect2" lang="en" xml:lang="en"> 106 <div class="titlepage"> 107 <div> 108 <div> 109 <h3 class="title"><a id="electretrytime"></a>Managing Election Retry Times</h3> 110 </div> 111 </div> 112 <div></div> 113 </div> 114 <p> 115 In the event that a election fails (see the 116 previous section), an election will not be 117 attempted again until the election retry 118 timeout value has expired. 119 </p> 120 <p> 121 You set the retry timeout value using 122 <span><tt class="methodname">DB_ENV->rep_set_timeout()</tt>.</span> 123 124 To do so, specify the 125 <tt class="literal">DB_REP_ELECTION_RETRY</tt> 126 flag to the <tt class="literal">which</tt> parameter and then a 127 retry value in microseconds to the 128 <tt class="literal">timeout</tt> parameter. 129 </p> 130 </div> 131 </div> 132 <div class="navfooter"> 133 <hr /> 134 <table width="100%" summary="Navigation footer"> 135 <tr> 136 <td width="40%" align="left"><a accesskey="p" href="fwrkpermmessage.html">Prev</a>��</td> 137 <td width="20%" align="center"> 138 <a accesskey="u" href="repapp.html">Up</a> 139 </td> 140 <td width="40%" align="right">��<a accesskey="n" href="fmwrkconnectretry.html">Next</a></td> 141 </tr> 142 <tr> 143 <td width="40%" align="left" valign="top">Permanent Message Handling��</td> 144 <td width="20%" align="center"> 145 <a accesskey="h" href="index.html">Home</a> 146 </td> 147 <td width="40%" align="right" valign="top">��Managing Connection Retries</td> 148 </tr> 149 </table> 150 </div> 151 </body> 152</html> 153