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.

231 lines
7.1 KiB

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