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.

311 lines
12 KiB

  1. /*++
  2. Copyright (c) 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. HsmServ.h
  5. Abstract:
  6. This header file defines the CHsmServer object, which acts as the 'entry point'
  7. for the HSM Engine.
  8. Author:
  9. Cat Brant [cbrant] 24-Jan-1997
  10. Revision History:
  11. Chris Timmes [chris.timmes] 11-Sep-1997 - Renamed FindStoragePoolById()
  12. to FindHsmStoragePoolByMediaSetId()
  13. and added FindHsmStoragePoolById()
  14. Chris Timmes [chris.timmes] 22-Sep-1997 - Added FindMediaIdByDisplayName()
  15. and RecreateMaster() methods to
  16. IHsmServer
  17. Chris Timmes [chris.timmes] 21-Oct-1997 - Added MarkMediaForRecreation()
  18. method to IHsmServer
  19. Chris Timmes [chris.timmes] 18-Nov-1997 - Added CreateTask() method to IHsmServer
  20. --*/
  21. #ifndef _HSMSERV_H
  22. #define _HSMSERV_H
  23. #include <rswriter.h>
  24. #define ENG_DB_DIRECTORY OLESTR("EngDb")
  25. class CHsmServer :
  26. public CWsbPersistable,
  27. public IHsmServer,
  28. public IWsbServer,
  29. public IWsbCreateLocalObject,
  30. public CComCoClass<CHsmServer,&CLSID_HsmServer>
  31. {
  32. public:
  33. CHsmServer( ) {}
  34. BEGIN_COM_MAP( CHsmServer )
  35. COM_INTERFACE_ENTRY( IHsmServer )
  36. COM_INTERFACE_ENTRY2(IPersist, IPersistStream)
  37. COM_INTERFACE_ENTRY(IPersistStream)
  38. COM_INTERFACE_ENTRY(IPersistFile)
  39. COM_INTERFACE_ENTRY(IWsbPersistable)
  40. COM_INTERFACE_ENTRY( IWsbCreateLocalObject )
  41. COM_INTERFACE_ENTRY( IWsbServer )
  42. END_COM_MAP( )
  43. DECLARE_NOT_AGGREGATABLE( CHsmServer)
  44. DECLARE_REGISTRY_RESOURCEID( IDR_HsmServer )
  45. DECLARE_PROTECT_FINAL_CONSTRUCT()
  46. // CComObjectRoot
  47. STDMETHOD(FinalConstruct)(void);
  48. void FinalRelease( void );
  49. // IPersist
  50. public:
  51. STDMETHOD(GetClassID)(LPCLSID pClsid);
  52. // IPersistStream
  53. public:
  54. STDMETHOD(GetSizeMax)(ULARGE_INTEGER* pSize);
  55. STDMETHOD(Load)(IStream* pStream);
  56. STDMETHOD(Save)(IStream* pStream, BOOL clearDirty);
  57. // IWsbServer
  58. public:
  59. STDMETHOD( GetId )( GUID* pId );
  60. STDMETHOD( GetRegistryName )( OLECHAR **pRegistryName, ULONG bufferSize );
  61. STDMETHOD( SetId )( GUID id );
  62. STDMETHOD( GetBuildVersion )( ULONG *pBuildVersion );
  63. STDMETHOD( GetNtProductVersion )( OLECHAR **pNtProductVersion, ULONG bufferSize );
  64. STDMETHOD( GetNtProductBuild )( ULONG *pNtProductBuild );
  65. STDMETHOD( GetDatabaseVersion )( ULONG *pDatabaseVersion );
  66. STDMETHOD( SaveAll )( void );
  67. STDMETHOD( Unload )( void );
  68. STDMETHOD( CheckAccess )( WSB_ACCESS_TYPE AccessType );
  69. STDMETHOD( GetTrace )( OUT IWsbTrace ** ppTrace );
  70. STDMETHOD( SetTrace )( IN IWsbTrace *pTrace );
  71. STDMETHOD( DestroyObject )( void );
  72. // IHsmServer
  73. public:
  74. STDMETHOD( Init )( void );
  75. STDMETHOD( GetID )( GUID *phid );
  76. STDMETHOD( GetDbPath )( OLECHAR** pPath, ULONG bufferSize );
  77. STDMETHOD( GetIDbPath )( OLECHAR** pPath, ULONG bufferSize );
  78. STDMETHOD( GetDbPathAndName )( OLECHAR** pPath, ULONG bufferSize );
  79. STDMETHOD( GetName )( OLECHAR **ppName );
  80. STDMETHOD( GetHsmExtVerHi )( SHORT *pExtVerHi );
  81. STDMETHOD( GetHsmExtVerLo )( SHORT *pExtVerLo );
  82. STDMETHOD( GetHsmExtRev )( SHORT *pExtRev );
  83. STDMETHOD( GetAutosave )( ULONG* pMilliseconds );
  84. STDMETHOD( SetAutosave )( ULONG milliseconds );
  85. STDMETHOD( GetCopyFilesLimit )( ULONG* pLimit );
  86. STDMETHOD( GetCopyFilesUserLimit )( ULONG* pLimit );
  87. STDMETHOD( SetCopyFilesUserLimit )( ULONG limit );
  88. STDMETHOD( GetManagedResources )( IWsbIndexedCollection **ppCollection);
  89. STDMETHOD( FindHsmStoragePoolById )( GUID StoragePoolId,
  90. IHsmStoragePool** ppStoragePool );
  91. STDMETHOD( FindHsmStoragePoolByMediaSetId )( GUID RmsMediaSetId,
  92. IHsmStoragePool** ppStoragePool );
  93. STDMETHOD( FindMediaIdByDescription )( IN OLECHAR* description,
  94. OUT GUID* pMediaId );
  95. STDMETHOD( FindStoragePoolByName )(OLECHAR* name, IHsmStoragePool** ppStoragePool );
  96. STDMETHOD( GetStoragePools )( IWsbIndexedCollection **ppCollection);
  97. STDMETHOD( GetOnlineInformation )( IWsbIndexedCollection **ppCollection);
  98. STDMETHOD( GetMessages )( IWsbIndexedCollection **ppCollection);
  99. STDMETHOD( GetUsrToNotify )( IWsbIndexedCollection **ppCollection);
  100. STDMETHOD( GetJobs )( IWsbIndexedCollection **ppCollection);
  101. STDMETHOD( FindJobByName )(OLECHAR* name, IHsmJob** ppJob );
  102. STDMETHOD( GetJobDefs )( IWsbIndexedCollection **ppCollection);
  103. STDMETHOD( GetPolicies )( IWsbIndexedCollection **ppCollection);
  104. STDMETHOD( GetActions )( IWsbIndexedCollection **ppCollection);
  105. STDMETHOD( GetCriteria )( IWsbIndexedCollection **ppCollection);
  106. STDMETHOD( GetMediaRecs )( IWsbIndexedCollection **ppCollection);
  107. STDMETHOD( GetMountingMedias ) ( IWsbIndexedCollection **ppCollection);
  108. STDMETHOD( LockMountingMedias )( void );
  109. STDMETHOD( UnlockMountingMedias )( void );
  110. STDMETHOD( GetNextMedia )( LONG *pNextMedia );
  111. STDMETHOD( GetSegmentDb )( IWsbDb **ppDb);
  112. STDMETHOD( BackupSegmentDb )( void );
  113. STDMETHOD( GetHsmFsaTskMgr )( IHsmFsaTskMgr **ppHsmFsaTskMgr);
  114. STDMETHOD( SaveMetaData )( void );
  115. STDMETHOD( SavePersistData )( void );
  116. STDMETHOD( CloseOutDb )( void );
  117. STDMETHOD( CancelAllJobs )( void );
  118. STDMETHOD( AreJobsEnabled )( void );
  119. STDMETHOD( EnableAllJobs )( void );
  120. STDMETHOD( DisableAllJobs )( void );
  121. STDMETHOD( RestartSuspendedJobs )( void );
  122. STDMETHOD( CreateTask )( IN const OLECHAR * jobName, IN const OLECHAR * jobParameters,
  123. IN const OLECHAR * jobComments,
  124. IN const TASK_TRIGGER_TYPE jobTriggerType,
  125. IN const WORD jobStartHour, IN const WORD jobStartMinute,
  126. IN const BOOL scheduledJob );
  127. STDMETHOD( CreateTaskEx )( IN const OLECHAR * jobName, IN const OLECHAR * jobParameters,
  128. IN const OLECHAR * jobComments,
  129. IN const TASK_TRIGGER_TYPE jobTriggerType,
  130. IN const SYSTEMTIME runTime,
  131. IN const DWORD runOccurrence,
  132. IN const BOOL scheduledJob );
  133. STDMETHOD( CancelCopyMedia )( void );
  134. STDMETHOD( MarkMediaForRecreation )( IN REFGUID masterMediaId );
  135. STDMETHOD( RecreateMaster )( IN REFGUID masterMediaId, USHORT copySet );
  136. STDMETHOD( SynchronizeMedia )( GUID poolId, USHORT copySet );
  137. STDMETHOD( GetHsmMediaMgr )( IRmsServer **ppHsmMediaMgr);
  138. STDMETHOD( ResetSegmentValidMark )( void );
  139. STDMETHOD( ResetMediaValidBytes )( void );
  140. STDMETHOD( GetSegmentPosition )( IN REFGUID bagId,
  141. IN LONGLONG fileStart,
  142. IN LONGLONG fileSize,
  143. OUT GUID* pPosMedia,
  144. OUT LONGLONG* pPosOfffset );
  145. STDMETHOD( UpdateMediaSizeLimit )(OUT DWORD* pdwNewLimit);
  146. // IHsmSystemState
  147. STDMETHOD( ChangeSysState )( HSM_SYSTEM_STATE* pSysState );
  148. // IWsbCreateLocalServer
  149. STDMETHOD( CreateInstance )( REFCLSID rclsid, REFIID riid, void **ppv );
  150. // Internal Helper functions
  151. STDMETHOD( Autosave )(void);
  152. STDMETHOD( LoadJobs )( IStream* pStream );
  153. STDMETHOD( StoreJobs )( IStream* pStream );
  154. STDMETHOD( LoadJobDefs )( IStream* pStream );
  155. STDMETHOD( StoreJobDefs )( IStream* pStream );
  156. STDMETHOD( LoadPolicies )( IStream* pStream );
  157. STDMETHOD( StorePolicies )( IStream* pStream );
  158. STDMETHOD( LoadManagedResources )( IStream* pStream );
  159. STDMETHOD( StoreManagedResources )( IStream* pStream );
  160. STDMETHOD( LoadStoragePools )( IStream* pStream );
  161. STDMETHOD( StoreStoragePools )( IStream* pStream );
  162. STDMETHOD( LoadSegmentInformation )( void );
  163. STDMETHOD( StoreSegmentInformation )( void );
  164. STDMETHOD( StoreSegmentInformationFinal )( void );
  165. STDMETHOD( LoadMessages )( IStream* pStream );
  166. STDMETHOD( StoreMessages )( IStream* pStream );
  167. STDMETHOD( LoadPersistData )( void );
  168. STDMETHOD( NotifyAllJobs )(HSM_JOB_STATE jobState);
  169. STDMETHOD( CreateDefaultJobs )( void );
  170. STDMETHOD( GetSavedTraceSettings )( LONGLONG *pTraceSettings, BOOLEAN *pTraceOn);
  171. STDMETHOD( SetSavedTraceSettings )( LONGLONG traceSettings, BOOLEAN traceOn);
  172. STDMETHOD( CheckManagedResources )( void );
  173. STDMETHOD( InternalSavePersistData)( void );
  174. STDMETHOD( CancelMountingMedias ) (void);
  175. void StopAutosaveThread(void);
  176. void StopCheckManagedResourcesThread(void);
  177. protected:
  178. ULONG m_autosaveInterval; // Autosave interval in
  179. // milliseconds; 0 turns it off
  180. HANDLE m_autosaveThread;
  181. HANDLE m_savingEvent; // An event for synchronizing saving of persistent data
  182. HANDLE m_terminateEvent; // An event for signaling termination to the autosave thread
  183. HANDLE m_CheckManagedResourcesThread;
  184. GUID m_hId;
  185. CWsbStringPtr m_name;
  186. CWsbStringPtr m_dir;
  187. BOOL m_initializationCompleted;
  188. BOOL m_persistWasCreated; // TRUE if persistence file was created
  189. ULONG m_traceSettings;
  190. BOOL m_traceOn;
  191. BOOL m_cancelCopyMedia;
  192. BOOL m_inCopyMedia;
  193. BOOL m_Suspended;
  194. BOOL m_JobsEnabled; // Not persistent !!
  195. CWsbStringPtr m_dbPath;
  196. CComPtr<IHsmFsaTskMgr> m_pHsmFsaTskMgr;
  197. CComPtr<IRmsServer> m_pHsmMediaMgr;
  198. CRssJetWriter *m_pRssWriter;
  199. CComPtr<IWsbTrace> m_pTrace;
  200. CComPtr<IWsbDbSys> m_pDbSys;
  201. CComPtr<IWsbDb> m_pSegmentDatabase;
  202. CComPtr<IWsbIndexedCollection> m_pJobs;
  203. CComPtr<IWsbIndexedCollection> m_pJobDefs;
  204. CComPtr<IWsbIndexedCollection> m_pPolicies;
  205. CComPtr<IWsbIndexedCollection> m_pManagedResources;
  206. CComPtr<IWsbIndexedCollection> m_pStoragePools;
  207. CComPtr<IWsbIndexedCollection> m_pMessages;
  208. CComPtr<IWsbIndexedCollection> m_pOnlineInformation;
  209. CComPtr<IWsbIndexedCollection> m_pMountingMedias;
  210. LONG m_mediaCount;
  211. ULONG m_buildVersion;
  212. ULONG m_databaseVersion;
  213. ULONG m_copyfilesUserLimit;
  214. CRITICAL_SECTION m_JobDisableLock;
  215. CRITICAL_SECTION m_MountingMediasLock;
  216. BOOL m_bCritSecCreated;
  217. };
  218. class CHsmUpgradeRmsDb :
  219. public CWsbPersistable,
  220. public IHsmUpgradeRmsDb,
  221. public CComCoClass<CHsmUpgradeRmsDb,&CLSID_CHsmUpgradeRmsDb>
  222. {
  223. public:
  224. CHsmUpgradeRmsDb( ) {}
  225. BEGIN_COM_MAP( CHsmUpgradeRmsDb )
  226. COM_INTERFACE_ENTRY( IHsmUpgradeRmsDb )
  227. COM_INTERFACE_ENTRY2(IPersist, IPersistStream)
  228. COM_INTERFACE_ENTRY(IPersistStream)
  229. COM_INTERFACE_ENTRY(IPersistFile)
  230. COM_INTERFACE_ENTRY(IWsbPersistable)
  231. END_COM_MAP( )
  232. DECLARE_REGISTRY_RESOURCEID( IDR_HsmUpgradeRmsDb )
  233. // CComObjectRoot
  234. public:
  235. STDMETHOD(FinalConstruct)(void);
  236. void FinalRelease(void);
  237. // IPersist
  238. public:
  239. STDMETHOD(GetClassID)(LPCLSID pclsid);
  240. // IPersistStream
  241. public:
  242. STDMETHOD(GetSizeMax)(ULARGE_INTEGER* /*pSize*/) {
  243. return(E_NOTIMPL); }
  244. STDMETHOD(Load)(IStream* pStream);
  245. STDMETHOD(Save)(IStream* pStream, BOOL clearDirty);
  246. // IHsmUpgradeRmsDb
  247. STDMETHOD(Init)( IRmsServer *pHsmMediaMgr);
  248. private:
  249. IRmsServer *m_pServer;
  250. };
  251. #endif // _HSMSERV_H