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.

213 lines
3.9 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 "MNLBCluster.h"
  11. #include "MWmiParameter.h"
  12. #include "MTrace.h"
  13. #include "WTokens.h"
  14. #include "wlbsctrl.h"
  15. #include "Common.h"
  16. #include "MNLBExe.h"
  17. #include <iostream>
  18. using namespace std;
  19. // constructor
  20. //
  21. MNLBCluster::MNLBCluster( _bstr_t cip )
  22. :
  23. m_clusterIP( cip ),
  24. m_pMachine( new MNLBMachine( cip, cip ) )
  25. {
  26. TRACE(MTrace::INFO, L"mnlbcluster constructor\n" );
  27. }
  28. // default constructor
  29. //
  30. // note that default constructor is purposely left undefined.
  31. // NO one should be using it. It is declared just for vector class usage.
  32. // copy constructor
  33. //
  34. MNLBCluster::MNLBCluster( const MNLBCluster& mcluster )
  35. :
  36. m_clusterIP( mcluster.m_clusterIP ),
  37. m_pMachine( m_pMachine )
  38. {
  39. TRACE(MTrace::INFO, L"mnlbcluster copy constructor\n" );
  40. }
  41. // assignment operator
  42. //
  43. MNLBCluster&
  44. MNLBCluster::operator=( const MNLBCluster& rhs )
  45. {
  46. m_clusterIP = rhs.m_clusterIP;
  47. m_pMachine = rhs.m_pMachine;
  48. TRACE(MTrace::INFO, L"mnlbcluster assignment operator\n" );
  49. return *this;
  50. }
  51. // destructor
  52. //
  53. MNLBCluster::~MNLBCluster()
  54. {
  55. TRACE(MTrace::INFO, L"mlbcluster destructor\n" );
  56. }
  57. // getClusterProperties
  58. //
  59. MNLBCluster::MNLBCluster_Error
  60. MNLBCluster::getClusterProperties( ClusterProperties* cp )
  61. {
  62. m_pMachine->getClusterProperties( cp );
  63. return MNLBCluster_SUCCESS;
  64. }
  65. // getHosts
  66. //
  67. MNLBCluster::MNLBCluster_Error
  68. MNLBCluster::getHosts( vector<MNLBHost>* hosts )
  69. {
  70. vector< MNLBMachine::HostInfo > hostInfoStore;
  71. m_pMachine->getPresentHostsInfo( &hostInfoStore );
  72. for( int i = 0; i < hostInfoStore.size(); ++i )
  73. {
  74. hosts->push_back( MNLBHost( m_clusterIP,
  75. hostInfoStore[i].hostID ) );
  76. }
  77. return MNLBCluster_SUCCESS;
  78. }
  79. // start
  80. //
  81. MNLBCluster::MNLBCluster_Error
  82. MNLBCluster::start( unsigned long* retVal )
  83. {
  84. m_pMachine->start( Common::ALL_HOSTS, retVal );
  85. return MNLBCluster_SUCCESS;
  86. }
  87. // stop
  88. //
  89. MNLBCluster::MNLBCluster_Error
  90. MNLBCluster::stop( unsigned long* retVal )
  91. {
  92. m_pMachine->stop( Common::ALL_HOSTS, retVal );
  93. return MNLBCluster_SUCCESS;
  94. }
  95. // resume
  96. //
  97. MNLBCluster::MNLBCluster_Error
  98. MNLBCluster::resume( unsigned long* retVal )
  99. {
  100. m_pMachine->resume( Common::ALL_HOSTS, retVal );
  101. return MNLBCluster_SUCCESS;
  102. }
  103. // suspend
  104. //
  105. MNLBCluster::MNLBCluster_Error
  106. MNLBCluster::suspend( unsigned long* retVal )
  107. {
  108. m_pMachine->suspend( Common::ALL_HOSTS, retVal );
  109. return MNLBCluster_SUCCESS;
  110. }
  111. // drainstop
  112. //
  113. MNLBCluster::MNLBCluster_Error
  114. MNLBCluster::drainstop( unsigned long* retVal )
  115. {
  116. m_pMachine->drainstop( Common::ALL_HOSTS, retVal );
  117. return MNLBCluster_SUCCESS;
  118. }
  119. // enable
  120. //
  121. MNLBCluster::MNLBCluster_Error
  122. MNLBCluster::enable( unsigned long* retVal, unsigned long portToAffect )
  123. {
  124. m_pMachine->enable( Common::ALL_HOSTS, retVal, portToAffect );
  125. return MNLBCluster_SUCCESS;
  126. }
  127. // disable
  128. //
  129. MNLBCluster::MNLBCluster_Error
  130. MNLBCluster::disable( unsigned long* retVal, unsigned long portToAffect )
  131. {
  132. m_pMachine->disable( Common::ALL_HOSTS, retVal, portToAffect );
  133. return MNLBCluster_SUCCESS;
  134. }
  135. // drain
  136. //
  137. MNLBCluster::MNLBCluster_Error
  138. MNLBCluster::drain( unsigned long* retVal, unsigned long portToAffect )
  139. {
  140. m_pMachine->drain( Common::ALL_HOSTS, retVal, portToAffect );
  141. return MNLBCluster_SUCCESS;
  142. }
  143. // refreshConnection
  144. //
  145. MNLBCluster::MNLBCluster_Error
  146. MNLBCluster::refreshConnection()
  147. {
  148. // reestablishing connection.
  149. //
  150. m_pMachine =
  151. auto_ptr<MNLBMachine> (new MNLBMachine( m_clusterIP, m_clusterIP ) );
  152. return MNLBCluster_SUCCESS;
  153. }