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.

247 lines
11 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. hsmWorkQ.h
  5. Abstract:
  6. This header file defines the CHsmWorkQueue object, which is used by the HSM
  7. Engine to direct work to be performed by the Remote Storage system.
  8. Author:
  9. Cat Brant [cbrant] 24-Jan-1997
  10. Revision History:
  11. --*/
  12. #include "resource.h" // main symbols
  13. #include "wsb.h" // Wsb structure definitions
  14. #include "rms.h" // RMS structure definitions
  15. #include "job.h" // RMS structure definitions
  16. #include "metalib.h" // metadata library structure definitions
  17. #include "fsalib.h" // FSA structure definitions
  18. #include "tsklib.h" // FSA structure definitions
  19. #include "mvrint.h" // Datamover interface
  20. #ifndef __HSMWORKQUEUE__
  21. #define __HSMWORKQUEUE__
  22. /////////////////////////////////////////////////////////////////////////////
  23. // task
  24. // Error reporting flags
  25. #define QUEUE_REPORT_PASS_QUOTA_LIMIT_FLAG 0x00000001
  26. class CHsmWorkQueue :
  27. public CComObjectRoot,
  28. public IHsmWorkQueue,
  29. public IHsmSessionSinkEveryEvent,
  30. public IHsmSessionSinkEveryState,
  31. public CComCoClass<CHsmWorkQueue,&CLSID_CHsmWorkQueue>
  32. {
  33. public:
  34. CHsmWorkQueue() {}
  35. BEGIN_COM_MAP(CHsmWorkQueue)
  36. COM_INTERFACE_ENTRY(IHsmWorkQueue)
  37. COM_INTERFACE_ENTRY(IHsmSessionSinkEveryEvent)
  38. COM_INTERFACE_ENTRY(IHsmSessionSinkEveryState)
  39. END_COM_MAP()
  40. DECLARE_REGISTRY_RESOURCEID( IDR_CHsmWorkQueue )
  41. // IHsmWorkQueue
  42. public:
  43. STDMETHOD(FinalConstruct)(void);
  44. STDMETHOD(FinalRelease)(void);
  45. STDMETHOD(Add)(IFsaPostIt *pFsaWorkItem);
  46. STDMETHOD(Init)(IUnknown *pServer, IHsmSession *pSession, IHsmFsaTskMgr *pTskMgr,
  47. HSM_WORK_QUEUE_TYPE type);
  48. STDMETHOD(Start)( void );
  49. STDMETHOD(Stop)( void );
  50. STDMETHOD(ContactOk)( void );
  51. STDMETHOD(GetCurrentSessionId)(GUID *pSessionId);
  52. STDMETHOD(GetNumWorkItems)(ULONG *pNumWorkItems);
  53. STDMETHOD(ProcessSessionEvent)(IHsmSession *pSession, HSM_JOB_PHASE phase,
  54. HSM_JOB_EVENT event);
  55. STDMETHOD(ProcessSessionState)(IHsmSession* pSession, IHsmPhase* pPhase,
  56. OLECHAR* currentPath);
  57. STDMETHOD(RaisePriority)(void);
  58. STDMETHOD(Remove)(IHsmWorkItem *pWorkItem);
  59. STDMETHOD(LowerPriority)(void);
  60. // IHsmSystemState
  61. STDMETHOD( ChangeSysState )( HSM_SYSTEM_STATE* pSysState );
  62. // Internal Helper functions
  63. STDMETHOD(PremigrateIt)( IFsaPostIt *pFsaWorkItem );
  64. STDMETHOD(RecallIt)( IFsaPostIt *pFsaWorkItem );
  65. STDMETHOD(validateIt)(IFsaPostIt *pFsaWorkItem );
  66. STDMETHOD(CheckForChanges)(IFsaPostIt *pFsaWorkItem);
  67. STDMETHOD(CheckForDiskSpace)(void);
  68. STDMETHOD(CheckRms)(void);
  69. STDMETHOD(CheckSession)(IHsmSession* pSessionUnknown);
  70. STDMETHOD(StartNewBag)(void);
  71. STDMETHOD(StartNewMedia)(IFsaPostIt *pFsaWorkItem);
  72. STDMETHOD(StartNewSession)(void);
  73. STDMETHOD(UpdateBagInfo)(IHsmWorkItem *pWorkItem );
  74. STDMETHOD(CompleteBag)( void );
  75. STDMETHOD(UpdateSegmentInfo)(IHsmWorkItem *pWorkItem );
  76. STDMETHOD(UpdateMediaInfo)(IHsmWorkItem *pWorkItem );
  77. STDMETHOD(UpdateMetaData)(IHsmWorkItem *pWorkItem );
  78. STDMETHOD(GetMediaSet)(IFsaPostIt *pFsaWorkItem );
  79. STDMETHOD(FindMigrateMediaToUse)(IFsaPostIt *pFsaWorkItem, GUID *pMediaToUse, GUID *pFirstSideToUse, BOOL *pMediaChanged, LONGLONG *pRequiredSize);
  80. STDMETHOD(FindRecallMediaToUse)(IFsaPostIt *pFsaWorkItem, GUID *pMediaToUse, BOOL *pMediaChanged);
  81. STDMETHOD(MountMedia)(IFsaPostIt *pFsaWorkItem, GUID mediaToMount, GUID firstSide = GUID_NULL,
  82. BOOL bShortWait = FALSE, BOOL bSerialize = FALSE, LONGLONG llFreeSpace = 0);
  83. STDMETHOD(MarkMediaFull)(IFsaPostIt *pFsaWorkItem, GUID mediaToMark );
  84. STDMETHOD(MarkMediaBad)(IFsaPostIt *pFsaWorkItem, GUID mediaToMark, HRESULT lastError);
  85. STDMETHOD(GetSource)(IFsaPostIt *pFsaWorkItem, OLECHAR **pSourceString);
  86. STDMETHOD(EndSessions)(BOOL done, BOOL bNoDelay);
  87. STDMETHOD(GetScanItem)(IFsaPostIt *fsaWorkItem, IFsaScanItem** ppIFsaScanItem);
  88. STDMETHOD(DoWork)(void);
  89. STDMETHOD(DoFsaWork)(IHsmWorkItem *pWorkItem);
  90. STDMETHOD(SetState)(HSM_JOB_STATE state);
  91. STDMETHOD(Pause)(void);
  92. STDMETHOD(Resume)(void);
  93. STDMETHOD(Cancel)(void);
  94. STDMETHOD(FailJob)(void);
  95. STDMETHOD(PauseScanner)(void);
  96. STDMETHOD(ResumeScanner)(void);
  97. STDMETHOD(BuildMediaName)(OLECHAR **pMediaName);
  98. STDMETHOD(GetMediaParameters)(LONGLONG defaultFreeSpace = -1);
  99. STDMETHOD(DismountMedia)(BOOL bNoDelay = FALSE);
  100. STDMETHOD(ConvertRmsCartridgeType)(LONG rmsCartridgeType,
  101. HSM_JOB_MEDIA_TYPE *pMediaType);
  102. void (ReportMediaProgress)(HSM_JOB_MEDIA_STATE state, HRESULT status);
  103. STDMETHOD(MarkQueueAsDone)( void );
  104. STDMETHOD(CopyToWaitingQueue)( IHsmWorkItem *pWorkItem );
  105. STDMETHOD(CompleteWorkItem)( IHsmWorkItem *pWorkItem );
  106. STDMETHOD(TimeToCommit)( void );
  107. STDMETHOD(TimeToCommit)( LONGLONG numFiles, LONGLONG amountOfData );
  108. STDMETHOD(CommitWork)(void);
  109. STDMETHOD(CheckMigrateMinimums)(void);
  110. STDMETHOD(CheckRegistry)(void);
  111. STDMETHOD(TranslateRmsMountHr)(HRESULT rmsHr);
  112. STDMETHOD(StoreDatabasesOnMedia)( void );
  113. STDMETHOD(StoreDataWithRetry)(BSTR localName, ULARGE_INTEGER localDataStart,
  114. ULARGE_INTEGER localDataSize, DWORD flags, ULARGE_INTEGER *pRemoteDataSetStart,
  115. ULARGE_INTEGER *pRemoteFileStart, ULARGE_INTEGER *pRemoteFileSize,
  116. ULARGE_INTEGER *pRemoteDataStart, ULARGE_INTEGER *pRemoteDataSize,
  117. DWORD *pRemoteVerificationType, ULARGE_INTEGER *pRemoteVerificationData,
  118. DWORD *pDatastreamCRCType, ULARGE_INTEGER *pDatastreamCRC, ULARGE_INTEGER *pUsn,
  119. BOOL *bFullMessage);
  120. STDMETHOD(ShouldJobContinue)(HRESULT problemHr);
  121. STDMETHOD(UnsetMediaInfo)(void);
  122. STDMETHOD(UpdateMediaFreeSpace)(void);
  123. STDMETHOD(GetMediaFreeSpace)(LONGLONG *pFreeSpace);
  124. // Data
  125. // We want the next pointers (to the Hsm Server) to be weak
  126. // references and **not** add ref the object. This is so shutting
  127. // down the server really works.
  128. IHsmServer *m_pServer;
  129. IWsbCreateLocalObject *m_pHsmServerCreate;
  130. IHsmFsaTskMgr *m_pTskMgr;
  131. CComPtr<IFsaResource> m_pFsaResource;
  132. CComPtr<IHsmSession> m_pSession;
  133. CComPtr<IRmsServer> m_pRmsServer;
  134. CComPtr<IRmsCartridge> m_pRmsCartridge;
  135. CComPtr<IDataMover> m_pDataMover;
  136. // Databases
  137. CComPtr<IWsbDb> m_pSegmentDb;
  138. CComPtr<IWsbDbSession> m_pDbWorkSession;
  139. CComPtr<IWsbIndexedCollection> m_pStoragePools;
  140. CComPtr<IWsbIndexedCollection> m_pWorkToDo;
  141. CComPtr<IWsbIndexedCollection> m_pWorkToCommit;
  142. // Data mover info
  143. GUID m_BagId;
  144. GUID m_MediaId;
  145. GUID m_MountedMedia;
  146. HSM_JOB_MEDIA_TYPE m_MediaType;
  147. CWsbStringPtr m_MediaName;
  148. CWsbStringPtr m_MediaBarCode;
  149. LONGLONG m_MediaFreeSpace;
  150. LONGLONG m_MediaCapacity;
  151. BOOL m_MediaReadOnly;
  152. GUID m_HsmId;
  153. ULARGE_INTEGER m_RemoteDataSetStart;
  154. GUID m_RmsMediaSetId;
  155. CWsbBstrPtr m_RmsMediaSetName;
  156. SHORT m_RemoteDataSet;
  157. FSA_REQUEST_ACTION m_RequestAction;
  158. HSM_WORK_QUEUE_TYPE m_QueueType;
  159. HRESULT m_BadMedia;
  160. FILETIME m_MediaUpdate;
  161. HRESULT m_BeginSessionHr;
  162. // Session reporting information
  163. DWORD m_StateCookie;
  164. DWORD m_EventCookie;
  165. HSM_JOB_PRIORITY m_JobPriority;
  166. HSM_JOB_ACTION m_JobAction;
  167. HSM_JOB_STATE m_JobState;
  168. HSM_JOB_PHASE m_JobPhase;
  169. HANDLE m_WorkerThread;
  170. BOOL m_TerminateQueue; // True only if the queue should terminate while
  171. // there is still work in progress
  172. CWsbStringPtr m_CurrentPath;
  173. CWsbStringPtr m_MediaBaseName;
  174. // Minimum migrate parameters
  175. ULONG m_MinBytesToMigrate;
  176. ULONG m_MinFilesToMigrate;
  177. // Commit parameters
  178. // Force a commit after writing this many bytes:
  179. ULONG m_MaxBytesBeforeCommit;
  180. // Don't commit unless we've written at least this many bytes:
  181. ULONG m_MinBytesBeforeCommit;
  182. // Force a commit after writing this many files IF also m_MinBytesBeforeCommit:
  183. ULONG m_FilesBeforeCommit;
  184. // Force a commit if free bytes on media is less than this IF also m_MinBytesBeforeCommit:
  185. ULONG m_FreeMediaBytesAtEndOfMedia;
  186. LONGLONG m_DataCountBeforeCommit;
  187. LONGLONG m_FilesCountBeforeCommit;
  188. BOOL m_StoreDatabasesInBags;
  189. // Pause/Resume parameters
  190. ULONG m_QueueItemsToPause;
  191. ULONG m_QueueItemsToResume;
  192. BOOL m_ScannerPaused;
  193. // Job abort on errors parameters
  194. ULONG m_JobAbortMaxConsecutiveErrors;
  195. ULONG m_JobAbortMaxTotalErrors;
  196. ULONG m_JobConsecutiveErrors;
  197. ULONG m_JobTotalErrors;
  198. ULONG m_JobAbortSysDiskSpace;
  199. // Media id parameters
  200. LONG m_mediaCount;
  201. BOOL m_ScratchFailed;
  202. // Full media watermark parameters:
  203. // Stop storing data after reaching this percent of free space
  204. ULONG m_MinFreeSpaceInFullMedia;
  205. // Mark media as full after reaching this percent of free space
  206. ULONG m_MaxFreeSpaceInFullMedia;
  207. // Job reporting flags
  208. ULONG m_uErrorReportFlags;
  209. };
  210. #endif // __HSMWORKQUEUE__