PageRenderTime 58ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 2ms

/OverSim-20101103/doc/doxy/Nice_8cc_source.html

https://bitbucket.org/indigopony/omnetproject
HTML | 3516 lines | 3515 code | 0 blank | 1 comment | 0 complexity | ec2494a4e33ab27d0f9378bf631c9140 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, GPL-2.0, Apache-2.0, JSON

Large files files are truncated, but you can click here to view the full file

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <title>OverSim: Nice.cc Source File</title>
  6. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  7. <link href="doxygen.css" rel="stylesheet" type="text/css"/>
  8. </head>
  9. <body>
  10. <!-- Generated by Doxygen 1.7.1 -->
  11. <div class="navigation" id="top">
  12. <div class="tabs">
  13. <ul class="tablist">
  14. <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
  15. <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  16. <li><a href="namespaces.html"><span>Namespaces</span></a></li>
  17. <li><a href="annotated.html"><span>Classes</span></a></li>
  18. <li class="current"><a href="files.html"><span>Files</span></a></li>
  19. <li><a href="dirs.html"><span>Directories</span></a></li>
  20. </ul>
  21. </div>
  22. <div class="tabs2">
  23. <ul class="tablist">
  24. <li><a href="files.html"><span>File&nbsp;List</span></a></li>
  25. <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
  26. </ul>
  27. </div>
  28. <div class="navpath">
  29. <ul>
  30. <li><a class="el" href="dir_668dee661430860db5868c2621a9c372.html">src</a> </li>
  31. <li><a class="el" href="dir_6302e9405fe106175d386473fd676d2e.html">overlay</a> </li>
  32. <li><a class="el" href="dir_3b7439cc863d448c2d91c48bb8f106aa.html">nice</a> </li>
  33. </ul>
  34. </div>
  35. </div>
  36. <div class="header">
  37. <div class="headertitle">
  38. <h1>Nice.cc</h1> </div>
  39. </div>
  40. <div class="contents">
  41. <a href="Nice_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//</span>
  42. <a name="l00002"></a>00002 <span class="comment">// Copyright (C) 2009 Institut fuer Telematik, Universitaet Karlsruhe (TH)</span>
  43. <a name="l00003"></a>00003 <span class="comment">//</span>
  44. <a name="l00004"></a>00004 <span class="comment">// This program is free software; you can redistribute it and/or</span>
  45. <a name="l00005"></a>00005 <span class="comment">// modify it under the terms of the GNU General Public License</span>
  46. <a name="l00006"></a>00006 <span class="comment">// as published by the Free Software Foundation; either version 2</span>
  47. <a name="l00007"></a>00007 <span class="comment">// of the License, or (at your option) any later version.</span>
  48. <a name="l00008"></a>00008 <span class="comment">//</span>
  49. <a name="l00009"></a>00009 <span class="comment">// This program is distributed in the hope that it will be useful,</span>
  50. <a name="l00010"></a>00010 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
  51. <a name="l00011"></a>00011 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
  52. <a name="l00012"></a>00012 <span class="comment">// GNU General Public License for more details.</span>
  53. <a name="l00013"></a>00013 <span class="comment">//</span>
  54. <a name="l00014"></a>00014 <span class="comment">// You should have received a copy of the GNU General Public License</span>
  55. <a name="l00015"></a>00015 <span class="comment">// along with this program; if not, write to the Free Software</span>
  56. <a name="l00016"></a>00016 <span class="comment">// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</span>
  57. <a name="l00017"></a>00017 <span class="comment">//</span>
  58. <a name="l00018"></a>00018
  59. <a name="l00025"></a>00025 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
  60. <a name="l00026"></a>00026
  61. <a name="l00027"></a>00027 <span class="preprocessor">#include &lt;<a class="code" href="GlobalStatistics_8h.html">GlobalStatistics.h</a>&gt;</span>
  62. <a name="l00028"></a>00028 <span class="preprocessor">#include &quot;<a class="code" href="SimpleInfo_8h.html">SimpleInfo.h</a>&quot;</span>
  63. <a name="l00029"></a>00029 <span class="preprocessor">#include &quot;<a class="code" href="SimpleNodeEntry_8h.html">SimpleNodeEntry.h</a>&quot;</span>
  64. <a name="l00030"></a>00030 <span class="preprocessor">#include &quot;<a class="code" href="SimpleUDP_8h.html">SimpleUDP.h</a>&quot;</span>
  65. <a name="l00031"></a>00031 <span class="preprocessor">#include &quot;<a class="code" href="GlobalNodeListAccess_8h.html">GlobalNodeListAccess.h</a>&quot;</span>
  66. <a name="l00032"></a>00032 <span class="preprocessor">#include &lt;<a class="code" href="BootstrapList_8h.html">BootstrapList.h</a>&gt;</span>
  67. <a name="l00033"></a>00033 <span class="preprocessor">#include &quot;<a class="code" href="Nice_8h.html">Nice.h</a>&quot;</span>
  68. <a name="l00034"></a>00034
  69. <a name="l00035"></a>00035 <span class="keyword">namespace </span>oversim
  70. <a name="l00036"></a>00036 {
  71. <a name="l00037"></a>00037
  72. <a name="l00041"></a>00041 <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="namespaceoversim.html#a068481bf2793ad703ca213dcca1e4a6f" title="Define colors for layers in visualization.">clustercolors</a>[] = { <span class="stringliteral">&quot;yellow&quot;</span>,
  73. <a name="l00042"></a>00042 <span class="stringliteral">&quot;magenta&quot;</span>,
  74. <a name="l00043"></a>00043 <span class="stringliteral">&quot;red&quot;</span>,
  75. <a name="l00044"></a>00044 <span class="stringliteral">&quot;orange&quot;</span>,
  76. <a name="l00045"></a>00045 <span class="stringliteral">&quot;green&quot;</span>,
  77. <a name="l00046"></a>00046 <span class="stringliteral">&quot;aquamarine&quot;</span>,
  78. <a name="l00047"></a>00047 <span class="stringliteral">&quot;cyan&quot;</span>,
  79. <a name="l00048"></a>00048 <span class="stringliteral">&quot;blue&quot;</span>,
  80. <a name="l00049"></a>00049 <span class="stringliteral">&quot;navy&quot;</span>,
  81. <a name="l00050"></a>00050 <span class="stringliteral">&quot;yellow&quot;</span>
  82. <a name="l00051"></a><a class="code" href="namespaceoversim.html#aa3b63c2cc07d2571efe93e9004ca0172">00051</a> };
  83. <a name="l00052"></a>00052
  84. <a name="l00053"></a>00053 <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="namespaceoversim.html#aa3b63c2cc07d2571efe93e9004ca0172">clusterarrows</a>[] = { <span class="stringliteral">&quot;m=m,50,50,50,50;ls=yellow,2&quot;</span>,
  85. <a name="l00054"></a>00054 <span class="stringliteral">&quot;m=m,50,50,50,50;ls=magenta,3&quot;</span>,
  86. <a name="l00055"></a>00055 <span class="stringliteral">&quot;m=m,50,50,50,50;ls=red,4&quot;</span>,
  87. <a name="l00056"></a>00056 <span class="stringliteral">&quot;m=m,50,50,50,50;ls=orange,5&quot;</span>,
  88. <a name="l00057"></a>00057 <span class="stringliteral">&quot;m=m,50,50,50,50;ls=green,6&quot;</span>,
  89. <a name="l00058"></a>00058 <span class="stringliteral">&quot;m=m,50,50,50,50;ls=aquamarine,7&quot;</span>,
  90. <a name="l00059"></a>00059 <span class="stringliteral">&quot;m=m,50,50,50,50;ls=cyan,8&quot;</span>,
  91. <a name="l00060"></a>00060 <span class="stringliteral">&quot;m=m,50,50,50,50;ls=blue,9&quot;</span>,
  92. <a name="l00061"></a>00061 <span class="stringliteral">&quot;m=m,50,50,50,50;ls=navy,10&quot;</span>,
  93. <a name="l00062"></a>00062 <span class="stringliteral">&quot;m=m,50,50,50,50;ls=yellow,11&quot;</span>
  94. <a name="l00063"></a>00063 };
  95. <a name="l00064"></a>00064
  96. <a name="l00065"></a>00065 <a class="code" href="namespaceoversim.html#aac274bdf33ee20fba3e03edadb79cb5b">Define_Module</a>(Nice);
  97. <a name="l00066"></a>00066
  98. <a name="l00067"></a>00067 <span class="keyword">const</span> <span class="keywordtype">short</span> <a class="code" href="classoversim_1_1Nice.html#a960f2035d499686a97fe7163542b8647">Nice::maxLayers</a>;
  99. <a name="l00068"></a>00068
  100. <a name="l00069"></a>00069 <span class="comment">/******************************************************************************</span>
  101. <a name="l00070"></a><a class="code" href="classoversim_1_1Nice.html#a7ffce18253e937f405a232fd8555b60e">00070</a> <span class="comment"> * Constructor</span>
  102. <a name="l00071"></a>00071 <span class="comment"> */</span>
  103. <a name="l00072"></a>00072 <a class="code" href="classoversim_1_1Nice.html#a7ffce18253e937f405a232fd8555b60e">Nice::Nice</a>() : isRendevouzPoint(false),
  104. <a name="l00073"></a>00073 isTempPeered(false),
  105. <a name="l00074"></a>00074 numInconsistencies(0),
  106. <a name="l00075"></a>00075 numQueryTimeouts(0),
  107. <a name="l00076"></a>00076 numPeerTimeouts(0),
  108. <a name="l00077"></a>00077 numTempPeerTimeouts(0),
  109. <a name="l00078"></a>00078 numStructurePartitions(0),
  110. <a name="l00079"></a>00079 numOwnMessagesReceived(0),
  111. <a name="l00080"></a>00080 totalSCMinCompare(0),
  112. <a name="l00081"></a>00081 numJoins(0),
  113. <a name="l00082"></a>00082 totalForwardBytes(0),
  114. <a name="l00083"></a>00083 numReceived(0),
  115. <a name="l00084"></a>00084 totalReceivedBytes(0),
  116. <a name="l00085"></a>00085 numHeartbeat(0),
  117. <a name="l00086"></a>00086 totalHeartbeatBytes(0)
  118. <a name="l00087"></a>00087 {
  119. <a name="l00088"></a>00088
  120. <a name="l00089"></a>00089 <span class="comment">/* do nothing at this point of time, OverSim calls initializeOverlay */</span>
  121. <a name="l00090"></a>00090
  122. <a name="l00091"></a>00091 } <span class="comment">// Nice</span>
  123. <a name="l00092"></a>00092
  124. <a name="l00093"></a>00093
  125. <a name="l00094"></a>00094 <span class="comment">/******************************************************************************</span>
  126. <a name="l00095"></a><a class="code" href="classoversim_1_1Nice.html#a9788a3d4f0f81f204edaaa16a492cf50">00095</a> <span class="comment"> * Destructor</span>
  127. <a name="l00096"></a>00096 <span class="comment"> */</span>
  128. <a name="l00097"></a>00097 <a class="code" href="classoversim_1_1Nice.html#a9788a3d4f0f81f204edaaa16a492cf50">Nice::~Nice</a>()
  129. <a name="l00098"></a>00098 {
  130. <a name="l00099"></a>00099
  131. <a name="l00100"></a>00100 <span class="comment">// destroy self timer messages</span>
  132. <a name="l00101"></a>00101 cancelAndDelete(<a class="code" href="classoversim_1_1Nice.html#a687c425a685e47b47d989b24a1fe6165">heartbeatTimer</a>);
  133. <a name="l00102"></a>00102 cancelAndDelete(<a class="code" href="classoversim_1_1Nice.html#ace2ed47b84cbee1c7cc71cbc44a4fea8">maintenanceTimer</a>);
  134. <a name="l00103"></a>00103 cancelAndDelete(<a class="code" href="classoversim_1_1Nice.html#a4a913c4be6eabc80fac48dffed005771">rpPollTimer</a>);
  135. <a name="l00104"></a>00104 cancelAndDelete(<a class="code" href="classoversim_1_1Nice.html#a4648efb65dd8c13990a571c275d3bd04">queryTimer</a>);
  136. <a name="l00105"></a>00105 cancelAndDelete(<a class="code" href="classoversim_1_1Nice.html#aa31f386f8403d2ba88f43a1a57fcba57">visualizationTimer</a>);
  137. <a name="l00106"></a>00106
  138. <a name="l00107"></a>00107 std::map&lt;TransportAddress, NicePeerInfo*&gt;::iterator it = <a class="code" href="classoversim_1_1Nice.html#abfd784a7eb10c0af88d835308cf66ff6">peerInfos</a>.begin();
  139. <a name="l00108"></a>00108
  140. <a name="l00109"></a>00109 <span class="keywordflow">for</span> (; it != <a class="code" href="classoversim_1_1Nice.html#abfd784a7eb10c0af88d835308cf66ff6">peerInfos</a>.end(); it++) {
  141. <a name="l00110"></a>00110
  142. <a name="l00111"></a>00111 <span class="keyword">delete</span> it-&gt;second;
  143. <a name="l00112"></a>00112
  144. <a name="l00113"></a>00113 }
  145. <a name="l00114"></a>00114
  146. <a name="l00115"></a>00115 } <span class="comment">// ~NICE</span>
  147. <a name="l00116"></a>00116
  148. <a name="l00117"></a>00117
  149. <a name="l00118"></a>00118 <span class="comment">/******************************************************************************</span>
  150. <a name="l00119"></a>00119 <span class="comment"> * initializeOverlay</span>
  151. <a name="l00120"></a><a class="code" href="classoversim_1_1Nice.html#a63977effde493b185fb9230ec5c2a608">00120</a> <span class="comment"> * see BaseOverlay.h</span>
  152. <a name="l00121"></a>00121 <span class="comment"> */</span>
  153. <a name="l00122"></a>00122 <span class="keywordtype">void</span> <a class="code" href="classoversim_1_1Nice.html#a63977effde493b185fb9230ec5c2a608" title="Initializes derived-class-attributes.">Nice::initializeOverlay</a>( <span class="keywordtype">int</span> stage )
  154. <a name="l00123"></a>00123 {
  155. <a name="l00124"></a>00124
  156. <a name="l00125"></a>00125 <span class="comment">/* Because of IPAddressResolver, we need to wait until interfaces</span>
  157. <a name="l00126"></a>00126 <span class="comment"> * are registered, address auto-assignment takes place etc. */</span>
  158. <a name="l00127"></a>00127 <span class="keywordflow">if</span> (stage != <a class="code" href="InitStages_8h.html#a42fde1aa1e14a1c45d29061d6e87e532a58e83c497c7c8495e9c592ff3148b6b9" title="first stage for overlay modules (Tier 0 / KBR)">MIN_STAGE_OVERLAY</a>)
  159. <a name="l00128"></a>00128 <span class="keywordflow">return</span>;
  160. <a name="l00129"></a>00129
  161. <a name="l00130"></a>00130 <span class="comment">/* Set appearance of node in visualization */</span>
  162. <a name="l00131"></a>00131 getParentModule()-&gt;getParentModule()-&gt;getDisplayString().setTagArg(<span class="stringliteral">&quot;i&quot;</span>, 0, <span class="stringliteral">&quot;device/pc_vs&quot;</span>);
  163. <a name="l00132"></a>00132 getParentModule()-&gt;getParentModule()-&gt;getDisplayString().setTagArg(<span class="stringliteral">&quot;i2&quot;</span>, 0, <span class="stringliteral">&quot;block/circle_vs&quot;</span>);
  164. <a name="l00133"></a>00133
  165. <a name="l00134"></a>00134 <span class="comment">/* Initially clear all clusters */</span>
  166. <a name="l00135"></a>00135 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;<a class="code" href="classoversim_1_1Nice.html#a960f2035d499686a97fe7163542b8647">maxLayers</a>; i++) {
  167. <a name="l00136"></a>00136
  168. <a name="l00137"></a>00137 <span class="keywordflow">for</span> (TaSet::iterator itn = <a class="code" href="classoversim_1_1Nice.html#a644c991f567da9990713bba00e3dacac">clusters</a>[i].begin(); itn != <a class="code" href="classoversim_1_1Nice.html#a644c991f567da9990713bba00e3dacac">clusters</a>[i].<a class="code" href="classNiceCluster.html#aed386323e43a572eb51c3e2a97790a6c" title="Returns const iterator to end of cluster.">end</a>(); ++itn) {
  169. <a name="l00138"></a>00138 <a class="code" href="classTopologyVis.html#ae9629882d5f3bb7865f9c9501b23a172" title="Removes an arrow from this node to neighbor.">deleteOverlayNeighborArrow</a>(*itn);
  170. <a name="l00139"></a>00139 }
  171. <a name="l00140"></a>00140 <a class="code" href="classoversim_1_1Nice.html#a644c991f567da9990713bba00e3dacac">clusters</a>[i].<a class="code" href="classNiceCluster.html#ad66e5cfc867561bef65fcfd43dbc7d13" title="Removes all addresses from cluster, sets leader to unspecified address and sets last lt to 0...">clear</a>();
  172. <a name="l00141"></a>00141
  173. <a name="l00142"></a>00142 }
  174. <a name="l00143"></a>00143
  175. <a name="l00144"></a>00144 <span class="comment">/* Initialize Self-Messages */</span>
  176. <a name="l00145"></a>00145
  177. <a name="l00146"></a>00146 <span class="comment">// Periodic Heartbeat Messages</span>
  178. <a name="l00147"></a>00147 <a class="code" href="classoversim_1_1Nice.html#a58d3d6285e2a84acb277e220d1a35807">heartbeatInterval</a> = par(<span class="stringliteral">&quot;heartbeatInterval&quot;</span>);
  179. <a name="l00148"></a>00148 <a class="code" href="classoversim_1_1Nice.html#a687c425a685e47b47d989b24a1fe6165">heartbeatTimer</a> = <span class="keyword">new</span> cMessage(<span class="stringliteral">&quot;heartbeatTimer&quot;</span>);
  180. <a name="l00149"></a>00149
  181. <a name="l00150"></a>00150 <span class="comment">// Periodic Protocol Maintenance</span>
  182. <a name="l00151"></a>00151 <a class="code" href="classoversim_1_1Nice.html#a6d14d42d813222d9ee8c5d395ba60365">maintenanceInterval</a> = par(<span class="stringliteral">&quot;maintenanceInterval&quot;</span>);
  183. <a name="l00152"></a>00152 <a class="code" href="classoversim_1_1Nice.html#ace2ed47b84cbee1c7cc71cbc44a4fea8">maintenanceTimer</a> = <span class="keyword">new</span> cMessage(<span class="stringliteral">&quot;maintenanceTimer&quot;</span>);
  184. <a name="l00153"></a>00153
  185. <a name="l00154"></a>00154 <a class="code" href="classoversim_1_1Nice.html#a6e3e4cdfa221e6f9980e3c51a5452570">queryInterval</a> = par(<span class="stringliteral">&quot;queryInterval&quot;</span>);
  186. <a name="l00155"></a>00155 <a class="code" href="classoversim_1_1Nice.html#a4648efb65dd8c13990a571c275d3bd04">queryTimer</a> = <span class="keyword">new</span> cMessage(<span class="stringliteral">&quot;queryTimer&quot;</span>);
  187. <a name="l00156"></a>00156
  188. <a name="l00157"></a>00157 <a class="code" href="classoversim_1_1Nice.html#a4a913c4be6eabc80fac48dffed005771">rpPollTimer</a> = <span class="keyword">new</span> cMessage(<span class="stringliteral">&quot;rpPollTimer&quot;</span>);
  189. <a name="l00158"></a>00158 <a class="code" href="classoversim_1_1Nice.html#a417d95b2b0bdad377d0613f4dde77b66">rpPollTimerInterval</a> = par(<span class="stringliteral">&quot;rpPollTimerInterval&quot;</span>);
  190. <a name="l00159"></a>00159
  191. <a name="l00160"></a>00160 <a class="code" href="classoversim_1_1Nice.html#abffc50a7507069a0d97997f269c2d130">peerTimeoutHeartbeats</a> = par(<span class="stringliteral">&quot;peerTimeoutHeartbeats&quot;</span>);
  192. <a name="l00161"></a>00161
  193. <a name="l00162"></a>00162 <a class="code" href="classoversim_1_1Nice.html#a8603dc65c59516ee5dc237ce651659c6">pimp</a> = par(<span class="stringliteral">&quot;enhancedMode&quot;</span>);
  194. <a name="l00163"></a>00163
  195. <a name="l00164"></a>00164 <a class="code" href="classoversim_1_1Nice.html#aaad03fa2518f9122314129e4afd433d8">isRendevouzPoint</a> = <span class="keyword">false</span>;
  196. <a name="l00165"></a>00165
  197. <a name="l00166"></a>00166 <a class="code" href="classoversim_1_1Nice.html#ac00b0f8d11b8f3f7c3e5c2eb78511cc6">polledRendevouzPoint</a> = <a class="code" href="classTransportAddress.html#ac1709545db722cbbce1367034142d31f" title="TransportAddress without specified ip and port.">TransportAddress::UNSPECIFIED_NODE</a>;
  198. <a name="l00167"></a>00167
  199. <a name="l00168"></a>00168 <span class="comment">/* DEBUG */</span>
  200. <a name="l00169"></a>00169 <a class="code" href="classoversim_1_1Nice.html#aebff401d083e6f6b20fb9253181465ff">clusterrefinement</a> = par(<span class="stringliteral">&quot;debug_clusterrefinement&quot;</span>);
  201. <a name="l00170"></a>00170 <a class="code" href="classoversim_1_1Nice.html#ae8b24bedc06f07fe2c03ec7b135c63a5">debug_heartbeats</a> = par(<span class="stringliteral">&quot;debug_heartbeats&quot;</span>);
  202. <a name="l00171"></a>00171 <a class="code" href="classoversim_1_1Nice.html#a1a3aaae38bf78dc32e177868afbde6c7">debug_visualization</a> = par(<span class="stringliteral">&quot;debug_visualization&quot;</span>);
  203. <a name="l00172"></a>00172 <a class="code" href="classoversim_1_1Nice.html#afa26359a3e0160724c4f36bbb02df6f4">debug_join</a> = par(<span class="stringliteral">&quot;debug_join&quot;</span>);
  204. <a name="l00173"></a>00173 <a class="code" href="classoversim_1_1Nice.html#a6af70b0196fd0d482286c0ff5a46f5ae">debug_peertimeouts</a> = par(<span class="stringliteral">&quot;debug_peertimeouts&quot;</span>);
  205. <a name="l00174"></a>00174 <a class="code" href="classoversim_1_1Nice.html#a12a2bd46343643e35473ab74900db70a">debug_removes</a> = par(<span class="stringliteral">&quot;debug_removes&quot;</span>);
  206. <a name="l00175"></a>00175 <a class="code" href="classoversim_1_1Nice.html#a65ded61488d36484e3529f3e23b6e713">debug_queries</a> = par(<span class="stringliteral">&quot;debug_queries&quot;</span>);
  207. <a name="l00176"></a>00176
  208. <a name="l00177"></a>00177 <a class="code" href="classoversim_1_1Nice.html#aa31f386f8403d2ba88f43a1a57fcba57">visualizationTimer</a> = <span class="keyword">new</span> cMessage(<span class="stringliteral">&quot;visualizationTimer&quot;</span>);
  209. <a name="l00178"></a>00178
  210. <a name="l00179"></a>00179 <span class="comment">/* Read cluster parameter k */</span>
  211. <a name="l00180"></a>00180 <a class="code" href="classoversim_1_1Nice.html#a29f5e69b521aa1eb0047e64272b84562">k</a> = par(<span class="stringliteral">&quot;k&quot;</span>);
  212. <a name="l00181"></a>00181
  213. <a name="l00182"></a>00182 <a class="code" href="classoversim_1_1Nice.html#a3469d510d59a1cc3577e5d24a6628275">CLUSTERLEADERBOUND</a> = par(<span class="stringliteral">&quot;clusterLeaderBound&quot;</span>);
  214. <a name="l00183"></a>00183 <a class="code" href="classoversim_1_1Nice.html#ad83625b73a292aa04380837e7d6c3944">CLUSTERLEADERCOMPAREDIST</a> = par(<span class="stringliteral">&quot;clusterLeaderCompareDist&quot;</span>);
  215. <a name="l00184"></a>00184 <a class="code" href="classoversim_1_1Nice.html#a4368d509b0c5ac9950cf8fa52fa5f176">SC_PROC_DISTANCE</a> = par(<span class="stringliteral">&quot;scProcDistance&quot;</span>);
  216. <a name="l00185"></a>00185 <a class="code" href="classoversim_1_1Nice.html#a02292a0c465a7bbb80f66fbd7187cc9b">SC_MIN_OFFSET</a> = par(<span class="stringliteral">&quot;scMinOffset&quot;</span>);
  217. <a name="l00186"></a>00186
  218. <a name="l00187"></a>00187 <span class="comment">/* Add own node to peerInfos */</span>
  219. <a name="l00188"></a>00188 <a class="code" href="classoversim_1_1NicePeerInfo.html">NicePeerInfo</a>* pi = <span class="keyword">new</span> <a class="code" href="classoversim_1_1Nice.html#a6b71884e13dc73c1a1c81351b031cb64">NicePeerInfo</a>(<span class="keyword">this</span>);
  220. <a name="l00189"></a>00189 pi-&gt;<a class="code" href="classoversim_1_1NicePeerInfo.html#a582f40941e6e0e51010bc032560218b2">set_distance</a>(0);
  221. <a name="l00190"></a>00190 <a class="code" href="classoversim_1_1Nice.html#abfd784a7eb10c0af88d835308cf66ff6">peerInfos</a>.insert(std::make_pair(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>, pi));
  222. <a name="l00191"></a>00191
  223. <a name="l00192"></a>00192 <span class="comment">/* Set evaluation layer to not specified */</span>
  224. <a name="l00193"></a>00193 <a class="code" href="classoversim_1_1Nice.html#a71935c17b8b4804bc6dd823d696dbf3e">evalLayer</a> = -1;
  225. <a name="l00194"></a>00194 <a class="code" href="classoversim_1_1Nice.html#a46807673c62fb160eaf202a0eac29058">joinLayer</a> = -1;
  226. <a name="l00195"></a>00195
  227. <a name="l00196"></a>00196 <a class="code" href="classoversim_1_1Nice.html#a36ec304efa445340c9c1f72e950b076b">first_leader</a> = <a class="code" href="classTransportAddress.html#ac1709545db722cbbce1367034142d31f" title="TransportAddress without specified ip and port.">TransportAddress::UNSPECIFIED_NODE</a>;
  228. <a name="l00197"></a>00197 <a class="code" href="classoversim_1_1Nice.html#ad6115b6ca9ae33de7308570d8aaceaf7">second_leader</a> = <a class="code" href="classTransportAddress.html#ac1709545db722cbbce1367034142d31f" title="TransportAddress without specified ip and port.">TransportAddress::UNSPECIFIED_NODE</a>;
  229. <a name="l00198"></a>00198
  230. <a name="l00199"></a>00199 <span class="comment">// add some watches</span>
  231. <a name="l00200"></a>00200 WATCH(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>);
  232. <a name="l00201"></a>00201 <a class="code" href="hashWatch_8h.html#ae5678c8f482eb1afddaea5022e654865" title="Makes pointer_maps inspectable in Tkenv.">WATCH_POINTER_MAP</a>(<a class="code" href="classoversim_1_1Nice.html#abfd784a7eb10c0af88d835308cf66ff6">peerInfos</a>);
  233. <a name="l00202"></a>00202 WATCH(<a class="code" href="classoversim_1_1Nice.html#a71935c17b8b4804bc6dd823d696dbf3e">evalLayer</a>);
  234. <a name="l00203"></a>00203 WATCH(<a class="code" href="classoversim_1_1Nice.html#aa604bd27a4b737fd179c2b09debebc84">query_start</a>);
  235. <a name="l00204"></a>00204 WATCH(<a class="code" href="classoversim_1_1Nice.html#a687c425a685e47b47d989b24a1fe6165">heartbeatTimer</a>);
  236. <a name="l00205"></a>00205 WATCH_MAP(<a class="code" href="classoversim_1_1Nice.html#ab4e95531a9f00a8c4ed022749d263238">tempPeers</a>);
  237. <a name="l00206"></a>00206 WATCH(<a class="code" href="classoversim_1_1Nice.html#a28c155327e18edb17d6ab2a4c67cf0a8">RendevouzPoint</a>);
  238. <a name="l00207"></a>00207 WATCH(<a class="code" href="classoversim_1_1Nice.html#aaad03fa2518f9122314129e4afd433d8">isRendevouzPoint</a>);
  239. <a name="l00208"></a>00208
  240. <a name="l00209"></a>00209 WATCH(<a class="code" href="classoversim_1_1Nice.html#a50dd1e20f4c56dc45f9ffa1c52d2716f">numInconsistencies</a>);
  241. <a name="l00210"></a>00210 WATCH(<a class="code" href="classoversim_1_1Nice.html#ac151ea0f3d5ac1d60b32d92c08d89e44">numQueryTimeouts</a>);
  242. <a name="l00211"></a>00211 WATCH(<a class="code" href="classoversim_1_1Nice.html#a82e217903a688c47656a56dc4a593ebc">numPeerTimeouts</a>);
  243. <a name="l00212"></a>00212 WATCH(<a class="code" href="classoversim_1_1Nice.html#a97964c134da4da5b58b3c7dff32a0800">numTempPeerTimeouts</a>);
  244. <a name="l00213"></a>00213 WATCH(<a class="code" href="classoversim_1_1Nice.html#acd1effc337560f6677e63608b3e53af8">numStructurePartitions</a>);
  245. <a name="l00214"></a>00214 WATCH(<a class="code" href="classoversim_1_1Nice.html#ab0a8837fcffd376b822166d048a401fa">numOwnMessagesReceived</a>);
  246. <a name="l00215"></a>00215 WATCH(<a class="code" href="classoversim_1_1Nice.html#a063a91a0c9cbd3bcfeca7ce10944eb70">totalSCMinCompare</a>);
  247. <a name="l00216"></a>00216 WATCH(<a class="code" href="classoversim_1_1Nice.html#a765b5d96a57bf709b6a8ce28541d55a6">numJoins</a>);
  248. <a name="l00217"></a>00217 WATCH(<a class="code" href="classoversim_1_1Nice.html#ade427df4fbd3edb53e04467984384927">totalForwardBytes</a>);
  249. <a name="l00218"></a>00218 WATCH(<a class="code" href="classoversim_1_1Nice.html#ab0165945cd4929e57f66e595ce76cc14">numReceived</a>);
  250. <a name="l00219"></a>00219 WATCH(<a class="code" href="classoversim_1_1Nice.html#ab70712e9a475d6ab12690cf36a31ffe1">totalReceivedBytes</a>);
  251. <a name="l00220"></a>00220 WATCH(<a class="code" href="classoversim_1_1Nice.html#aed41149eb142ad3c71d6a639b113a5f7">numHeartbeat</a>);
  252. <a name="l00221"></a>00221 WATCH(<a class="code" href="classoversim_1_1Nice.html#ad186e77457bdad45888594517319a02b">totalHeartbeatBytes</a>);
  253. <a name="l00222"></a>00222
  254. <a name="l00223"></a>00223 } <span class="comment">// initializeOverlay</span>
  255. <a name="l00224"></a>00224
  256. <a name="l00225"></a>00225
  257. <a name="l00226"></a>00226 <span class="comment">/******************************************************************************</span>
  258. <a name="l00227"></a>00227 <span class="comment"> * joinOverlay</span>
  259. <a name="l00228"></a><a class="code" href="classoversim_1_1Nice.html#a642dd901f2f5b0561cde5a1c3e932d8e">00228</a> <span class="comment"> * see BaseOverlay.h</span>
  260. <a name="l00229"></a>00229 <span class="comment"> */</span>
  261. <a name="l00230"></a>00230 <span class="keywordtype">void</span> <a class="code" href="classoversim_1_1Nice.html#a642dd901f2f5b0561cde5a1c3e932d8e" title="Join the overlay with a given nodeID in thisNode.key.">Nice::joinOverlay</a>()
  262. <a name="l00231"></a>00231 {
  263. <a name="l00232"></a>00232 <a class="code" href="classoversim_1_1Nice.html#ad1d32ea267badf0b9a482d7c415aa03c" title="changes node state">changeState</a>(<a class="code" href="classBaseOverlay.html#a0ad4b12b0c9949661f66db7fbbf7d40fa4c1b397f6c4682baf7db280e7f15520a">INIT</a>);
  264. <a name="l00233"></a>00233 <a class="code" href="classoversim_1_1Nice.html#ad1d32ea267badf0b9a482d7c415aa03c" title="changes node state">changeState</a>(<a class="code" href="classBaseOverlay.html#a0ad4b12b0c9949661f66db7fbbf7d40fab746fc2a119638665d6ac9d493146662">BOOTSTRAP</a>);
  265. <a name="l00234"></a><a class="code" href="classoversim_1_1Nice.html#a9f2264e7a35474365104f15854108700">00234</a> } <span class="comment">// joinOverlay</span>
  266. <a name="l00235"></a>00235
  267. <a name="l00236"></a>00236 <span class="keywordtype">void</span> <a class="code" href="classoversim_1_1Nice.html#a9f2264e7a35474365104f15854108700" title="This method gets call **.gracefulLeaveDelay seconds before it is killed.">Nice::handleNodeLeaveNotification</a>() {
  268. <a name="l00237"></a>00237 <span class="keywordflow">if</span> (<a class="code" href="classoversim_1_1Nice.html#aaad03fa2518f9122314129e4afd433d8">isRendevouzPoint</a>) {
  269. <a name="l00238"></a>00238 opp_error(<span class="stringliteral">&quot;The NICE Rendevouz Point is being churned out and the simulation cannot continue. &quot;</span>
  270. <a name="l00239"></a>00239 <span class="stringliteral">&quot;Please, check your config and make sure that the Chrun Generator&#39;s configuration is correct. &quot;</span>
  271. <a name="l00240"></a>00240 <span class="stringliteral">&quot;Specifically, the Rendevouz Point must not get churned out during the simulation.&quot;</span>);
  272. <a name="l00241"></a>00241 }
  273. <a name="l00242"></a>00242 }
  274. <a name="l00243"></a>00243
  275. <a name="l00244"></a>00244 <span class="comment">/******************************************************************************</span>
  276. <a name="l00245"></a>00245 <span class="comment"> * changeState</span>
  277. <a name="l00246"></a><a class="code" href="classoversim_1_1Nice.html#ad1d32ea267badf0b9a482d7c415aa03c">00246</a> <span class="comment"> * see BaseOverlay.h</span>
  278. <a name="l00247"></a>00247 <span class="comment"> */</span>
  279. <a name="l00248"></a>00248 <span class="keywordtype">void</span> <a class="code" href="classoversim_1_1Nice.html#ad1d32ea267badf0b9a482d7c415aa03c" title="changes node state">Nice::changeState</a>( <span class="keywordtype">int</span> toState )
  280. <a name="l00249"></a>00249 {
  281. <a name="l00250"></a>00250 <span class="keywordflow">switch</span> (toState) {
  282. <a name="l00251"></a>00251
  283. <a name="l00252"></a>00252 <span class="keywordflow">case</span> <a class="code" href="classBaseOverlay.html#a0ad4b12b0c9949661f66db7fbbf7d40fa4c1b397f6c4682baf7db280e7f15520a">INIT</a>:
  284. <a name="l00253"></a>00253
  285. <a name="l00254"></a>00254 <a class="code" href="classBaseOverlay.html#ab4be6d88417117fbf33a445d56af2655">state</a> = INIT;
  286. <a name="l00255"></a>00255
  287. <a name="l00256"></a>00256 getParentModule()-&gt;getParentModule()-&gt;getDisplayString().setTagArg(<span class="stringliteral">&quot;i2&quot;</span>, 1, <span class="stringliteral">&quot;red&quot;</span>);
  288. <a name="l00257"></a>00257
  289. <a name="l00258"></a>00258 scheduleAt(simTime() + 1, <a class="code" href="classoversim_1_1Nice.html#aa31f386f8403d2ba88f43a1a57fcba57">visualizationTimer</a>);
  290. <a name="l00259"></a>00259
  291. <a name="l00260"></a>00260 <span class="keywordflow">break</span>;
  292. <a name="l00261"></a>00261
  293. <a name="l00262"></a>00262 <span class="keywordflow">case</span> <a class="code" href="classBaseOverlay.html#a0ad4b12b0c9949661f66db7fbbf7d40fab746fc2a119638665d6ac9d493146662">BOOTSTRAP</a>:
  294. <a name="l00263"></a>00263
  295. <a name="l00264"></a>00264 <a class="code" href="classBaseOverlay.html#ab4be6d88417117fbf33a445d56af2655">state</a> = BOOTSTRAP;
  296. <a name="l00265"></a>00265
  297. <a name="l00266"></a>00266 <span class="comment">/* get rendevouz point */</span>
  298. <a name="l00267"></a>00267 <a class="code" href="classoversim_1_1Nice.html#a28c155327e18edb17d6ab2a4c67cf0a8">RendevouzPoint</a> = <a class="code" href="classBaseOverlay.html#abe4dea93564123116c97d5c4721f0504" title="pointer to the BootstrapList module">bootstrapList</a>-&gt;<a class="code" href="classBootstrapList.html#af6e1422372d548ba574e136c1a10ccaa" title="Get a bootstrap node from the bootstrap list.">getBootstrapNode</a>();
  299. <a name="l00268"></a>00268 <span class="keywordflow">if</span> (<a class="code" href="classoversim_1_1Nice.html#a28c155327e18edb17d6ab2a4c67cf0a8">RendevouzPoint</a>.<a class="code" href="classTransportAddress.html#a026e777c423ff2a0280edd2fa5472e74" title="indicates if TransportAddress is specified">isUnspecified</a>()) {
  300. <a name="l00269"></a>00269
  301. <a name="l00270"></a>00270 <a class="code" href="classoversim_1_1Nice.html#a28c155327e18edb17d6ab2a4c67cf0a8">RendevouzPoint</a> = <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>;
  302. <a name="l00271"></a>00271 <a class="code" href="classoversim_1_1Nice.html#aaad03fa2518f9122314129e4afd433d8">isRendevouzPoint</a> = <span class="keyword">true</span>;
  303. <a name="l00272"></a>00272
  304. <a name="l00273"></a>00273 <span class="comment">/* join cluster layer 0 as first node */</span>
  305. <a name="l00274"></a>00274 <a class="code" href="classoversim_1_1Nice.html#a644c991f567da9990713bba00e3dacac">clusters</a>[0].<a class="code" href="classNiceCluster.html#abf66af103a6767b2c7fbce63bc18ce19" title="Adds address to cluster.">add</a>(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>);
  306. <a name="l00275"></a>00275 <a class="code" href="classoversim_1_1Nice.html#a644c991f567da9990713bba00e3dacac">clusters</a>[0].<a class="code" href="classNiceCluster.html#a1e05f1adaf751ab276de29c3eb8fbe56" title="Set leader to given address.">setLeader</a>(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>);
  307. <a name="l00276"></a>00276
  308. <a name="l00277"></a>00277 <a class="code" href="classoversim_1_1Nice.html#ad1d32ea267badf0b9a482d7c415aa03c" title="changes node state">changeState</a>(<a class="code" href="classBaseOverlay.html#a0ad4b12b0c9949661f66db7fbbf7d40fab3a263fb274a58d63b15cd61ba910335">READY</a>);
  309. <a name="l00278"></a>00278
  310. <a name="l00279"></a>00279 <span class="keywordflow">return</span>;
  311. <a name="l00280"></a>00280
  312. <a name="l00281"></a>00281 }
  313. <a name="l00282"></a>00282 <span class="keywordflow">else</span> {
  314. <a name="l00283"></a>00283
  315. <a name="l00284"></a>00284 <a class="code" href="classoversim_1_1Nice.html#ac1b9865b490cf352d83680020939c270">pollRP</a>(-1);
  316. <a name="l00285"></a>00285
  317. <a name="l00286"></a>00286 <span class="comment">/* initiate NICE structure joining */</span>
  318. <a name="l00287"></a>00287 <a class="code" href="classoversim_1_1Nice.html#ad3b7430e484451777e58ea163e4fc049">BasicJoinLayer</a>(-1);
  319. <a name="l00288"></a>00288
  320. <a name="l00289"></a>00289 }
  321. <a name="l00290"></a>00290
  322. <a name="l00291"></a>00291 <span class="keywordflow">break</span>;
  323. <a name="l00292"></a>00292
  324. <a name="l00293"></a>00293 <span class="keywordflow">case</span> <a class="code" href="classBaseOverlay.html#a0ad4b12b0c9949661f66db7fbbf7d40fab3a263fb274a58d63b15cd61ba910335">READY</a>:
  325. <a name="l00294"></a>00294
  326. <a name="l00295"></a>00295 <a class="code" href="classBaseOverlay.html#ab4be6d88417117fbf33a445d56af2655">state</a> = READY;
  327. <a name="l00296"></a>00296
  328. <a name="l00297"></a>00297 cancelEvent(<a class="code" href="classoversim_1_1Nice.html#a687c425a685e47b47d989b24a1fe6165">heartbeatTimer</a>);
  329. <a name="l00298"></a>00298 scheduleAt(simTime() + <a class="code" href="classoversim_1_1Nice.html#a58d3d6285e2a84acb277e220d1a35807">heartbeatInterval</a>, <a class="code" href="classoversim_1_1Nice.html#a687c425a685e47b47d989b24a1fe6165">heartbeatTimer</a>);
  330. <a name="l00299"></a>00299 cancelEvent(<a class="code" href="classoversim_1_1Nice.html#ace2ed47b84cbee1c7cc71cbc44a4fea8">maintenanceTimer</a>);
  331. <a name="l00300"></a>00300 scheduleAt(simTime() + <a class="code" href="classoversim_1_1Nice.html#a6d14d42d813222d9ee8c5d395ba60365">maintenanceInterval</a>, <a class="code" href="classoversim_1_1Nice.html#ace2ed47b84cbee1c7cc71cbc44a4fea8">maintenanceTimer</a>);
  332. <a name="l00301"></a>00301
  333. <a name="l00302"></a>00302 getParentModule()-&gt;getParentModule()-&gt;getDisplayString().setTagArg
  334. <a name="l00303"></a>00303 (<span class="stringliteral">&quot;i2&quot;</span>, 1, <a class="code" href="namespaceoversim.html#a068481bf2793ad703ca213dcca1e4a6f" title="Define colors for layers in visualization.">clustercolors</a>[<a class="code" href="classoversim_1_1Nice.html#ac29c7ecdf6590c8f7fd4ea9b546f72f8">getHighestLayer</a>()]);
  335. <a name="l00304"></a>00304
  336. <a name="l00305"></a>00305 <a class="code" href="classBaseOverlay.html#a9da615809e832cbc4645cc732d510277" title="Sets the overlay ready icon and register/deregisters the node at the GlobalNodeList.">setOverlayReady</a>(<span class="keyword">true</span>);
  337. <a name="l00306"></a>00306 <span class="comment">/* allow only rendevouz point to be bootstrap node */</span>
  338. <a name="l00307"></a>00307 <span class="keywordflow">if</span> (!<a class="code" href="classoversim_1_1Nice.html#aaad03fa2518f9122314129e4afd433d8">isRendevouzPoint</a>) <a class="code" href="classBaseOverlay.html#abe4dea93564123116c97d5c4721f0504" title="pointer to the BootstrapList module">bootstrapList</a>-&gt;<a class="code" href="classBootstrapList.html#ae3599c25687b302037e58d3ca68411cd">removeBootstrapNode</a>(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>);
  339. <a name="l00308"></a>00308
  340. <a name="l00309"></a>00309 <span class="keywordflow">break</span>;
  341. <a name="l00310"></a>00310
  342. <a name="l00311"></a>00311 }
  343. <a name="l00312"></a>00312
  344. <a name="l00313"></a>00313 } <span class="comment">// changeState</span>
  345. <a name="l00314"></a>00314
  346. <a name="l00315"></a>00315
  347. <a name="l00316"></a>00316 <span class="comment">/******************************************************************************</span>
  348. <a name="l00317"></a>00317 <span class="comment"> * changeState</span>
  349. <a name="l00318"></a><a class="code" href="classoversim_1_1Nice.html#aebd1289938fa0c32bceda56deafaf302">00318</a> <span class="comment"> * see BaseOverlay.h</span>
  350. <a name="l00319"></a>00319 <span class="comment"> */</span>
  351. <a name="l00320"></a>00320 <span class="keywordtype">void</span> <a class="code" href="classoversim_1_1Nice.html#aebd1289938fa0c32bceda56deafaf302">Nice::handleTimerEvent</a>( cMessage* msg )
  352. <a name="l00321"></a>00321 {
  353. <a name="l00322"></a>00322
  354. <a name="l00323"></a>00323 <span class="keywordflow">if</span> (msg-&gt;isName(<span class="stringliteral">&quot;visualizationTimer&quot;</span>)) {
  355. <a name="l00324"></a>00324
  356. <a name="l00325"></a>00325 <a class="code" href="classoversim_1_1Nice.html#a71a14940853660afb14b6c8f6b5d448c">updateVisualization</a>();
  357. <a name="l00326"></a>00326 scheduleAt(simTime() + 1, <a class="code" href="classoversim_1_1Nice.html#aa31f386f8403d2ba88f43a1a57fcba57">visualizationTimer</a>);
  358. <a name="l00327"></a>00327
  359. <a name="l00328"></a>00328 }
  360. <a name="l00329"></a>00329 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (msg-&gt;isName(<span class="stringliteral">&quot;heartbeatTimer&quot;</span>)) {
  361. <a name="l00330"></a>00330
  362. <a name="l00331"></a>00331 <a class="code" href="classoversim_1_1Nice.html#a1ffd3a3b39866e51502fee0bf37480f7">sendHeartbeats</a>();
  363. <a name="l00332"></a>00332 scheduleAt(simTime() + <a class="code" href="classoversim_1_1Nice.html#a58d3d6285e2a84acb277e220d1a35807">heartbeatInterval</a>, <a class="code" href="classoversim_1_1Nice.html#a687c425a685e47b47d989b24a1fe6165">heartbeatTimer</a>);
  364. <a name="l00333"></a>00333
  365. <a name="l00334"></a>00334 }
  366. <a name="l00335"></a>00335 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (msg-&gt;isName(<span class="stringliteral">&quot;maintenanceTimer&quot;</span>)) {
  367. <a name="l00336"></a>00336
  368. <a name="l00337"></a>00337 <a class="code" href="classoversim_1_1Nice.html#a0a808dd35aedab035a7bb8ba1a5d6f9a">maintenance</a>();
  369. <a name="l00338"></a>00338 cancelEvent(<a class="code" href="classoversim_1_1Nice.html#ace2ed47b84cbee1c7cc71cbc44a4fea8">maintenanceTimer</a>);
  370. <a name="l00339"></a>00339 scheduleAt(simTime() + <a class="code" href="classoversim_1_1Nice.html#a6d14d42d813222d9ee8c5d395ba60365">maintenanceInterval</a>, <a class="code" href="classoversim_1_1Nice.html#ace2ed47b84cbee1c7cc71cbc44a4fea8">maintenanceTimer</a>);
  371. <a name="l00340"></a>00340
  372. <a name="l00341"></a>00341 }
  373. <a name="l00342"></a>00342 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (msg-&gt;isName(<span class="stringliteral">&quot;queryTimer&quot;</span>)) {
  374. <a name="l00343"></a>00343
  375. <a name="l00344"></a>00344 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(++<a class="code" href="classoversim_1_1Nice.html#a50dd1e20f4c56dc45f9ffa1c52d2716f">numInconsistencies</a>; ++<a class="code" href="classoversim_1_1Nice.html#ac151ea0f3d5ac1d60b32d92c08d89e44">numQueryTimeouts</a>);
  376. <a name="l00345"></a>00345 <span class="keywordflow">if</span> (!<a class="code" href="classoversim_1_1Nice.html#a974f1212dc063af0d943b5fa350cc57a">tempResolver</a>.<a class="code" href="classTransportAddress.html#a026e777c423ff2a0280edd2fa5472e74" title="indicates if TransportAddress is specified">isUnspecified</a>() &amp;&amp;
  377. <a name="l00346"></a>00346 (<a class="code" href="classoversim_1_1Nice.html#a974f1212dc063af0d943b5fa350cc57a">tempResolver</a> == <a class="code" href="classoversim_1_1Nice.html#a28c155327e18edb17d6ab2a4c67cf0a8">RendevouzPoint</a> ||
  378. <a name="l00347"></a>00347 (!<a class="code" href="classoversim_1_1Nice.html#ac00b0f8d11b8f3f7c3e5c2eb78511cc6">polledRendevouzPoint</a>.<a class="code" href="classTransportAddress.html#a026e777c423ff2a0280edd2fa5472e74" title="indicates if TransportAddress is specified">isUnspecified</a>() &amp;&amp; <a class="code" href="classoversim_1_1Nice.html#a974f1212dc063af0d943b5fa350cc57a">tempResolver</a> == <a class="code" href="classoversim_1_1Nice.html#ac00b0f8d11b8f3f7c3e5c2eb78511cc6">polledRendevouzPoint</a>))) {
  379. <a name="l00348"></a>00348 <a class="code" href="classoversim_1_1Nice.html#a6acafcf8008939d12f8db7e002a2ebb5">Query</a>(<a class="code" href="classoversim_1_1Nice.html#a28c155327e18edb17d6ab2a4c67cf0a8">RendevouzPoint</a>, <a class="code" href="classoversim_1_1Nice.html#a46807673c62fb160eaf202a0eac29058">joinLayer</a>);
  380. <a name="l00349"></a>00349 }
  381. <a name="l00350"></a>00350 <span class="keywordflow">else</span> {
  382. <a name="l00351"></a>00351 <a class="code" href="classoversim_1_1Nice.html#a6acafcf8008939d12f8db7e002a2ebb5">Query</a>(<a class="code" href="classoversim_1_1Nice.html#a974f1212dc063af0d943b5fa350cc57a">tempResolver</a>, <a class="code" href="classoversim_1_1Nice.html#a46807673c62fb160eaf202a0eac29058">joinLayer</a>);
  383. <a name="l00352"></a>00352 }
  384. <a name="l00353"></a>00353
  385. <a name="l00354"></a>00354 }
  386. <a name="l00355"></a>00355 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (msg-&gt;isName(<span class="stringliteral">&quot;rpPollTimer&quot;</span>)) {
  387. <a name="l00356"></a>00356
  388. <a name="l00357"></a>00357 <a class="code" href="classoversim_1_1Nice.html#ac1b9865b490cf352d83680020939c270">pollRP</a>(-1);
  389. <a name="l00358"></a>00358
  390. <a name="l00359"></a>00359 }
  391. <a name="l00360"></a>00360
  392. <a name="l00361"></a>00361 } <span class="comment">// handleTimerEvent</span>
  393. <a name="l00362"></a>00362
  394. <a name="l00363"></a>00363
  395. <a name="l00364"></a>00364 <span class="comment">/******************************************************************************</span>
  396. <a name="l00365"></a>00365 <span class="comment"> * handleUDPMessage</span>
  397. <a name="l00366"></a><a class="code" href="classoversim_1_1Nice.html#aa7b0abef7e007a2a032614cd1e5be597">00366</a> <span class="comment"> * see BaseOverlay.h</span>
  398. <a name="l00367"></a>00367 <span class="comment"> */</span>
  399. <a name="l00368"></a>00368 <span class="keywordtype">void</span> <a class="code" href="classoversim_1_1Nice.html#aa7b0abef7e007a2a032614cd1e5be597" title="Processes messages from underlay.">Nice::handleUDPMessage</a>(<a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>* msg)
  400. <a name="l00369"></a>00369 {
  401. <a name="l00370"></a>00370
  402. <a name="l00371"></a>00371 <span class="comment">// try message cast to NICE base message</span>
  403. <a name="l00372"></a>00372 <span class="keywordflow">if</span> (dynamic_cast&lt;NiceMessage*&gt;(msg) != NULL) {
  404. <a name="l00373"></a>00373
  405. <a name="l00374"></a>00374 <a class="code" href="classNiceMessage.html" title="Class generated from overlay/nice/NiceMessage.msg by opp_msgc.">NiceMessage</a>* niceMsg = check_and_cast&lt;<a class="code" href="classNiceMessage.html" title="Class generated from overlay/nice/NiceMessage.msg by opp_msgc.">NiceMessage</a>*&gt;(msg);
  406. <a name="l00375"></a>00375
  407. <a name="l00376"></a>00376 <span class="comment">// First of all, update activity information for sourcenode</span>
  408. <a name="l00377"></a>00377 std::map&lt;TransportAddress, NicePeerInfo*&gt;::iterator it = <a class="code" href="classoversim_1_1Nice.html#abfd784a7eb10c0af88d835308cf66ff6">peerInfos</a>.find(niceMsg-&gt;<a class="code" href="classNiceMessage.html#aecd3c064af0f390ca24b0364f8490e36">getSrcNode</a>());
  409. <a name="l00378"></a>00378
  410. <a name="l00379"></a>00379 <span class="keywordflow">if</span> (it != <a class="code" href="classoversim_1_1Nice.html#abfd784a7eb10c0af88d835308cf66ff6">peerInfos</a>.end()) {
  411. <a name="l00380"></a>00380
  412. <a name="l00381"></a>00381 it-&gt;second-&gt;touch();
  413. <a name="l00382"></a>00382
  414. <a name="l00383"></a>00383 }
  415. <a name="l00384"></a>00384
  416. <a name="l00385"></a>00385 <span class="comment">/* Dispatch message, possibly downcasting to a more concrete type */</span>
  417. <a name="l00386"></a>00386 <span class="keywordflow">switch</span> (niceMsg-&gt;<a class="code" href="classNiceMessage.html#a3569492f722da94c494a21014e51240f">getCommand</a>()) {
  418. <a name="l00387"></a>00387
  419. <a name="l00388"></a>00388 <span class="comment">/* More concrete types, to which the message is cast if needed */</span>
  420. <a name="l00389"></a>00389 <a class="code" href="classNiceMemberMessage.html" title="Class generated from overlay/nice/NiceMessage.msg by opp_msgc.">NiceMemberMessage</a>* queryRspMsg;
  421. <a name="l00390"></a>00390 <a class="code" href="classNiceClusterMerge.html" title="Class generated from overlay/nice/NiceMessage.msg by opp_msgc.">NiceClusterMerge</a>* mergeMsg;
  422. <a name="l00391"></a>00391 <a class="code" href="classNiceMulticastMessage.html" title="Class generated from overlay/nice/NiceMessage.msg by opp_msgc.">NiceMulticastMessage</a>* multicastMsg;
  423. <a name="l00392"></a>00392
  424. <a name="l00393"></a>00393 <span class="keywordflow">case</span> <a class="code" href="NiceMessage__m_8h.html#a53eb6ab4c3521dbc1b971f43f68001e7a8d5e84b5d60df22479df8355d6347834">NICE_QUERY</a>:
  425. <a name="l00394"></a>00394
  426. <a name="l00395"></a>00395 <a class="code" href="classoversim_1_1Nice.html#afeb7081be1f7f76b2108aad45c49abfe">handleNiceQuery</a>(niceMsg);
  427. <a name="l00396"></a>00396
  428. <a name="l00397"></a>00397 <span class="keywordflow">break</span>;
  429. <a name="l00398"></a>00398
  430. <a name="l00399"></a>00399 <span class="keywordflow">case</span> <a class="code" href="NiceMessage__m_8h.html#a53eb6ab4c3521dbc1b971f43f68001e7a0ee562452c946bccf6069ac9e42b066e">NICE_QUERY_RESPONSE</a>:
  431. <a name="l00400"></a>00400
  432. <a name="l00401"></a>00401 queryRspMsg = check_and_cast&lt;<a class="code" href="classNiceMemberMessage.html" title="Class generated from overlay/nice/NiceMessage.msg by opp_msgc.">NiceMemberMessage</a>*&gt;(niceMsg);
  433. <a name="l00402"></a>00402 <a class="code" href="classoversim_1_1Nice.html#ab36bfc01b3cd042da92e1b27782ce7bd">handleNiceQueryResponse</a>(queryRspMsg);
  434. <a name="l00403"></a>00403
  435. <a name="l00404"></a>00404 <span class="keywordflow">break</span>;
  436. <a name="l00405"></a>00405
  437. <a name="l00406"></a>00406 <span class="keywordflow">case</span> <a class="code" href="NiceMessage__m_8h.html#a53eb6ab4c3521dbc1b971f43f68001e7a6fd9bbfeec6702e13ecfa8ddf57fa018">NICE_JOIN_CLUSTER</a>:
  438. <a name="l00407"></a>00407
  439. <a name="l00408"></a>00408 <a class="code" href="classoversim_1_1Nice.html#a0757be556541e2d8efd235be889f2ab6">handleNiceJoinCluster</a>(niceMsg);
  440. <a name="l00409"></a>00409
  441. <a name="l00410"></a>00410 <span class="keywordflow">break</span>;
  442. <a name="l00411"></a>00411
  443. <a name="l00412"></a>00412 <span class="keywordflow">case</span> <a class="code" href="NiceMessage__m_8h.html#a53eb6ab4c3521dbc1b971f43f68001e7a8bf3ffec79cbd15ef9c801ec8fdcc1db">NICE_POLL_RP</a>:
  444. <a name="l00413"></a>00413
  445. <a name="l00414"></a>00414 <a class="code" href="classoversim_1_1Nice.html#a10494e710344144e515c7e22b83e786c">handleNicePollRp</a>(niceMsg);
  446. <a name="l00415"></a>00415
  447. <a name="l00416"></a>00416 <span class="keywordflow">break</span>;
  448. <a name="l00417"></a>00417
  449. <a name="l00418"></a>00418 <span class="keywordflow">case</sp

Large files files are truncated, but you can click here to view the full file