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.

220 lines
5.3 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CClusSvcCreate.cpp
  7. //
  8. // Description:
  9. // Contains the definition of the CClusSvcCreate 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 "CClusSvcCreate.h"
  25. // For the CBaseClusterAddNode class.
  26. #include "CBaseClusterAddNode.h"
  27. //////////////////////////////////////////////////////////////////////////////
  28. //++
  29. //
  30. // CClusSvcCreate::CClusSvcCreate()
  31. //
  32. // Description:
  33. // Constructor of the CClusSvcCreate 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. CClusSvcCreate::CClusSvcCreate(
  48. CBaseClusterAddNode * pbcanParentActionIn
  49. )
  50. : BaseClass( pbcanParentActionIn )
  51. {
  52. BCATraceScope( "" );
  53. SetRollbackPossible( true );
  54. } //*** CClusSvcCreate::CClusSvcCreate()
  55. //////////////////////////////////////////////////////////////////////////////
  56. //++
  57. //
  58. // CClusSvcCreate::~CClusSvcCreate( void )
  59. //
  60. // Description:
  61. // Destructor of the CClusSvcCreate 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. CClusSvcCreate::~CClusSvcCreate( void )
  75. {
  76. BCATraceScope( "" );
  77. } //*** CClusSvcCreate::~CClusSvcCreate()
  78. //////////////////////////////////////////////////////////////////////////////
  79. //++
  80. //
  81. // void
  82. // CClusSvcCreate::Commit( void )
  83. //
  84. // Description:
  85. // Create and start the service.
  86. //
  87. // Arguments:
  88. // None.
  89. //
  90. // Return Value:
  91. // None.
  92. //
  93. // Exceptions Thrown:
  94. // CAssert
  95. // If the base parent of this action is not CBaseClusterAddNode.
  96. //
  97. // Any that are thrown by the contained actions.
  98. //
  99. //--
  100. //////////////////////////////////////////////////////////////////////////////
  101. void
  102. CClusSvcCreate::Commit( void )
  103. {
  104. BCATraceScope( "" );
  105. // Get the parent action pointer.
  106. CBaseClusterAddNode * pcanClusterAddNode = dynamic_cast< CBaseClusterAddNode *>( PbcaGetParent() );
  107. // If the parent action of this action is not CBaseClusterForm
  108. if ( pcanClusterAddNode == NULL )
  109. {
  110. THROW_ASSERT( E_POINTER, "The parent action of this action is not CBaseClusterAddNode." );
  111. } // an invalid pointer was passed in.
  112. // Call the base class commit method.
  113. BaseClass::Commit();
  114. try
  115. {
  116. // Create the service.
  117. ConfigureService(
  118. pcanClusterAddNode->RStrGetServiceDomainAccountName().PszData()
  119. , pcanClusterAddNode->RStrGetServiceAccountPassword().PszData()
  120. , pcanClusterAddNode->PszGetNodeIdString()
  121. , pcanClusterAddNode->FIsVersionCheckingDisabled()
  122. );
  123. } // try:
  124. catch( ... )
  125. {
  126. // If we are here, then something went wrong with the create.
  127. BCATraceMsg( "Caught exception during commit." );
  128. //
  129. // Cleanup anything that the failed create might have done.
  130. // Catch any exceptions thrown during Cleanup to make sure that there
  131. // is no collided unwind.
  132. //
  133. try
  134. {
  135. CleanupService();
  136. }
  137. catch( ... )
  138. {
  139. //
  140. // The rollback of the committed action has failed.
  141. // There is nothing that we can do.
  142. // We certainly cannot rethrow this exception, since
  143. // the exception that caused the rollback is more important.
  144. //
  145. THR( E_UNEXPECTED );
  146. BCATraceMsg( "Caught exception during cleanup." );
  147. LogMsg( "THIS COMPUTER MAY BE IN AN INVALID STATE. An error has occurred during cleanup." );
  148. } // catch: all
  149. // Rethrow the exception thrown by commit.
  150. throw;
  151. } // catch: all
  152. // If we are here, then everything went well.
  153. SetCommitCompleted( true );
  154. } //*** CClusSvcCreate::Commit()
  155. //////////////////////////////////////////////////////////////////////////////
  156. //++
  157. //
  158. // void
  159. // CClusSvcCreate::Rollback( void )
  160. //
  161. // Description:
  162. // Cleanup the service.
  163. //
  164. // Arguments:
  165. // None.
  166. //
  167. // Return Value:
  168. // None.
  169. //
  170. // Exceptions Thrown:
  171. // Any that are thrown by the underlying functions.
  172. //
  173. //--
  174. //////////////////////////////////////////////////////////////////////////////
  175. void
  176. CClusSvcCreate::Rollback( void )
  177. {
  178. BCATraceScope( "" );
  179. // Call the base class rollback method.
  180. BaseClass::Rollback();
  181. // Cleanup the service.
  182. CleanupService();
  183. SetCommitCompleted( false );
  184. } //*** CClusSvcCreate::Rollback()