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.

258 lines
7.6 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CBaseClusterCleanup.cpp
  7. //
  8. // Description:
  9. // Contains the definition of the CBaseClusterCleanup class.
  10. //
  11. // Maintained By:
  12. // David Potter (DavidP) 14-JUN-2001
  13. // Vij Vasu (Vvasu) 30-APR-2000
  14. //
  15. //////////////////////////////////////////////////////////////////////////////
  16. //////////////////////////////////////////////////////////////////////////////
  17. // Include Files
  18. //////////////////////////////////////////////////////////////////////////////
  19. // The precompiled header.
  20. #include "Pch.h"
  21. // The header file of this class.
  22. #include "CBaseClusterCleanup.h"
  23. // For the CBCAInterface class.
  24. #include "CBCAInterface.h"
  25. // For the CClusSvcCleanup action
  26. #include "CClusSvcCleanup.h"
  27. // For the CClusDBCleanup action
  28. #include "CClusDBCleanup.h"
  29. // For the CClusDiskCleanup action
  30. #include "CClusDiskCleanup.h"
  31. // For the CClusNetCleanup action
  32. #include "CClusNetCleanup.h"
  33. // For the CNodeCleanup action
  34. #include "CNodeCleanup.h"
  35. //////////////////////////////////////////////////////////////////////////////
  36. //++
  37. //
  38. // CBaseClusterCleanup::CBaseClusterCleanup
  39. //
  40. // Description:
  41. // Constructor of the CBaseClusterCleanup class.
  42. //
  43. // This function also stores the parameters that are required for
  44. // cluster cleanup.
  45. //
  46. // This function also checks if the computer is in the correct state
  47. // for cleanup.
  48. //
  49. // Arguments:
  50. // pbcaiInterfaceIn
  51. // Pointer to the interface class for this library.
  52. //
  53. // Return Value:
  54. // None.
  55. //
  56. // Exceptions Thrown:
  57. // CConfigError
  58. // If the OS version is incorrect or if the installation state.
  59. //
  60. // CRuntimeError
  61. // If any of the APIs fail.
  62. //
  63. //--
  64. //////////////////////////////////////////////////////////////////////////////
  65. CBaseClusterCleanup::CBaseClusterCleanup(
  66. CBCAInterface * pbcaiInterfaceIn
  67. )
  68. : BaseClass( pbcaiInterfaceIn )
  69. {
  70. TraceFunc( "" );
  71. LogMsg( "[BC] The current cluster configuration task is: Node Cleanup." );
  72. // Check if the installation state of the cluster binaries is correct.
  73. {
  74. eClusterInstallState ecisInstallState;
  75. DWORD sc = TW32( ClRtlGetClusterInstallState( NULL, &ecisInstallState ) );
  76. if ( sc != ERROR_SUCCESS )
  77. {
  78. LogMsg( "[BC] Error %#08x occurred trying to get cluster installation state. Throwing an exception.", sc );
  79. THROW_RUNTIME_ERROR( HRESULT_FROM_WIN32( sc ), IDS_ERROR_GETTING_INSTALL_STATE );
  80. } // if: there was a problem getting the cluster installation state
  81. LogMsg(
  82. "[BC] Current install state = %d. Required %d or %d."
  83. , ecisInstallState
  84. , eClusterInstallStateConfigured
  85. , eClusterInstallStateUpgraded
  86. );
  87. //
  88. // The installation state for this node to be cleaned up should be that the cluster service
  89. // has been configured or that it has been upgraded.
  90. //
  91. if ( ( ecisInstallState != eClusterInstallStateConfigured ) && ( ecisInstallState != eClusterInstallStateUpgraded ) )
  92. {
  93. LogMsg( "[BC] The cluster installation state is set to %d. Expected %d or %d. Cannot proceed (throwing an exception).", ecisInstallState, eClusterInstallStateConfigured, eClusterInstallStateUpgraded );
  94. THROW_CONFIG_ERROR( HRESULT_FROM_WIN32( TW32( ERROR_INVALID_STATE ) ), IDS_ERROR_INCORRECT_INSTALL_STATE );
  95. } // if: the installation state is not correct
  96. LogMsg( "[BC] The cluster installation state is correct. Configuration can proceed." );
  97. }
  98. //
  99. // Create a list of actions to be performed.
  100. // The order of appending actions is significant.
  101. //
  102. // Add the action to clean up the ClusNet service.
  103. // The ClusNet service depends on the ClusSvc service and therefore cannot be
  104. // stopped if the ClusSvc service is running. So, the ClusSvc service should not be
  105. // running when the Commit() method of this class is called.
  106. RalGetActionList().AppendAction( new CClusNetCleanup( this ) );
  107. // Add the action to clean up the ClusDisk service.
  108. RalGetActionList().AppendAction( new CClusDiskCleanup( this ) );
  109. // Add the action to clean up the cluster database.
  110. RalGetActionList().AppendAction( new CClusDBCleanup( this ) );
  111. // Add the action to clean up miscellenous actions we performed when this node joined the cluster.
  112. RalGetActionList().AppendAction( new CNodeCleanup( this ) );
  113. // Add the action to clean up the cluster service. Clean this up last for two reasons:
  114. // 1. The install state is changed by this action.
  115. // 2. If cleanup aborted for some reason and the cluster service is not deleted, it will
  116. // reinitiate cleanup the next time it starts.
  117. RalGetActionList().AppendAction( new CClusSvcCleanup( this ) );
  118. // Indicate if this action can be rolled back or not.
  119. SetRollbackPossible( RalGetActionList().FIsRollbackPossible() );
  120. // Indicate that a node should be cleaned up during commit.
  121. SetAction( eCONFIG_ACTION_CLEANUP );
  122. LogMsg( "[BC] Initialization for node cleanup complete." );
  123. TraceFuncExit();
  124. } //*** CBaseClusterCleanup::CBaseClusterCleanup
  125. //////////////////////////////////////////////////////////////////////////////
  126. //++
  127. //
  128. // CBaseClusterCleanup::~CBaseClusterCleanup
  129. //
  130. // Description:
  131. // Destructor of the CBaseClusterCleanup class
  132. //
  133. // Arguments:
  134. // None.
  135. //
  136. // Return Value:
  137. // None.
  138. //
  139. // Exceptions Thrown:
  140. // None.
  141. //
  142. //--
  143. //////////////////////////////////////////////////////////////////////////////
  144. CBaseClusterCleanup::~CBaseClusterCleanup( void ) throw()
  145. {
  146. TraceFunc( "" );
  147. TraceFuncExit();
  148. } //*** CBaseClusterCleanup::~CBaseClusterCleanup
  149. //////////////////////////////////////////////////////////////////////////////
  150. //++
  151. //
  152. // CBaseClusterCleanup::Commit
  153. //
  154. // Description:
  155. // Clean up this node. This function cannot be called when the cluster
  156. // service is running.
  157. //
  158. // Arguments:
  159. // None.
  160. //
  161. // Return Value:
  162. // None.
  163. //
  164. // Exceptions Thrown:
  165. // CRuntimeError
  166. // If any of the APIs fail.
  167. //
  168. // Any exceptions thrown by functions called.
  169. //
  170. //--
  171. //////////////////////////////////////////////////////////////////////////////
  172. void
  173. CBaseClusterCleanup::Commit( void )
  174. {
  175. TraceFunc( "" );
  176. LogMsg( "[BC] Initiating cluster node cleanup." );
  177. // Call the base class commit routine. This commits the action list.
  178. BaseClass::Commit();
  179. // If we are here, then everything went well.
  180. SetCommitCompleted( true );
  181. TraceFuncExit();
  182. } //*** CBaseClusterCleanup::Commit
  183. //////////////////////////////////////////////////////////////////////////////
  184. //++
  185. //
  186. // CBaseClusterCleanup::Rollback
  187. //
  188. // Description:
  189. // Performs the rolls back of the action committed by this object.
  190. //
  191. // Arguments:
  192. // None.
  193. //
  194. // Return Value:
  195. // None.
  196. //
  197. // Exceptions Thrown:
  198. // Any exceptions thrown by functions called.
  199. //
  200. //--
  201. //////////////////////////////////////////////////////////////////////////////
  202. void
  203. CBaseClusterCleanup::Rollback( void )
  204. {
  205. TraceFunc( "" );
  206. // Rollback the actions.
  207. BaseClass::Rollback();
  208. SetCommitCompleted( false );
  209. TraceFuncExit();
  210. } //*** CBaseClusterCleanup::Rollback