Ejemplo n.º 1
0
        // newSegmentFile will close the current segment file and open a new one, updating bookkeeping info on the log.
        private void newSegmentFile()
        {
            currentSegmentID++;
            if (currentSegmentWriter != null)
            {
                currentSegmentWriter.Flush();
                currentSegmentWriter.Close();
                Interlocked.Add(ref stats.OldBytes, currentSegmentWriter.Size);
            }

            string     fileName = string.Format("{0}{1}{2:D5}.{3}", Path, Constants.WALFilePrefix, currentSegmentID, Constants.WALFileExtension);
            FileStream fd       = File.Create(fileName);

            currentSegmentWriter = new WalSegmentWriter(fd);

            LastWriteTime = DateTime.Now.Ticks;

            // Reset the current segment size stat
            Interlocked.Add(ref stats.CurrentBytes, 0);
        }