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.

230 lines
5.7 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CNodeConfig.cpp
  7. //
  8. // Description:
  9. // Contains the definition of the CNodeConfig class.
  10. //
  11. // Maintained By:
  12. // David Potter (DavidP) 14-JU-2001
  13. // Vij Vasu (Vvasu) 08-MAR-2000
  14. //
  15. //////////////////////////////////////////////////////////////////////////////
  16. //////////////////////////////////////////////////////////////////////////////
  17. // Include Files
  18. //////////////////////////////////////////////////////////////////////////////
  19. // The precompiled header.
  20. #include "Pch.h"
  21. // The header for this file
  22. #include "CNodeConfig.h"
  23. // For the CBaseClusterAddNode class.
  24. #include "CBaseClusterAddNode.h"
  25. //////////////////////////////////////////////////////////////////////////////
  26. //++
  27. //
  28. // CNodeConfig::CNodeConfig
  29. //
  30. // Description:
  31. // Constructor of the CNodeConfig class
  32. //
  33. // Arguments:
  34. // pbcanParentActionIn
  35. // Pointer to the base cluster action of which this action is a part.
  36. //
  37. // Return Value:
  38. // None.
  39. //
  40. // Exceptions Thrown:
  41. // Any exceptions thrown by underlying functions
  42. //
  43. //--
  44. //////////////////////////////////////////////////////////////////////////////
  45. CNodeConfig::CNodeConfig(
  46. CBaseClusterAddNode * pbcanParentActionIn
  47. )
  48. : CNode( pbcanParentActionIn )
  49. {
  50. TraceFunc( "" );
  51. // Indicate that action can be rolled back.
  52. SetRollbackPossible( true );
  53. TraceFuncExit();
  54. } //*** CNodeConfig::CNodeConfig
  55. //////////////////////////////////////////////////////////////////////////////
  56. //++
  57. //
  58. // CNodeConfig::~CNodeConfig
  59. //
  60. // Description:
  61. // Destructor of the CNodeConfig class.
  62. //
  63. // Arguments:
  64. // None.
  65. //
  66. // Return Value:
  67. // None.
  68. //
  69. // Exceptions Thrown:
  70. // Any exceptions thrown by underlying functions
  71. //
  72. //--
  73. //////////////////////////////////////////////////////////////////////////////
  74. CNodeConfig::~CNodeConfig( void )
  75. {
  76. TraceFunc( "" );
  77. TraceFuncExit();
  78. } //*** CNodeConfig::~CNodeConfig
  79. //////////////////////////////////////////////////////////////////////////////
  80. //++
  81. //
  82. // CNodeConfig::Commit
  83. //
  84. // Description:
  85. // Perform the node specific configuration steps.
  86. //
  87. // Arguments:
  88. // None.
  89. //
  90. // Return Value:
  91. // None.
  92. //
  93. // Exceptions Thrown:
  94. // Any that are thrown by the contained actions.
  95. //
  96. //--
  97. //////////////////////////////////////////////////////////////////////////////
  98. void
  99. CNodeConfig::Commit( void )
  100. {
  101. TraceFunc( "" );
  102. CStatusReport srConfigNode(
  103. PbcaGetParent()->PBcaiGetInterfacePointer()
  104. , TASKID_Major_Configure_Cluster_Services
  105. , TASKID_Minor_Configuring_Cluster_Node
  106. , 0, 1
  107. , IDS_TASK_CONFIG_NODE
  108. );
  109. // Get the parent action pointer.
  110. CBaseClusterAddNode * pcanClusterAddNode = dynamic_cast< CBaseClusterAddNode *>( PbcaGetParent() );
  111. // If the parent action of this action is not CBaseClusterForm
  112. if ( pcanClusterAddNode == NULL )
  113. {
  114. THROW_ASSERT( E_POINTER, "The parent action of this action is not CBaseClusterAddNode." );
  115. } // an invalid pointer was passed in.
  116. // Call the base class commit method.
  117. BaseClass::Commit();
  118. // Send the next step of this status report.
  119. srConfigNode.SendNextStep( S_OK );
  120. try
  121. {
  122. LogMsg( "[BC] Making miscellaneous changes to the node." );
  123. // Configure the node.
  124. Configure( pcanClusterAddNode->RStrGetClusterName() );
  125. } // try:
  126. catch( ... )
  127. {
  128. // If we are here, then something went wrong with the configuration.
  129. LogMsg( "[BC] Caught exception during commit." );
  130. //
  131. // Cleanup anything that the failed commit might have done.
  132. // Catch any exceptions thrown during Cleanup to make sure that there
  133. // is no collided unwind.
  134. //
  135. try
  136. {
  137. Cleanup();
  138. }
  139. catch( ... )
  140. {
  141. //
  142. // The rollback of the committed action has failed.
  143. // There is nothing that we can do.
  144. // We certainly cannot rethrow this exception, since
  145. // the exception that caused the rollback is more important.
  146. //
  147. TW32( ERROR_CLUSCFG_ROLLBACK_FAILED );
  148. LogMsg( "[BC] THIS COMPUTER MAY BE IN AN INVALID STATE. Caught an exception during cleanup." );
  149. } // catch: all
  150. // Rethrow the exception thrown by commit.
  151. throw;
  152. } // catch: all
  153. // If we are here, then everything went well.
  154. SetCommitCompleted( true );
  155. // Send the last step of this status report.
  156. srConfigNode.SendNextStep( S_OK );
  157. TraceFuncExit();
  158. } //*** CNodeConfig::Commit
  159. //////////////////////////////////////////////////////////////////////////////
  160. //++
  161. //
  162. // CNodeConfig::Rollback
  163. //
  164. // Description:
  165. // Roll the node back to the state it was in before we tried to
  166. // configure it.
  167. //
  168. // Arguments:
  169. // None.
  170. //
  171. // Return Value:
  172. // None.
  173. //
  174. // Exceptions Thrown:
  175. // Any that are thrown by the underlying functions.
  176. //
  177. //--
  178. //////////////////////////////////////////////////////////////////////////////
  179. void
  180. CNodeConfig::Rollback( void )
  181. {
  182. TraceFunc( "" );
  183. // Call the base class rollback method.
  184. BaseClass::Rollback();
  185. // Bring the node back to its original state.
  186. Cleanup();
  187. SetCommitCompleted( false );
  188. TraceFuncExit();
  189. } //*** CNodeConfig::Rollback