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.

211 lines
7.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1998.
  5. //
  6. // File: DQUEUE.HXX
  7. //
  8. // Contents: Document queue
  9. //
  10. // Classes: CDocQueue
  11. //
  12. // History: 29-Mar-91 BartoszM Created
  13. // 13-Sep-93 BartoszM Took a second look and rewrote it
  14. // 11-Oct-93 BartoszM Rewrote it again.
  15. // 08-Feb-94 DwightKr Added code to make it persistent and
  16. // recoverable
  17. // 21-May-94 SrikantS Redesigned the list structure to make
  18. // persistent change log clearer.
  19. // 24-Feb-97 SitaramR Push filtering
  20. //
  21. //----------------------------------------------------------------------------
  22. #pragma once
  23. #include <glbconst.hxx>
  24. #include <frmutils.hxx>
  25. #include <pstore.hxx>
  26. #include <rcstxact.hxx>
  27. #include <rcstrmit.hxx>
  28. #include "changlog.hxx"
  29. class CChangeTrans;
  30. class CFreshTest;
  31. class CResManager;
  32. class CNotificationTransaction;
  33. //+---------------------------------------------------------------------------
  34. //
  35. // Class: CDocQueue
  36. //
  37. // Purpose: A queue of outstanding updates
  38. //
  39. // Notes: The CDocQueue data-structure manages the change notifications
  40. // received for documents. It acts as a "cache" for the change
  41. // log which stores the change notifications persistently. It
  42. // is optimized to use only a small amount of memory and use
  43. // this memory to provide a "window" into the change log.
  44. //
  45. // The CDocQueue consists of two in-memory lists of "chunks"
  46. // and a "CChangeLog" object for managing the on-disk contents.
  47. // There is a "serializedList" of CDocChunk objects and an
  48. // "unserializedList" of CDocChunk objects. All the chunks in
  49. // the "serializedList" are present in memory as well as in the
  50. // change log. However, the chunks in the "unserializedList" are
  51. // NOT logged yet.
  52. //
  53. // At any given instant, we are either retrieving from the
  54. // "serializedList" or the "unserializedList". This is identified
  55. // by the state variable "_state".
  56. //
  57. // History: 02-Aug-91 BartoszM Created.
  58. // 11-Oct-93 BartoszM Rewrote
  59. // 21-May-94 SrikantS Redesigned.
  60. //
  61. //----------------------------------------------------------------------------
  62. class CExtractDocs;
  63. class CDocList;
  64. const LONGLONG eSigDocQueue = 0x4555455551434f44i64; // "DOCQUEUE"
  65. class CDocQueue : INHERIT_UNWIND
  66. {
  67. DECLARE_UNWIND
  68. friend class CExtractDocs;
  69. public:
  70. CDocQueue( WORKID, PStorage &,
  71. PStorage::EChangeLogType type,
  72. CCiFrameworkParams & frmwrkParams );
  73. ~CDocQueue();
  74. void LokEmpty();
  75. NTSTATUS LokDismount( CChangeTrans & xact );
  76. unsigned Count() const { return _cDocuments; }
  77. BOOL IsEmpty () const
  78. {
  79. return ( 0 == _cDocuments ) && ( 0 == _cRefiledDocs ) ;
  80. }
  81. SCODE Append ( CChangeTrans & xact,
  82. WORKID wid,
  83. USN usn,
  84. VOLUMEID volumeId,
  85. ULONG action,
  86. ULONG cRetries,
  87. ULONG cSecQRetries );
  88. BOOL Get( WORKID * aWid, unsigned & cWid );
  89. void Extract ( CChangeTrans & xact,
  90. unsigned maxDocs,
  91. CDocList& docList );
  92. void LokRefileDocs( const CDocList & docList );
  93. void LokAppendRefiledDocs( CChangeTrans & xact );
  94. void LokDeleteWIDsInPersistentIndexes( CChangeTrans & xact,
  95. CFreshTest & freshTestLatest,
  96. CFreshTest & freshTestAtMerge,
  97. CDocList & docList,
  98. CNotificationTransaction & notifTrans );
  99. void LokDisableUpdates();
  100. void LokEnableUpdates( BOOL fFirstTimeUpdatesAreEnabled );
  101. void LokFlushUpdates();
  102. #ifdef CIEXTMODE
  103. void CiExtDump(void *ciExtSelf);
  104. #endif
  105. void SetResMan( CResManager * pResManager, BOOL fPushFiltering )
  106. {
  107. Win4Assert( 0 == _pResManager );
  108. _pResManager = pResManager;
  109. _changeLog.SetResMan( pResManager, fPushFiltering );
  110. }
  111. private:
  112. enum ERetrieveState {
  113. eUseSerializedList, // State in which documents are being
  114. // retrieved from the serialized list.
  115. eUseUnSerializedList // State in which documents are being
  116. // retrieved from the unserialized list.
  117. };
  118. BOOL IsAppendChunkFull()
  119. {
  120. Win4Assert( _oAppend <= cDocInChunk );
  121. return (cDocInChunk == _oAppend) ||
  122. (0 == _unserializedList.GetLast()) ;
  123. }
  124. CDocChunk * GetChunkToAppend()
  125. {
  126. return( _unserializedList.GetLast() );
  127. }
  128. void Serialize( ULONG nMaxChunksToKeep );
  129. void DeSerialize();
  130. void SerializeInLHS( ULONG nMaxChunksToKeep,
  131. CCountedDynArray<CUsnFlushInfo> & aUsnFlushInfo );
  132. void SerializeInRHS( ULONG nMaxChunksToKeep,
  133. CCountedDynArray<CUsnFlushInfo> & aUsnFlushInfo );
  134. void MoveToSerializedList( CChunkList & listToCompact,
  135. ULONG nMaxChunksToKeep );
  136. void LokCleanup();
  137. void LokInit();
  138. void CheckInvariants( char *pTag = 0 ) const;
  139. const LONGLONG _sigDocQueue; // Signature
  140. CCiFrameworkParams & _frmwrkParams; // registry params
  141. ERetrieveState _state; // State indicating whether we
  142. // should consume from the
  143. // archived list or the non-
  144. // archived list.
  145. ULONG _oAppend; // Offset in the chunk
  146. // to append.
  147. ULONG _oRetrieve; // Offset in the first unfiltered
  148. // chunk to retrieve from.
  149. CDocChunk * _pFirstUnFiltered; // First unfiltered chunk.
  150. CChangeLog _changeLog; // Change log manager.
  151. CChunkList _serializedList; // Chunks that have already
  152. // been serialized.
  153. CChunkList _unserializedList; // Chunks that have not been
  154. // serialized.
  155. unsigned _cDocuments; // # of documents
  156. unsigned _cFilteredChunks; // # of filtered chunks
  157. CDocNotification _aRefiledDocs[CI_MAX_DOCS_IN_WORDLIST];
  158. // Array of refiled documents.
  159. unsigned _cRefiledDocs; // Number of refiled docs.
  160. CResManager * _pResManager; // Resource manager
  161. };