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.

228 lines
5.5 KiB

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