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
6.8 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CBaseClusterJoin.h
  7. //
  8. // Description:
  9. // Header file for CBaseClusterJoin class.
  10. //
  11. // The CBaseClusterJoin class is a class that encapsulates the
  12. // action of add a node to a cluster.
  13. //
  14. // Implementation Files:
  15. // CBaseClusterJoin.cpp
  16. //
  17. // Maintained By:
  18. // Vij Vasu (Vvasu) 03-MAR-2000
  19. //
  20. //////////////////////////////////////////////////////////////////////////////
  21. // Make sure that this file is included only once per compile path.
  22. #pragma once
  23. //////////////////////////////////////////////////////////////////////////
  24. // Include Files
  25. //////////////////////////////////////////////////////////////////////////
  26. // For the base class of this class.
  27. #include "CBaseClusterAddNode.h"
  28. // For the CStr class.
  29. #include "CStr.h"
  30. // For a few smart classes
  31. #include "SmartClasses.h"
  32. // For the cluster API functions and types
  33. #include "ClusAPI.h"
  34. // For the CClusSvcAccountConfig action
  35. #include "CClusSvcAccountConfig.h"
  36. //////////////////////////////////////////////////////////////////////////
  37. // Type definitions
  38. //////////////////////////////////////////////////////////////////////////
  39. // Class used to automatically release a RPC binding handle.
  40. class CRPCBindingHandleTrait
  41. {
  42. public:
  43. //////////////////////////////////////////////////////////////////////////
  44. // Public types
  45. //////////////////////////////////////////////////////////////////////////
  46. typedef RPC_BINDING_HANDLE ResourceType;
  47. //////////////////////////////////////////////////////////////////////////
  48. // Public methods
  49. //////////////////////////////////////////////////////////////////////////
  50. // A routine used to close a handle.
  51. static void CloseRoutine( ResourceType hResourceIn )
  52. {
  53. RpcBindingFree( &hResourceIn );
  54. } //*** CloseRoutine()
  55. // Get the null value for this type.
  56. static ResourceType HGetNullValue()
  57. {
  58. return NULL;
  59. } //*** HGetNullValue()
  60. }; //*** class CRPCBindingHandleTrait
  61. // A smart RPC binding handle
  62. typedef CSmartResource< CRPCBindingHandleTrait > SmartRpcBinding;
  63. // Smart handle to a cluster.
  64. typedef CSmartResource<
  65. CHandleTrait<
  66. HCLUSTER
  67. , BOOL
  68. , CloseCluster
  69. , reinterpret_cast< HCLUSTER >( NULL )
  70. >
  71. > SmartClusterHandle;
  72. //////////////////////////////////////////////////////////////////////////////
  73. //++
  74. //
  75. // class CBaseClusterJoin
  76. //
  77. // Description:
  78. // The CBaseClusterJoin class is a class that encapsulates the
  79. // action of add a node to a cluster.
  80. //
  81. //--
  82. //////////////////////////////////////////////////////////////////////////////
  83. class CBaseClusterJoin : public CBaseClusterAddNode
  84. {
  85. public:
  86. //////////////////////////////////////////////////////////////////////////
  87. // Constructors and destructors
  88. //////////////////////////////////////////////////////////////////////////
  89. // Constructor.
  90. CBaseClusterJoin(
  91. CBCAInterface * pbcaiInterfaceIn
  92. , const WCHAR * pcszClusterNameIn
  93. , const WCHAR * pcszClusterBindingStringIn
  94. , const WCHAR * pcszClusterAccountNameIn
  95. , const WCHAR * pcszClusterAccountPwdIn
  96. , const WCHAR * pcszClusterAccountDomainIn
  97. );
  98. // Default destructor.
  99. ~CBaseClusterJoin( void ) throw();
  100. //////////////////////////////////////////////////////////////////////////
  101. // Public accessors
  102. //////////////////////////////////////////////////////////////////////////
  103. // Get the NodeId of this node.
  104. virtual const WCHAR *
  105. PszGetNodeIdString( void ) const throw() { return m_strNodeId.PszData(); }
  106. // Set the NodeId of this node.
  107. void
  108. SetNodeIdString( const WCHAR * pcszNodeIdIn ) { m_strNodeId = pcszNodeIdIn; }
  109. // Get a handle to the cluster service account token.
  110. HANDLE
  111. HGetClusterServiceAccountToken( void ) const throw() { return m_satServiceAccountToken.HHandle(); }
  112. RPC_BINDING_HANDLE
  113. RbhGetJoinBindingHandle( void ) const throw() { return m_srbJoinBinding.HHandle(); }
  114. //////////////////////////////////////////////////////////////////////////
  115. // Public member functions
  116. //////////////////////////////////////////////////////////////////////////
  117. // Join the cluster.
  118. void
  119. Commit( void );
  120. // Rollback a created cluster.
  121. void
  122. Rollback( void );
  123. // Returns the number of progress messages that this action will send.
  124. UINT
  125. UiGetMaxProgressTicks( void ) const throw()
  126. {
  127. // The extra tick if for the "Join starting" notification.
  128. return BaseClass::UiGetMaxProgressTicks() + 1;
  129. }
  130. private:
  131. //////////////////////////////////////////////////////////////////////////
  132. // Private types
  133. //////////////////////////////////////////////////////////////////////////
  134. // The base class of this class
  135. typedef CBaseClusterAddNode BaseClass;
  136. // A smart handle to an account token.
  137. typedef CSmartResource< CHandleTrait< HANDLE, BOOL, CloseHandle > > SmartAccountToken;
  138. // A smart handle to an RPC string.
  139. typedef CSmartResource<
  140. CHandleTrait<
  141. LPWSTR *
  142. , RPC_STATUS
  143. , RpcStringFreeW
  144. , reinterpret_cast< LPWSTR * >( NULL )
  145. >
  146. >
  147. SmartRpcString;
  148. typedef CSmartGenericPtr< CPtrTrait< CClusSvcAccountConfig > > SmartAccountConfigPtr;
  149. //////////////////////////////////////////////////////////////////////////
  150. // Public member functions
  151. //////////////////////////////////////////////////////////////////////////
  152. // Get a handle to a an account token. Note, this token is an impersonation token.
  153. HANDLE
  154. HGetAccountToken(
  155. const WCHAR * pcszAccountNameIn
  156. , const WCHAR * pcszAccountPwdIn
  157. , const WCHAR * pcszAccountDomainIn
  158. );
  159. // Check and see if this node can interoperate with the sponsor cluster.
  160. void
  161. CheckInteroperability( void );
  162. // Get a binding handle to the extrocluster join interface and store it.
  163. void
  164. InitializeJoinBinding( void );
  165. //////////////////////////////////////////////////////////////////////////
  166. // Private data
  167. //////////////////////////////////////////////////////////////////////////
  168. // Node Id of this node.
  169. CStr m_strNodeId;
  170. // Token for the cluster service account.
  171. SmartAccountToken m_satServiceAccountToken;
  172. // Binding handle to the extrocluster join interface.
  173. SmartRpcBinding m_srbJoinBinding;
  174. // A smart pointer to a CClusSvcAccountConfig object.
  175. SmartAccountConfigPtr m_spacAccountConfigAction;
  176. }; //*** class CBaseClusterJoin