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.

198 lines
6.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: cibackup.cxx
  7. //
  8. // Contents: Content Index index migration
  9. //
  10. // Classes:
  11. //
  12. // History: 3-17-97 srikants Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <pch.cxx>
  16. #pragma hdrstop
  17. #include <pstore.hxx>
  18. #include <pidxtbl.hxx>
  19. #include "cibackup.hxx"
  20. #include "resman.hxx"
  21. #include "indsnap.hxx"
  22. #include "partn.hxx"
  23. #include "fresh.hxx"
  24. //+---------------------------------------------------------------------------
  25. //
  26. // Member: CBackupCiWorkItem::CBackupCiWorkItem
  27. //
  28. // Synopsis: Constructor of the backup save work item.
  29. //
  30. // Arguments: [storage] - Destination storage object.
  31. // [fFullSave] - Indicating if a full save is needed.
  32. // [progressTracker] - Progress tracking object.
  33. //
  34. // History: 3-18-97 srikants Created
  35. //
  36. //----------------------------------------------------------------------------
  37. CBackupCiWorkItem::CBackupCiWorkItem( PStorage & storage,
  38. BOOL fFullSave,
  39. PSaveProgressTracker & progressTracker )
  40. : _status(STATUS_UNSUCCESSFUL),
  41. _storage(storage),
  42. _fFull(fFullSave),
  43. _progressTracker(progressTracker),
  44. _fDoingFull(FALSE),
  45. _backupState(eNotStarted)
  46. {
  47. _evtDone.Reset();
  48. }
  49. //+---------------------------------------------------------------------------
  50. //
  51. // Member: CBackupCiPersData::CBackupCiPersData
  52. //
  53. // Synopsis: An object that backups the relevant CI persistent data.
  54. //
  55. // Arguments: [workItem] - The workitem having details of the save operation.
  56. // [resman] - Resman reference.
  57. // [partn] - The partition that must be saved.
  58. //
  59. // History: 3-18-97 srikants Created
  60. //
  61. // Notes: We are assuming that changelog need not be saved. This is
  62. // certainly true for the Incremental Index Shipping feature of
  63. // Normandy.
  64. //
  65. // We are also assuming that for an incremental save, the
  66. // destination has the same master index id as this. This
  67. // assumption allows us to save the index table and the
  68. // persistent freshlog without any transformation. If the
  69. // destination misses even one "full" save in a sequence,
  70. // a full save MUST be done.
  71. //
  72. // These limitations can be removed when KyleP does the complete
  73. // implementation of incremental indexing.
  74. //
  75. //----------------------------------------------------------------------------
  76. CBackupCiPersData::CBackupCiPersData(
  77. CBackupCiWorkItem & workItem,
  78. CResManager & resman,
  79. CPartition & partn )
  80. : _workItem( workItem ),
  81. _pIndSnap( 0 ),
  82. _resman( resman ),
  83. _partn(partn),
  84. _indexTable( resman.GetIndexTable() ),
  85. _fresh( resman.GetFresh() )
  86. {
  87. }
  88. //+---------------------------------------------------------------------------
  89. //
  90. // Member: CBackupCiPersData::~CBackupCiPersData
  91. //
  92. // Synopsis: Destroys the saved index snap shot.
  93. //
  94. // History: 3-18-97 srikants Created
  95. //
  96. //----------------------------------------------------------------------------
  97. CBackupCiPersData::~CBackupCiPersData()
  98. {
  99. delete _pIndSnap;
  100. }
  101. //+---------------------------------------------------------------------------
  102. //
  103. // Member: CBackupCiPersData::LokGrabResources
  104. //
  105. // Synopsis: Grabs the persistent indexes that must be backed up.
  106. //
  107. // History: 3-18-97 srikants Created
  108. //
  109. //----------------------------------------------------------------------------
  110. void CBackupCiPersData::LokGrabResources()
  111. {
  112. //
  113. // First Create a new Index SnapShot depending upon the
  114. // type of backup.
  115. //
  116. Win4Assert( 0 == _pIndSnap );
  117. _pIndSnap = new CIndexSnapshot( _resman );
  118. _pIndSnap->LokInitForBackup( _partn, _workItem.IsFullSave() );
  119. }
  120. //+---------------------------------------------------------------------------
  121. //
  122. // Member: CBackupCiPersData::BackupIndexes
  123. //
  124. // Synopsis: Backs up the relevant persistent indexes.
  125. //
  126. // History: 3-18-97 srikants Created
  127. //
  128. //----------------------------------------------------------------------------
  129. void CBackupCiPersData::BackupIndexes()
  130. {
  131. //
  132. // For each index in the snapshot, create a backup copy.
  133. //
  134. unsigned cInd;
  135. CIndex ** apIndexes = _pIndSnap->LokGetIndexes( cInd );
  136. Win4Assert( cInd <= 1 );
  137. for ( unsigned i = 0; i < cInd; i++ )
  138. {
  139. Win4Assert( apIndexes[i]->IsPersistent() );
  140. PStorage::EDefaultStrmType strmType = PStorage::eNonSparseIndex;
  141. WORKID wid = _workItem.GetStorage().CreateObjectId( apIndexes[i]->GetId(),
  142. strmType );
  143. apIndexes[i]->MakeBackupCopy( _workItem.GetStorage(),
  144. wid,
  145. _workItem.GetSaveProgressTracker() );
  146. }
  147. }
  148. //+---------------------------------------------------------------------------
  149. //
  150. // Member: CBackupCiPersData::LokBackupMetaInfo
  151. //
  152. // Synopsis: Backs up the persistent fresh log and the index table.
  153. // Also collects the workids in the fresh log to indicate the
  154. // changed workid.
  155. //
  156. // Arguments: [aWids] - On output, will have the modified list of workids.
  157. //
  158. // History: 3-18-97 srikants Created
  159. //
  160. //----------------------------------------------------------------------------
  161. void CBackupCiPersData::LokBackupMetaInfo()
  162. {
  163. _fresh.LokMakeFreshLogBackup( _workItem.GetStorage(),
  164. _workItem.GetSaveProgressTracker(),
  165. _workItem.GetWorkidsIf() );
  166. //
  167. // Create a backup of the Index Table.
  168. //
  169. _indexTable.LokMakeBackupCopy( _workItem.GetStorage(),
  170. _workItem.IsFullSave(),
  171. _workItem.GetSaveProgressTracker() );
  172. }