Exemplo n.º 1
0
        public bool Write(LogRecord record, out long newPos)
        {
            var chunkNum = (int)(_writerPos / _db.Config.ChunkSize);
            var chunkPos = _writerPos % _db.Config.ChunkSize;

            var result = _writerChunk.TryAppend(record);

            if (result.Success)
            {
                Debug.Assert(result.OldPosition == chunkPos);
                _writerPos = chunkNum * (long)_db.Config.ChunkSize + result.NewPosition;
            }
            else
            {
                _writerChunk.Flush();
                _writerChunk.Complete();
                _writerChunk = _db.Manager.AddNewChunk();
                //_writerCheckpoint.Flush(); //flush our checkpoint
                _writerPos = _writerChunk.ChunkHeader.ChunkStartNumber * (long)_db.Config.ChunkSize; // we just moved to a new chunk at pos 0
                //GFY CANT USE chunkNum here (it could be exact at end)
            }
            _writerCheckpoint.Write(_writerPos);
            newPos = _writerPos;
            return(result.Success);
        }
 public void Setup()
 {
     _record = new PrepareLogRecord(0, _corrId, _eventId, 0, 0, "test", 1, new DateTime(2000, 1, 1, 12, 0, 0),
                                    PrepareFlags.None, "Foo", new byte[12], new byte[15]);
     _chunk = TFChunk.CreateNew(_filename, 4096, 0, 0);
     _result = _chunk.TryAppend(_record);
     _chunk.Flush();
     _chunk.Complete();
     _cachedChunk = TFChunk.FromCompletedFile(_filename, verifyHash: true);
     _cachedChunk.CacheInMemory();
 }
Exemplo n.º 3
0
        public void CompleteChunk()
        {
            _writerChunk.Flush();
            _writerChunk.Complete();
            _writerCheckpoint.Flush(); //flush our checkpoint

            _writerChunk = _db.Manager.AddNewChunk();
            _writerPos   = _writerChunk.ChunkHeader.ChunkStartNumber * (long)_db.Config.ChunkSize;

            _writerCheckpoint.Write(_writerPos);
        }
 public void Setup()
 {
     _chunk = TFChunk.CreateNew(_filename, 4096, 0, 0);
     _chunk.Complete();
     _testChunk = TFChunk.FromCompletedFile(_filename, verifyHash: true);
 }
 public void Setup()
 {
     _chunk = TFChunk.CreateNew(filename, 4096, 0, 0);
     _chunk.Complete();
     _testChunk = TFChunk.FromCompletedFile(filename);
 }