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 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() { _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(); }
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(); }
public void CompleteRawChunk(TFChunk rawChunk) { rawChunk.Flush(); rawChunk.CompleteRaw(); _db.Manager.AddReplicatedChunk(rawChunk, verifyHash: true); _writerChunk = _db.Manager.AddNewChunk(); _writerPos = _writerChunk.ChunkHeader.ChunkStartNumber * (long)_db.Config.ChunkSize; _writerCheckpoint.Write(_writerPos); _writerCheckpoint.Flush(); }
public void Setup() { _prepare1 = new PrepareLogRecord(0, _corrId, _eventId, 0, "test", 1, new DateTime(2000, 1, 1, 12, 0, 0), PrepareFlags.None, "Foo", new byte[12], new byte[15]); _prepare2 = new PrepareLogRecord(0, _corrId, _eventId, 0, "test2", 2, new DateTime(2000, 1, 1, 12, 0, 0), PrepareFlags.None, "Foo2", new byte[12], new byte[15]); _chunk = TFChunk.CreateNew(_filename, 4096, 0, 0); var r1 = _chunk.TryAppend(_prepare1); _written1 = r1.Success; _position1 = r1.OldPosition; var r2 = _chunk.TryAppend(_prepare2); _written2 = r2.Success; _position2 = r2.OldPosition; _chunk.Flush(); }
public void CompleteRawChunk(TFChunk rawChunk) { rawChunk.Flush(); rawChunk.CompleteRaw(); _db.Manager.AddReplicatedChunk(rawChunk, verifyHash: true); _writerChunk = _db.Manager.AddNewChunk(); _writerPos = _writerChunk.ChunkHeader.ChunkStartNumber * (long)_db.Config.ChunkSize; _writerCheckpoint.Write(_writerPos); _writerCheckpoint.Flush(); }