Exemplo n.º 1
0
        internal NtfsEventStore(string basePath, bool dropEvents)
        {
            Directory.CreateDirectory(basePath);

            GlobalSequenceIndex = new GlobalSequenceIndex(basePath, dropEvents);
            DataStore = new DataStore(basePath, dropEvents);
            CommitLog = new CommitLog(basePath, dropEvents);
        }
Exemplo n.º 2
0
        public void DetectCorruptionAndRecover(DataStore store, long lastCommittedGlobalSequenceNumber)
        {
            var numberOfRecords = _writer.BaseStream.Length/SizeofSeqRecord;
            var expectedNumberOfRecords = lastCommittedGlobalSequenceNumber + 1;

            if (expectedNumberOfRecords == numberOfRecords)
                return;

            _writer.Dispose();

            foreach (var orphan in Read(long.MaxValue, lastCommittedGlobalSequenceNumber + 1))
            {
                store.Truncate(orphan.AggregateRootId, orphan.LocalSequenceNumber);
            }

            using (var stream = new FileStream(_seqFilePath, FileMode.Open, FileSystemRights.Write, FileShare.Read, 1024, FileOptions.None))
            {
                stream.SetLength(expectedNumberOfRecords * SizeofSeqRecord);
                stream.Flush();
            }

            OpenWriter();        
        }
Exemplo n.º 3
0
        public IEnumerable <EventData> Load(string aggregateRootId, long firstSeq = 0)
        {
            var lastCommittedGlobalSequenceNumber = CommitLog.Read();

            return(DataStore.Read(lastCommittedGlobalSequenceNumber, aggregateRootId, firstSeq));
        }