Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

262 lines
5.8 KiB

  1. // Copyright (c) Microsoft. All rights reserved.
  2. //
  3. // This is unpublished source code of Microsoft.
  4. // The copyright notice above does not evidence any
  5. // actual or intended publication of such source code.
  6. // OneLiner : Implementation of MNLBCluster
  7. // DevUnit : wlbstest
  8. // Author : Murtaza Hakim
  9. // include files
  10. #include "MNLBUIData.h"
  11. #include "wlbsctrl.h"
  12. // PortDataULB default constructor
  13. //
  14. PortDataULB::PortDataULB()
  15. :
  16. MNLBPortRuleLoadBalanced()
  17. {
  18. _isEqualLoadBalanced = false;
  19. }
  20. // PortDataULB constructor
  21. //
  22. PortDataULB::PortDataULB( long startPort,
  23. long endPort,
  24. Protocol trafficToHandle,
  25. Affinity affinity )
  26. :
  27. MNLBPortRuleLoadBalanced( startPort,
  28. endPort,
  29. trafficToHandle,
  30. false,
  31. 0,
  32. affinity )
  33. {
  34. }
  35. // PortDataELB default constructor
  36. //
  37. PortDataELB::PortDataELB()
  38. :
  39. MNLBPortRuleLoadBalanced()
  40. {
  41. }
  42. // PortDataELB constructor
  43. //
  44. PortDataELB::PortDataELB( long startPort,
  45. long endPort,
  46. Protocol trafficToHandle,
  47. Affinity affinity )
  48. :
  49. MNLBPortRuleLoadBalanced( startPort,
  50. endPort,
  51. trafficToHandle,
  52. true,
  53. 0,
  54. affinity )
  55. {
  56. }
  57. bool
  58. PortDataELB::operator==( const PortDataELB& objToCompare )
  59. {
  60. return MNLBPortRuleLoadBalanced::operator==( objToCompare );
  61. }
  62. bool
  63. PortDataELB::operator!=( const PortDataELB& objToCompare )
  64. {
  65. return !operator==( objToCompare );
  66. }
  67. // PortDataF default constructor
  68. //
  69. PortDataF::PortDataF()
  70. :
  71. MNLBPortRuleFailover()
  72. {
  73. }
  74. // PortDataF constructor
  75. //
  76. PortDataF::PortDataF( long startPort,
  77. long endPort,
  78. Protocol trafficToHandle )
  79. :
  80. MNLBPortRuleFailover( startPort,
  81. endPort,
  82. trafficToHandle,
  83. 0 )
  84. {
  85. }
  86. // PortDataD default constructor
  87. //
  88. PortDataD::PortDataD()
  89. :
  90. MNLBPortRuleDisabled()
  91. {
  92. }
  93. // PortDataD constructor
  94. //
  95. PortDataD::PortDataD( long startPort,
  96. long endPort,
  97. Protocol trafficToHandle )
  98. :
  99. MNLBPortRuleDisabled( startPort,
  100. endPort,
  101. trafficToHandle )
  102. {
  103. }
  104. // equality
  105. //
  106. bool
  107. PortDataD::operator==( const PortDataD& objToCompare )
  108. {
  109. return MNLBPortRuleDisabled::operator==( objToCompare );
  110. }
  111. // inequality
  112. //
  113. bool
  114. PortDataD::operator!=( const PortDataD& objToCompare )
  115. {
  116. return !operator==( objToCompare );
  117. }
  118. // getAvailableHostIDS
  119. //
  120. set<int>
  121. ClusterData::getAvailableHostIDS()
  122. {
  123. set<int> availableHostIDS;
  124. // initially make all available.
  125. for( int i = 1; i <= WLBS_MAX_HOSTS; ++i )
  126. {
  127. availableHostIDS.insert( i );
  128. }
  129. // remove host ids not available.
  130. map<_bstr_t, HostData>::iterator top;
  131. for( top = hosts.begin(); top != hosts.end(); ++top )
  132. {
  133. availableHostIDS.erase( (*top).second.hp.hID );
  134. }
  135. return availableHostIDS;
  136. }
  137. set<long>
  138. PortDataF::getAvailablePriorities()
  139. {
  140. set<long> availablePriorities;
  141. // initially make all available.
  142. for( int i = 1; i <= WLBS_MAX_HOSTS; ++i )
  143. {
  144. availablePriorities.insert( i );
  145. }
  146. // remove priorities not available.
  147. map<_bstr_t, long>::iterator top;
  148. for( top = machineMapToPriority.begin();
  149. top != machineMapToPriority.end();
  150. ++top )
  151. {
  152. availablePriorities.erase( (*top).second );
  153. }
  154. return availablePriorities;
  155. }
  156. void
  157. ClusterData::dump()
  158. {
  159. map< _bstr_t, HostData>::iterator topHost;
  160. for( topHost = hosts.begin();
  161. topHost != hosts.end();
  162. ++topHost )
  163. {
  164. _bstr_t hostName = (*topHost).first;
  165. HostProperties hp = (*topHost).second.hp;
  166. _bstr_t connectionIP = (*topHost).second.connectionIP;
  167. }
  168. map< long, PortDataELB>::iterator topELB;
  169. for( topELB = portELB.begin();
  170. topELB != portELB.end();
  171. ++topELB )
  172. {
  173. long startport = (*topELB).first;
  174. PortDataELB portDataELB = (*topELB).second;
  175. }
  176. map< long, PortDataD>::iterator topD;
  177. for( topD = portD.begin();
  178. topD != portD.end();
  179. ++topD )
  180. {
  181. long startport = (*topD).first;
  182. PortDataD portDataD = (*topD).second;
  183. }
  184. map< long, PortDataULB>::iterator topULB;
  185. for( topULB = portULB.begin();
  186. topULB != portULB.end();
  187. ++topULB )
  188. {
  189. long startport = (*topULB).first;
  190. PortDataULB portDataULB = (*topULB).second;
  191. map< _bstr_t, long >::iterator topLW;
  192. for( topLW = (*topULB).second.machineMapToLoadWeight.begin();
  193. topLW != (*topULB).second.machineMapToLoadWeight.end();
  194. ++topLW )
  195. {
  196. _bstr_t machineName = (*topLW).first;
  197. long loadWeight = (*topLW).second;
  198. }
  199. }
  200. map< long, PortDataF>::iterator topF;
  201. for( topF = portF.begin();
  202. topF != portF.end();
  203. ++topF )
  204. {
  205. long startport = (*topF).first;
  206. PortDataF portDataF = (*topF).second;
  207. map< _bstr_t, long >::iterator topP;
  208. for( topP = (*topF).second.machineMapToPriority.begin();
  209. topP != (*topF).second.machineMapToPriority.end();
  210. ++topP )
  211. {
  212. _bstr_t machineName = (*topP).first;
  213. long loadWeight = (*topP).second;
  214. }
  215. }
  216. }