Leaked source code of windows server 2003
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.

124 lines
2.7 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 "precomp.h"
  11. #pragma hdrstop
  12. #include "private.h"
  13. // done
  14. // constructor
  15. //
  16. PortDataX::PortDataX( long startPort,
  17. long endPort,
  18. Protocol trafficToHandle,
  19. bool equal,
  20. long load,
  21. Affinity affinity,
  22. long priority)
  23. : _startPort( startPort ),
  24. _endPort( endPort ),
  25. _trafficToHandle( trafficToHandle ),
  26. _isEqualLoadBalanced( equal ),
  27. _affinity( affinity ),
  28. _priority( priority ),
  29. _key( startPort )
  30. {}
  31. // done
  32. // default constructor
  33. //
  34. PortDataX::PortDataX()
  35. :_startPort( 0 ),
  36. _endPort( 65535 ),
  37. _trafficToHandle( both ),
  38. _key( 0 )
  39. {}
  40. // done
  41. // equality operator
  42. bool
  43. PortDataX::operator==(const PortDataX& objToCompare ) const
  44. {
  45. if( (_startPort == objToCompare._startPort )
  46. &&
  47. (_endPort == objToCompare._endPort )
  48. &&
  49. (_trafficToHandle == objToCompare._trafficToHandle )
  50. )
  51. {
  52. return true;
  53. }
  54. else
  55. {
  56. return false;
  57. }
  58. }
  59. // done
  60. // inequality operator
  61. bool
  62. PortDataX::operator!=(const PortDataX& objToCompare ) const
  63. {
  64. return !( *this == objToCompare );
  65. }
  66. set<long>
  67. PortDataX::getAvailablePriorities()
  68. {
  69. set<long> availablePriorities;
  70. // initially make all available.
  71. for( int i = 1; i <= WLBS_MAX_HOSTS; ++i )
  72. {
  73. availablePriorities.insert( i );
  74. }
  75. // remove priorities not available.
  76. map<_bstr_t, long>::iterator top;
  77. for( top = machineMapToPriority.begin();
  78. top != machineMapToPriority.end();
  79. ++top )
  80. {
  81. availablePriorities.erase( (*top).second );
  82. }
  83. return availablePriorities;
  84. }
  85. // getAvailableHostIDS
  86. //
  87. set<int>
  88. ClusterData::getAvailableHostIDS()
  89. {
  90. set<int> availableHostIDS;
  91. // initially make all available.
  92. for( int i = 1; i <= WLBS_MAX_HOSTS; ++i )
  93. {
  94. availableHostIDS.insert( i );
  95. }
  96. // remove host ids not available.
  97. map<_bstr_t, HostData>::iterator top;
  98. for( top = hosts.begin(); top != hosts.end(); ++top )
  99. {
  100. availableHostIDS.erase( (*top).second.hp.hID );
  101. }
  102. return availableHostIDS;
  103. }