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 <tt class="methodname">Environment.setReplicationTimeout()</tt>. 97 You pass this method the 98 <tt class="methodname">ReplicationTimeoutType.ELECTION_TIMEOUT</tt> 99 constant and a timeout value in microseconds. 100 </p> 101 </div> 102 <div class="sect2" lang="en" xml:lang="en"> 103 <div class="titlepage"> 104 <div> 105 <div> 106 <h3 class="title"><a id="electretrytime"></a>Managing Election Retry Times</h3> 107 </div> 108 </div> 109 <div></div> 110 </div> 111 <p> 112 In the event that a election fails (see the 113 previous section), an election will not be 114 attempted again until the election retry 115 timeout value has expired. 116 </p> 117 <p> 118 You set the election timeout value using 119 <tt class="methodname">Environment.setReplicationTimeout()</tt>. 120 You pass this method the 121 <tt class="methodname">ReplicationTimeoutType.ELECTION_RETRY</tt> 122 constant and a retry value in microseconds. 123 </p> 124 </div> 125 </div> 126 <div class="navfooter"> 127 <hr /> 128 <table width="100%" summary="Navigation footer"> 129 <tr> 130 <td width="40%" align="left"><a accesskey="p" href="fwrkpermmessage.html">Prev</a>��</td> 131 <td width="20%" align="center"> 132 <a accesskey="u" href="repapp.html">Up</a> 133 </td> 134 <td width="40%" align="right">��<a accesskey="n" href="fmwrkconnectretry.html">Next</a></td> 135 </tr> 136 <tr> 137 <td width="40%" align="left" valign="top">Permanent Message Handling��</td> 138 <td width="20%" align="center"> 139 <a accesskey="h" href="index.html">Home</a> 140 </td> 141 <td width="40%" align="right" valign="top">��Managing Connection Retries</td> 142 </tr> 143 </table> 144 </div> 145 </body> 146</html> 147