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.

386 lines
16 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // Res.h
  7. //
  8. // Abstract:
  9. // Definition of the CResource class.
  10. //
  11. // Implementation File:
  12. // Res.cpp
  13. //
  14. // Author:
  15. // David Potter (davidp) May 6, 1996
  16. //
  17. // Revision History:
  18. //
  19. // Notes:
  20. //
  21. /////////////////////////////////////////////////////////////////////////////
  22. #ifndef _RES_H_
  23. #define _RES_H_
  24. /////////////////////////////////////////////////////////////////////////////
  25. // Forward Class Declarations
  26. /////////////////////////////////////////////////////////////////////////////
  27. class CResource;
  28. class CResourceList;
  29. /////////////////////////////////////////////////////////////////////////////
  30. // External Class Declarations
  31. /////////////////////////////////////////////////////////////////////////////
  32. class CGroup;
  33. class CResourceType;
  34. /////////////////////////////////////////////////////////////////////////////
  35. // External Class Declarations
  36. /////////////////////////////////////////////////////////////////////////////
  37. class CClusterNode;
  38. class CNodeList;
  39. /////////////////////////////////////////////////////////////////////////////
  40. // Type Definitions
  41. /////////////////////////////////////////////////////////////////////////////
  42. /////////////////////////////////////////////////////////////////////////////
  43. // Include Files
  44. /////////////////////////////////////////////////////////////////////////////
  45. #ifndef _CLUSITEM_H_
  46. #include "ClusItem.h" // for CClusterItem
  47. #endif
  48. #ifndef _RESTYPE_H_
  49. #include "ResType.h" // for CResourceType
  50. #endif
  51. #ifndef _PROPLIST_H_
  52. #include "PropList.h" // for CObjectProperty, CClusPropList
  53. #endif
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CResource command target
  56. /////////////////////////////////////////////////////////////////////////////
  57. class CResource : public CClusterItem
  58. {
  59. DECLARE_DYNCREATE(CResource)
  60. // Construction
  61. public:
  62. CResource(void); // protected constructor used by dynamic creation
  63. CResource(IN BOOL bDocobj);
  64. void Init(IN OUT CClusterDoc * pdoc, IN LPCTSTR lpszName);
  65. void Create(
  66. IN OUT CClusterDoc * pdoc,
  67. IN LPCTSTR lpszName,
  68. IN LPCTSTR lpszType,
  69. IN LPCTSTR lpszGroup,
  70. IN BOOL bSeparateMonitor
  71. );
  72. protected:
  73. void CommonConstruct(void);
  74. // Attributes
  75. protected:
  76. HRESOURCE m_hresource;
  77. CLUSTER_RESOURCE_STATE m_crs;
  78. CString m_strOwner;
  79. CClusterNode * m_pciOwner;
  80. CString m_strGroup;
  81. CGroup * m_pciGroup;
  82. BOOL m_bSeparateMonitor;
  83. DWORD m_nLooksAlive;
  84. DWORD m_nIsAlive;
  85. CRRA m_crraRestartAction;
  86. DWORD m_nRestartThreshold;
  87. DWORD m_nRestartPeriod;
  88. DWORD m_nPendingTimeout;
  89. CString m_strResourceType;
  90. CResourceType * m_pciResourceType;
  91. PCLUSPROP_REQUIRED_DEPENDENCY m_pcrd;
  92. CLUS_RESOURCE_CLASS_INFO m_rciResClassInfo;
  93. DWORD m_dwCharacteristics;
  94. DWORD m_dwFlags;
  95. CResourceList * m_plpciresDependencies;
  96. CNodeList * m_plpcinodePossibleOwners;
  97. enum
  98. {
  99. epropName = 0,
  100. epropType,
  101. epropDescription,
  102. epropSeparateMonitor,
  103. epropLooksAlive,
  104. epropIsAlive,
  105. epropRestartAction,
  106. epropRestartThreshold,
  107. epropRestartPeriod,
  108. epropPendingTimeout,
  109. epropMAX
  110. };
  111. CObjectProperty m_rgProps[epropMAX];
  112. public:
  113. HRESOURCE Hresource(void) const { return m_hresource; }
  114. CLUSTER_RESOURCE_STATE Crs(void) const { return m_crs; }
  115. const CString & StrOwner(void) const { return m_strOwner; }
  116. CClusterNode * PciOwner(void) const { return m_pciOwner; }
  117. const CString & StrGroup(void) const { return m_strGroup; }
  118. CGroup * PciGroup(void) const { return m_pciGroup; }
  119. const CString & StrResourceType(void) const { return m_strResourceType; }
  120. const CString & StrRealResourceType(void) const
  121. {
  122. if (PciResourceType() == NULL)
  123. return StrResourceType();
  124. else
  125. {
  126. ASSERT_VALID(PciResourceType());
  127. return PciResourceType()->StrName();
  128. }
  129. }
  130. const CString & StrRealResourceTypeDisplayName(void) const
  131. {
  132. if (PciResourceType() == NULL)
  133. return StrResourceType();
  134. else
  135. {
  136. ASSERT_VALID(PciResourceType());
  137. if (PciResourceType()->StrDisplayName().GetLength() == 0)
  138. return PciResourceType()->StrName();
  139. else
  140. return PciResourceType()->StrDisplayName();
  141. }
  142. }
  143. CResourceType * PciResourceType(void) const { return m_pciResourceType; }
  144. BOOL BSeparateMonitor(void) const { return m_bSeparateMonitor; }
  145. DWORD NLooksAlive(void) const { return m_nLooksAlive; }
  146. DWORD NIsAlive(void) const { return m_nIsAlive; }
  147. CRRA CrraRestartAction(void) const { return m_crraRestartAction; }
  148. DWORD NRestartThreshold(void) const { return m_nRestartThreshold; }
  149. DWORD NRestartPeriod(void) const { return m_nRestartPeriod; }
  150. DWORD NPendingTimeout(void) const { return m_nPendingTimeout; }
  151. const PCLUSPROP_REQUIRED_DEPENDENCY Pcrd(void) const { return m_pcrd; }
  152. CLUSTER_RESOURCE_CLASS ResClass(void) const { return m_rciResClassInfo.rc; }
  153. PCLUS_RESOURCE_CLASS_INFO PrciResClassInfo(void) { return &m_rciResClassInfo; }
  154. DWORD DwCharacteristics(void) const { return m_dwCharacteristics; }
  155. DWORD DwFlags(void) const { return m_dwFlags; }
  156. BOOL BQuorumCapable( void ) const { return (m_dwCharacteristics & CLUS_CHAR_QUORUM) != 0; }
  157. BOOL BLocalQuorum( void ) const { return (m_dwCharacteristics & CLUS_CHAR_LOCAL_QUORUM) != 0; }
  158. BOOL BLocalQuorumDebug( void ) const { return (m_dwCharacteristics & CLUS_CHAR_LOCAL_QUORUM_DEBUG) != 0; }
  159. BOOL BDeleteRequiresAllNodes( void ) const { return (m_dwCharacteristics & CLUS_CHAR_DELETE_REQUIRES_ALL_NODES) != 0; }
  160. BOOL BCore( void ) const { return (m_dwFlags & CLUS_FLAG_CORE) != 0; }
  161. const CResourceList & LpciresDependencies(void) const { ASSERT(m_plpciresDependencies != NULL); return *m_plpciresDependencies; }
  162. const CNodeList & LpcinodePossibleOwners(void) const { ASSERT(m_plpcinodePossibleOwners != NULL); return *m_plpcinodePossibleOwners; }
  163. void GetStateName(OUT CString & rstrState) const;
  164. BOOL BCanBeDependent(IN CResource * pciRes);
  165. BOOL BIsDependent(IN CResource * pciRes);
  166. BOOL BGetNetworkName(OUT WCHAR * lpszNetName, IN OUT DWORD * pcchNetName);
  167. BOOL BGetNetworkName(OUT CString & rstrNetName);
  168. // Operations
  169. public:
  170. void SetOwnerState(IN LPCTSTR pszNewOwner);
  171. void SetGroupState(IN LPCTSTR pszNewGroup);
  172. void CollectPossibleOwners(IN OUT CNodeList * plpci) const;
  173. // void RemoveNodeFromPossibleOwners(IN OUT CNodeList * plpci, IN const CClusterNode * pNode);
  174. void CollectDependencies(IN OUT CResourceList * plpci, IN BOOL bFullTree = FALSE) const;
  175. void CollectProvidesFor(IN OUT CResourceList * plpci, IN BOOL bFullTree = FALSE) const;
  176. void CollectDependencyTree(IN OUT CResourceList * plpci) const;
  177. void DeleteResource(void);
  178. void Move(IN const CGroup * pciGroup);
  179. void ReadExtensions(void);
  180. void SetName(IN LPCTSTR pszName);
  181. void SetGroup(IN LPCTSTR pszGroup);
  182. void SetDependencies(IN const CResourceList & rlpci);
  183. void SetPossibleOwners(IN const CNodeList & rlpci);
  184. void SetCommonProperties(
  185. IN const CString & rstrDesc,
  186. IN BOOL bSeparate,
  187. IN DWORD nLooksAlive,
  188. IN DWORD nIsAlive,
  189. IN CRRA crra,
  190. IN DWORD nThreshold,
  191. IN DWORD nPeriod,
  192. IN DWORD nTimeout,
  193. IN BOOL bValidateOnly
  194. );
  195. void SetCommonProperties(
  196. IN const CString & rstrDesc,
  197. IN BOOL bSeparate,
  198. IN DWORD nLooksAlive,
  199. IN DWORD nIsAlive,
  200. IN CRRA crra,
  201. IN DWORD nThreshold,
  202. IN DWORD nPeriod,
  203. IN DWORD nTimeout
  204. )
  205. {
  206. SetCommonProperties(rstrDesc, bSeparate, nLooksAlive, nIsAlive,crra,
  207. nThreshold, nPeriod, nTimeout, FALSE /*bValidateOnly*/ );
  208. }
  209. void ValidateCommonProperties(
  210. IN const CString & rstrDesc,
  211. IN BOOL bSeparate,
  212. IN DWORD nLooksAlive,
  213. IN DWORD nIsAlive,
  214. IN CRRA crra,
  215. IN DWORD nThreshold,
  216. IN DWORD nPeriod,
  217. IN DWORD nTimeout
  218. )
  219. {
  220. SetCommonProperties(rstrDesc, bSeparate, nLooksAlive, nIsAlive,crra,
  221. nThreshold, nPeriod, nTimeout, TRUE /*bValidateOnly*/ );
  222. }
  223. DWORD DwResourceControlGet(
  224. IN DWORD dwFunctionCode,
  225. IN PBYTE pbInBuf,
  226. IN DWORD cbInBuf,
  227. OUT PBYTE * ppbOutBuf
  228. );
  229. DWORD DwResourceControlGet(
  230. IN DWORD dwFunctionCode,
  231. OUT PBYTE * ppbOutBuf
  232. ) { return DwResourceControlGet(dwFunctionCode, NULL, NULL, ppbOutBuf); }
  233. BOOL BRequiredDependenciesPresent(
  234. IN const CResourceList & rlpciRes,
  235. OUT CString & rstrMissing
  236. );
  237. // Overrides
  238. public:
  239. virtual void Cleanup(void);
  240. virtual void ReadItem(void);
  241. virtual void UpdateState(void);
  242. virtual void Rename(IN LPCTSTR pszName);
  243. virtual BOOL BGetColumnData(IN COLID colid, OUT CString & rstrText);
  244. virtual BOOL BCanBeEdited(void) const;
  245. virtual BOOL BDisplayProperties(IN BOOL bReadOnly = FALSE);
  246. // Drag & Drop
  247. virtual BOOL BCanBeDragged(void) const { return TRUE; }
  248. virtual const CStringList * PlstrExtensions(void) const;
  249. #ifdef _DISPLAY_STATE_TEXT_IN_TREE
  250. virtual void GetTreeName(OUT CString & rstrName) const;
  251. #endif
  252. // ClassWizard generated virtual function overrides
  253. //{{AFX_VIRTUAL(CResource)
  254. public:
  255. virtual void OnFinalRelease();
  256. virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
  257. //}}AFX_VIRTUAL
  258. virtual LRESULT OnClusterNotify(IN OUT CClusterNotify * pnotify);
  259. protected:
  260. virtual const CObjectProperty * Pprops(void) const { return m_rgProps; }
  261. virtual DWORD Cprops(void) const { return sizeof(m_rgProps) / sizeof(m_rgProps[0]); }
  262. virtual DWORD DwSetCommonProperties(IN const CClusPropList & rcpl, IN BOOL bValidateOnly = FALSE);
  263. // Implementation
  264. protected:
  265. CStringList m_lstrCombinedExtensions;
  266. BOOL m_bInitializing;
  267. BOOL m_bDeleting;
  268. const CStringList & LstrCombinedExtensions(void) const { return m_lstrCombinedExtensions; }
  269. public:
  270. virtual ~CResource(void);
  271. BOOL BInitializing(void) const { return m_bInitializing; }
  272. BOOL BDeleting(void) const { return m_bDeleting; }
  273. void SetInitializing(IN BOOL bInit = TRUE) { m_bInitializing = bInit; }
  274. protected:
  275. void DeleteResource(IN const CResourceList & rlpci);
  276. void Move(IN const CGroup * pciGroup, IN const CResourceList & rlpci);
  277. BOOL BAllowedToTakeOffline(void);
  278. void WaitForOffline( void );
  279. public:
  280. // Generated message map functions
  281. //{{AFX_MSG(CResource)
  282. afx_msg void OnUpdateBringOnline(CCmdUI* pCmdUI);
  283. afx_msg void OnUpdateTakeOffline(CCmdUI* pCmdUI);
  284. afx_msg void OnUpdateInitiateFailure(CCmdUI* pCmdUI);
  285. afx_msg void OnUpdateMoveResource1(CCmdUI* pCmdUI);
  286. afx_msg void OnUpdateMoveResourceRest(CCmdUI* pCmdUI);
  287. afx_msg void OnUpdateDelete(CCmdUI* pCmdUI);
  288. afx_msg void OnUpdateProperties(CCmdUI* pCmdUI);
  289. afx_msg void OnCmdBringOnline();
  290. afx_msg void OnCmdTakeOffline();
  291. afx_msg void OnCmdInitiateFailure();
  292. afx_msg void OnCmdDelete();
  293. //}}AFX_MSG
  294. afx_msg void OnCmdMoveResource(IN UINT nID);
  295. DECLARE_MESSAGE_MAP()
  296. #ifdef _CLUADMIN_USE_OLE_
  297. DECLARE_OLECREATE(CResource)
  298. // Generated OLE dispatch map functions
  299. //{{AFX_DISPATCH(CResource)
  300. // NOTE - the ClassWizard will add and remove member functions here.
  301. //}}AFX_DISPATCH
  302. DECLARE_DISPATCH_MAP()
  303. DECLARE_INTERFACE_MAP()
  304. #endif // _CLUADMIN_USE_OLE_
  305. }; //*** class CResource
  306. /////////////////////////////////////////////////////////////////////////////
  307. // CResourceList
  308. /////////////////////////////////////////////////////////////////////////////
  309. class CResourceList : public CClusterItemList
  310. {
  311. public:
  312. CResource * PciResFromName(
  313. IN LPCTSTR pszName,
  314. OUT POSITION * ppos = NULL
  315. )
  316. {
  317. return (CResource *) PciFromName(pszName, ppos);
  318. }
  319. }; //*** class CResourceList
  320. /////////////////////////////////////////////////////////////////////////////
  321. // Global Functions
  322. /////////////////////////////////////////////////////////////////////////////
  323. //void DeleteAllItemData(IN OUT CResourceList & rlp);
  324. #ifdef _DEBUG
  325. class CTraceTag;
  326. extern CTraceTag g_tagResource;
  327. extern CTraceTag g_tagResNotify;
  328. #endif
  329. /////////////////////////////////////////////////////////////////////////////
  330. #endif // _RES_H_