Beispiel #1
0
        /// <summary>
        /// Complete the change by copying the temporary buffer to the actual parity
        /// </summary>
        public void Save()
        {
            DateTime start = DateTime.Now;

            byte[] data = new byte[Parity.BLOCK_SIZE];
            try {
                saveBlock = startBlock;
                UInt32 endBlock = block;
                if (mmfStream != null)
                {
                    mmfStream.Seek(0, SeekOrigin.Begin); // return MMF stream to its start (it may still be at the end if on-disk temp was never used)
                    while (saveBlock < endBlock && saveBlock < lastMMFBlock)
                    {
                        mmfStream.Read(data, 0, Parity.BLOCK_SIZE);
                        parity.WriteBlock(saveBlock, data);
                        saveBlock++;
                    }
                    FreeMMF();
                }
                if (tempFileStream != null)
                {
#if DEBUG
                    LogFile.Log("Flushing MMF parity took {0} seconds", (DateTime.Now - start).TotalSeconds);
#endif
                    tempFileStream.Seek(0, SeekOrigin.Begin);
                    while (saveBlock < endBlock)
                    {
                        tempFileStream.Read(data, 0, Parity.BLOCK_SIZE);
                        parity.WriteBlock(saveBlock, data);
                        saveBlock++;
                    }
                }
            }
            catch (Exception e) {
                LogFile.Log("Fatal error in ParityChange.Save(): " + e.Message);
                throw new Exception("A fatal error occurred (" + e.Message + ") when writing to parity.  Parity data may be damaged.", e);
            }
        }
Beispiel #2
0
 public bool Write(UInt32 block)
 {
     return(parity.WriteBlock(block, data));
 }