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.

300 lines
8.3 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1998 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // WizThread.h
  7. //
  8. // Abstract:
  9. // Definition of the CWizardThread class.
  10. //
  11. // Implementation File:
  12. // WizThread.cpp
  13. //
  14. // Author:
  15. // David Potter (davidp) December 16, 1997
  16. //
  17. // Revision History:
  18. //
  19. // Notes:
  20. //
  21. /////////////////////////////////////////////////////////////////////////////
  22. #ifndef __WIZTHREAD_H_
  23. #define __WIZTHREAD_H_
  24. /////////////////////////////////////////////////////////////////////////////
  25. // Forward Class Declarations
  26. /////////////////////////////////////////////////////////////////////////////
  27. class CClusterThread;
  28. /////////////////////////////////////////////////////////////////////////////
  29. // External Class Declarations
  30. /////////////////////////////////////////////////////////////////////////////
  31. class CClusterAppWizard;
  32. class CClusNodeInfo;
  33. class CClusGroupInfo;
  34. class CClusResInfo;
  35. class CClusResTypeInfo;
  36. class CClusNetworkInfo;
  37. /////////////////////////////////////////////////////////////////////////////
  38. // Include Files
  39. /////////////////////////////////////////////////////////////////////////////
  40. #ifndef __WORKTHRD_H_
  41. #include "WorkThrd.h" // for CWorkerThread
  42. #endif
  43. #ifndef __CLUSOBJ_H_
  44. #include "ClusObj.h" // for CClusResPtrList, etc.
  45. #endif
  46. /////////////////////////////////////////////////////////////////////////////
  47. // Type Definitions
  48. /////////////////////////////////////////////////////////////////////////////
  49. // Cluster thread function codes.
  50. enum
  51. {
  52. WZTF_READ_CLUSTER_INFO = WTF_USER, // Read cluster information.
  53. WZTF_COLLECT_GROUPS, // Collect groups in the cluster.
  54. WZTF_COLLECT_RESOURCES, // Collect resources in the cluster.
  55. WZTF_COLLECT_RESOURCE_TYPES, // Collect resource types in the cluster.
  56. WZTF_COLLECT_NETWORKS, // Collect networks in the cluster.
  57. WZTF_COLLECT_NODES, // Collect nodes in the cluster.
  58. WZTF_COPY_GROUP_INFO, // Copy one group to another.
  59. WZTF_COLLECT_DEPENDENCIES, // Collect dependencies for a resource.
  60. WZTF_CREATE_VIRTUAL_SERVER, // Create a virtual server.
  61. WZTF_CREATE_APP_RESOURCE, // Create the application resource.
  62. WZTF_DELETE_APP_RESOURCE, // Delete the application resource.
  63. WZTF_RESET_CLUSTER, // Reset the cluster.
  64. WZTF_SET_APPRES_ATTRIBUTES, // Set properties, dependencies, owners of the application resource.
  65. WZTF_MAX
  66. };
  67. /////////////////////////////////////////////////////////////////////////////
  68. // class CWizardThread
  69. /////////////////////////////////////////////////////////////////////////////
  70. class CWizardThread : public CWorkerThread
  71. {
  72. public:
  73. //
  74. // Construction and destruction.
  75. //
  76. // Default constructor
  77. CWizardThread( IN CClusterAppWizard * pwiz )
  78. : m_pwiz( pwiz )
  79. {
  80. ASSERT( pwiz != NULL );
  81. } //*** CWizardThread()
  82. // Destructor
  83. ~CWizardThread( void )
  84. {
  85. } //*** ~CWizardThread()
  86. //
  87. // Accessor functions.
  88. //
  89. protected:
  90. //
  91. // Properties.
  92. //
  93. CClusterAppWizard * m_pwiz;
  94. // Returns the wizard object
  95. CClusterAppWizard * Pwiz( void )
  96. {
  97. ASSERT( m_pwiz != NULL );
  98. return m_pwiz;
  99. } //*** Pwiz()
  100. public:
  101. //
  102. // Function marshaler macros.
  103. //
  104. #define WIZ_THREAD_FUNCTION_0( funcname, funccode ) \
  105. public: \
  106. BOOL funcname( HWND hwnd ) \
  107. { \
  108. ASSERT( GetCurrentThreadId() != m_idThread ); \
  109. return CallThreadFunction( hwnd, funccode, NULL, NULL );\
  110. } \
  111. protected: \
  112. BOOL _##funcname( void );
  113. #define WIZ_THREAD_FUNCTION_1( funcname, funccode, p1type, p1 ) \
  114. public: \
  115. BOOL funcname( HWND hwnd, p1type p1 ) \
  116. { \
  117. ASSERT( GetCurrentThreadId() != m_idThread ); \
  118. ASSERT( p1 != NULL ); \
  119. return CallThreadFunction( hwnd, funccode, (PVOID) p1, NULL );\
  120. } \
  121. protected: \
  122. BOOL _##funcname( p1type p1 );
  123. #define WIZ_THREAD_FUNCTION_2( funcname, funccode, p1type, p1, p2type, p2 ) \
  124. public: \
  125. BOOL funcname( HWND hwnd, p1type p1, p2type p2 ) \
  126. { \
  127. ASSERT( GetCurrentThreadId() != m_idThread ); \
  128. ASSERT( p1 != NULL ); \
  129. ASSERT( p2 != NULL ); \
  130. return CallThreadFunction( hwnd, funccode, (PVOID) p1, (PVOID) p2 );\
  131. } \
  132. protected: \
  133. BOOL _##funcname( p1type p1, p2type p2 );
  134. //
  135. // Function marshaler functions.
  136. //
  137. WIZ_THREAD_FUNCTION_0( BReadClusterInfo, WZTF_READ_CLUSTER_INFO )
  138. WIZ_THREAD_FUNCTION_0( BCollectResources, WZTF_COLLECT_RESOURCES )
  139. WIZ_THREAD_FUNCTION_0( BCollectGroups, WZTF_COLLECT_GROUPS )
  140. WIZ_THREAD_FUNCTION_0( BCollectResourceTypes, WZTF_COLLECT_RESOURCE_TYPES )
  141. WIZ_THREAD_FUNCTION_0( BCollectNetworks, WZTF_COLLECT_NETWORKS )
  142. WIZ_THREAD_FUNCTION_0( BCollectNodes, WZTF_COLLECT_NODES )
  143. WIZ_THREAD_FUNCTION_1( BCopyGroupInfo, WZTF_COPY_GROUP_INFO, CClusGroupInfo **, ppgi )
  144. WIZ_THREAD_FUNCTION_1( BCollectDependencies, WZTF_COLLECT_DEPENDENCIES, CClusResInfo *, pri )
  145. WIZ_THREAD_FUNCTION_0( BCreateVirtualServer, WZTF_CREATE_VIRTUAL_SERVER )
  146. WIZ_THREAD_FUNCTION_0( BCreateAppResource, WZTF_CREATE_APP_RESOURCE )
  147. WIZ_THREAD_FUNCTION_0( BDeleteAppResource, WZTF_DELETE_APP_RESOURCE )
  148. WIZ_THREAD_FUNCTION_0( BResetCluster, WZTF_RESET_CLUSTER )
  149. WIZ_THREAD_FUNCTION_2( BSetAppResAttributes, WZTF_SET_APPRES_ATTRIBUTES,
  150. CClusResPtrList *, plpriOldDependencies,
  151. CClusNodePtrList *, plpniOldPossibleOwners
  152. )
  153. protected:
  154. //
  155. // Thread worker functions.
  156. //
  157. // Thread function handler
  158. virtual DWORD ThreadFunctionHandler(
  159. LONG nFunction,
  160. PVOID pvParam1,
  161. PVOID pvParam2
  162. );
  163. //
  164. // Helper functions.
  165. //
  166. // Cleanup objects
  167. virtual void Cleanup( void )
  168. {
  169. CWorkerThread::Cleanup();
  170. }
  171. protected:
  172. //
  173. // Utility functions callable by thread function handlers.
  174. //
  175. // Query for information about a resource
  176. BOOL _BQueryResource( IN OUT CClusResInfo * pri );
  177. // Get resource properties
  178. BOOL _BGetResourceProps( IN OUT CClusResInfo * pri );
  179. // Get possible owners for a resource
  180. BOOL _BGetPossibleOwners( IN OUT CClusResInfo * pri );
  181. // Get dependencies for a resource
  182. BOOL _BGetDependencies( IN OUT CClusResInfo * pri );
  183. // Query for information about a group
  184. BOOL _BQueryGroup( IN OUT CClusGroupInfo * pgi );
  185. // Get group properties
  186. BOOL _BGetGroupProps( IN OUT CClusGroupInfo * pgi );
  187. // Get resources in a group
  188. BOOL _BGetResourcesInGroup( IN OUT CClusGroupInfo * pgi );
  189. // Get preferred owners for a group
  190. BOOL _BGetPreferredOwners( IN OUT CClusGroupInfo * pgi );
  191. // Get private props of IP Address resource for the group
  192. BOOL _BGetIPAddressPrivatePropsForGroup(
  193. IN OUT CClusGroupInfo * pgi,
  194. IN OUT CClusResInfo * pri
  195. );
  196. // Get private props of Network Name resource for the group
  197. BOOL _BGetNetworkNamePrivatePropsForGroup(
  198. IN OUT CClusGroupInfo * pgi,
  199. IN OUT CClusResInfo * pri
  200. );
  201. // Query for information about a resource type
  202. BOOL _BQueryResourceType( IN OUT CClusResTypeInfo * prti );
  203. // Get resource type properties
  204. BOOL _BGetResourceTypeProps( IN OUT CClusResTypeInfo * prti );
  205. // Get resource type required dependencies
  206. BOOL _BGetRequiredDependencies( IN OUT CClusResTypeInfo * prti );
  207. // Query for information about a network
  208. BOOL _BQueryNetwork( IN OUT CClusNetworkInfo * pni );
  209. // Query for information about a node
  210. BOOL _BQueryNode( IN OUT CClusNodeInfo * pni );
  211. // Set properties on a group
  212. BOOL _BSetGroupProperties(
  213. IN OUT CClusGroupInfo * pgi,
  214. IN const CClusGroupInfo * pgiPrev
  215. );
  216. // Create a resource and set common properties
  217. BOOL _BCreateResource(
  218. IN CClusResInfo & rri,
  219. IN HGROUP hGroup
  220. );
  221. // Set the properties, dependency list and possible owner list of a resource.
  222. BOOL _BSetResourceAttributes(
  223. IN CClusResInfo & rri,
  224. IN CClusResPtrList * plpriOldDependencies = NULL,
  225. IN CClusNodePtrList * plpniOldPossibleOwners = NULL
  226. );
  227. // Set the dependency list of a resource.
  228. DWORD _BSetResourceDependencies(
  229. IN CClusResInfo & rri,
  230. IN CClusResPtrList * plpriOldDependencies = NULL
  231. );
  232. // Set the possible owner list of a resource.
  233. DWORD _BSetPossibleOwners(
  234. IN CClusResInfo & rri,
  235. IN CClusNodePtrList * plpniOldPossibleOwners = NULL
  236. );
  237. // Delete a resource
  238. BOOL _BDeleteResource( IN CClusResInfo & rri );
  239. // Reset the group to its original state (deleted or renamed)
  240. BOOL _BResetGroup( void );
  241. // Read admin extensions directly from the cluster database
  242. BOOL _BReadAdminExtensions( IN LPCWSTR pszKey, OUT std::list< CString > & rlstr );
  243. }; // class CWizardThread
  244. /////////////////////////////////////////////////////////////////////////////
  245. #endif // __WIZTHREAD_H_