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.

257 lines
7.5 KiB

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