本文整理汇总了C#中PrepareLogRecord类的典型用法代码示例。如果您正苦于以下问题:C# PrepareLogRecord类的具体用法?C# PrepareLogRecord怎么用?C# PrepareLogRecord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrepareLogRecord类属于命名空间,在下文中一共展示了PrepareLogRecord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
_record = 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]);
_chunk = Core.TransactionLog.Chunks.TFChunk.CreateNew(_filename, 4096, 0, 0);
_result = _chunk.TryAppend(_record);
}
示例2: SetUp
public void SetUp()
{
_writerCheckpoint = new InMemoryCheckpoint();
_db = new TFChunkDb(new TFChunkDbConfig(PathName,
new VersionedPatternFileNamingStrategy(PathName, "chunk-"),
1024,
0,
_writerCheckpoint,
new InMemoryCheckpoint(),
new InMemoryCheckpoint(-1),
new InMemoryCheckpoint(-1)));
_db.Open();
_writer = new TFChunkWriter(_db);
_writer.Open();
_record = new PrepareLogRecord(logPosition: 0,
eventId: _eventId,
correlationId: _correlationId,
transactionPosition: 0xDEAD,
transactionOffset: 0xBEEF,
eventStreamId: "WorldEnding",
expectedVersion: 1234,
timeStamp: new DateTime(2012, 12, 21),
flags: PrepareFlags.SingleWrite,
eventType: "type",
data: new byte[] { 1, 2, 3, 4, 5 },
metadata: new byte[] {7, 17});
long newPos;
_writer.Write(_record, out newPos);
_writer.Flush();
}
示例3: Setup
public void Setup()
{
var record = new PrepareLogRecord(15556, _corrId, _eventId, 15556, 0, "test", 1, new DateTime(2000, 1, 1, 12, 0, 0),
PrepareFlags.None, "Foo", new byte[12], new byte[15]);
_chunk = TFChunk.CreateNew(_filename, 20, 0, 0);
_written = _chunk.TryAppend(record).Success;
}
示例4: a_record_can_be_written
public void a_record_can_be_written()
{
var filename = Path.Combine(PathName, "prefix.tf0");
File.WriteAllBytes(filename, new byte[10000]);
_checkpoint = new InMemoryCheckpoint(137);
var tf = new MultifileTransactionFileWriter(new TransactionFileDatabaseConfig(PathName, "prefix.tf", 10000, _checkpoint, new List<ICheckpoint>()));
tf.Open();
var record = new PrepareLogRecord(logPosition: 0,
correlationId: _correlationId,
eventId: _eventId,
expectedVersion: 1234,
transactionPosition: 0,
transactionOffset: 0,
eventStreamId: "WorldEnding",
timeStamp: new DateTime(2012, 12, 21),
flags: PrepareFlags.None,
eventType: "type",
data: new byte[] { 1, 2, 3, 4, 5 },
metadata: new byte[] {7, 17});
long tmp;
tf.Write(record, out tmp);
tf.Flush();
tf.Close();
Assert.AreEqual(record.GetSizeWithLengthPrefixAndSuffix() + 137, _checkpoint.Read()); //137 is fluff assigned to beginning of checkpoint
//TODO actually read the event
using (var filestream = File.Open(filename, FileMode.Open, FileAccess.Read))
{
filestream.Seek(137 + sizeof(int), SeekOrigin.Begin);
var reader = new BinaryReader(filestream);
var read = LogRecord.ReadFrom(reader);
Assert.AreEqual(record, read);
}
}
开发者ID:soto,项目名称:EventStore,代码行数:33,代码来源:when_writing_an_existing_multifile_transaction_file_with_checksum.cs
示例5: a_record_can_be_written
public void a_record_can_be_written()
{
_checkpoint = new InMemoryCheckpoint(0);
var tf = new MultifileTransactionFileWriter(
new TransactionFileDatabaseConfig(PathName, "prefix.tf", 10000, _checkpoint, new List<ICheckpoint>()));
tf.Open();
var record = new PrepareLogRecord(logPosition: 0,
correlationId: _correlationId,
eventId: _eventId,
transactionPosition: 0,
transactionOffset: 0,
eventStreamId: "WorldEnding",
expectedVersion: 1234,
timeStamp: new DateTime(2012, 12, 21),
flags: PrepareFlags.None,
eventType: "type",
data: new byte[] { 1, 2, 3, 4, 5 },
metadata: new byte[] {7, 17});
long tmp;
tf.Write(record, out tmp);
tf.Close();
Assert.AreEqual(record.GetSizeWithLengthPrefixAndSuffix(), _checkpoint.Read());
using (var filestream = File.Open(Path.Combine(PathName, "prefix.tf0"), FileMode.Open, FileAccess.Read))
{
var reader = new BinaryReader(filestream);
reader.ReadInt32();
var read = LogRecord.ReadFrom(reader);
Assert.AreEqual(record, read);
}
}
示例6: TestFixtureSetUp
public override void TestFixtureSetUp()
{
base.TestFixtureSetUp();
_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, false);
_result = _chunk.TryAppend(_record);
}
示例7: WriteDeleteCommit
private CommitLogRecord WriteDeleteCommit(PrepareLogRecord prepare)
{
long pos;
var commit = LogRecord.Commit(WriterChecksum.ReadNonFlushed(),
prepare.CorrelationId,
prepare.LogPosition,
EventNumber.DeletedStream);
Assert.IsTrue(Writer.Write(commit, out pos));
return commit;
}
开发者ID:base31,项目名称:geteventstore_EventStore,代码行数:11,代码来源:when_deleting_single_stream_spanning_through_2_chunks_in_2nd_chunk__in_db_with_3_chunks.cs
示例8: Setup
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();
}
示例9: StreamEventAppeared
public StreamEventAppeared(int eventNumber, PrepareLogRecord prepareLogRecord, long commitPosition)
{
EventStreamId = prepareLogRecord.EventStreamId;
EventNumber = eventNumber;
EventId = prepareLogRecord.EventId.ToByteArray();
EventType = prepareLogRecord.EventType;
Data = prepareLogRecord.Data;
Metadata = prepareLogRecord.Metadata;
PreparePosition = prepareLogRecord.LogPosition;
CommitPosition = commitPosition;
}
示例10: a_record_can_be_written
public void a_record_can_be_written()
{
var filename = Path.Combine(PathName, "prefix.tf0");
var secondfilename = Path.Combine(PathName, "prefix.tf1");
var thirdfilename = Path.Combine(PathName, "prefix.tf2");
File.WriteAllBytes(filename, new byte[50]);
_checkpoint = new InMemoryCheckpoint(40);
var tf = new MultifileTransactionFileWriter(
new TransactionFileDatabaseConfig(PathName, "prefix.tf", 50, _checkpoint, new ICheckpoint[0]));
tf.Open();
var record = new PrepareLogRecord(logPosition: 0,
correlationId: _correlationId,
eventId: _eventId,
transactionPosition: 0,
transactionOffset: 0,
eventStreamId: "WorldEnding",
expectedVersion: 1234,
timeStamp: new DateTime(2012, 12, 21),
flags: PrepareFlags.None,
eventType: "type",
data: new byte[] { 1, 2, 3, 4, 5 },
metadata: new byte[] {7, 17});
long tmp;
tf.Write(record, out tmp);
tf.Close();
Assert.AreEqual(record.GetSizeWithLengthPrefixAndSuffix() + 40, _checkpoint.Read()); //+orginal checkpoint position
Assert.IsTrue(File.Exists(secondfilename));
var stream = new MemoryStream();
var buffer = new byte[256];
using (var filestream = File.Open(filename, FileMode.Open, FileAccess.Read))
{
filestream.Seek(40, SeekOrigin.Begin);
filestream.Read(buffer, 0, 10);
stream.Write(buffer, 0, 10);
}
using (var filestream = File.Open(secondfilename, FileMode.Open, FileAccess.Read))
{
filestream.Seek(0, SeekOrigin.Begin);
filestream.Read(buffer, 0, 50);
stream.Write(buffer, 0, 50);
}
using (var filestream = File.Open(thirdfilename, FileMode.Open, FileAccess.Read))
{
filestream.Seek(0, SeekOrigin.Begin);
filestream.Read(buffer, 0, 50);
stream.Write(buffer, 0, 50);
}
stream.Seek(0 + sizeof(int), SeekOrigin.Begin);
var reader = new BinaryReader(stream);
var read = LogRecord.ReadFrom(reader);
Assert.AreEqual(record, read);
}
开发者ID:soto,项目名称:EventStore,代码行数:52,代码来源:when_writing_an_existing_multifile_transaction_file_with_checksum_that_overlaps_multiple_files.cs
示例11: TestFixtureSetUp
public override void TestFixtureSetUp()
{
base.TestFixtureSetUp();
_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, false);
_result = _chunk.TryAppend(_record);
_chunk.Flush();
_chunk.Complete();
_uncachedChunk = TFChunk.FromCompletedFile(Filename, verifyHash: true);
_uncachedChunk.CacheInMemory();
_uncachedChunk.UnCacheFromMemory();
}
示例12: a_record_can_be_written
public void a_record_can_be_written()
{
var filename = Path.Combine(PathName, "prefix.tf0");
var chunkHeader = new ChunkHeader(1, 10000, 0, 0, 0);
var chunkBytes = chunkHeader.AsByteArray();
var buf = new byte[ChunkHeader.Size + ChunkFooter.Size + chunkHeader.ChunkSize];
Buffer.BlockCopy(chunkBytes, 0, buf, 0, chunkBytes.Length);
File.WriteAllBytes(filename, buf);
_checkpoint = new InMemoryCheckpoint(137);
var db = new TFChunkDb(new TFChunkDbConfig(PathName,
new PrefixFileNamingStrategy(PathName, "prefix.tf"),
chunkHeader.ChunkSize,
0,
_checkpoint,
new ICheckpoint[0]));
db.OpenVerifyAndClean();
var writer = new TFChunkWriter(db);
var record = new PrepareLogRecord(logPosition: 0,
correlationId: _correlationId,
eventId: _eventId,
transactionPosition: 0,
eventStreamId: "WorldEnding",
expectedVersion: 1234,
timeStamp: new DateTime(2012, 12, 21),
flags: PrepareFlags.None,
eventType: "type",
data: new byte[8000],
metadata: new byte[] { 7, 17 });
Console.WriteLine(record.GetSizeWithLengthPrefix());
Console.WriteLine(record.GetSizeWithLengthPrefix() + 137);
long pos;
Assert.IsTrue(writer.Write(record, out pos));
writer.Close();
db.Dispose();
Assert.AreEqual(record.GetSizeWithLengthPrefix() + 137, _checkpoint.Read());
using (var filestream = File.Open(filename, FileMode.Open, FileAccess.Read))
{
filestream.Seek(ChunkHeader.Size + 137 + sizeof(int), SeekOrigin.Begin);
var reader = new BinaryReader(filestream);
var read = LogRecord.ReadFrom(reader);
Console.WriteLine(string.Join("\n", Directory.EnumerateFiles(PathName)));
Assert.AreEqual(record, read);
}
}
开发者ID:vishal-h,项目名称:EventStore-1,代码行数:51,代码来源:when_writing_an_existing_chunked_transaction_file_with_checksum_and_data_bigger_than_buffer.cs
示例13: a_record_can_be_written
public void a_record_can_be_written()
{
var filename = GetFilePathFor("chunk-000000.000000");
var chunkHeader = new ChunkHeader(TFChunk.CurrentChunkVersion, 10000, 0, 0, false, Guid.NewGuid());
var chunkBytes = chunkHeader.AsByteArray();
var buf = new byte[ChunkHeader.Size + ChunkFooter.Size + chunkHeader.ChunkSize];
Buffer.BlockCopy(chunkBytes, 0, buf, 0, chunkBytes.Length);
File.WriteAllBytes(filename, buf);
_checkpoint = new InMemoryCheckpoint(137);
var db = new TFChunkDb(new TFChunkDbConfig(PathName,
new VersionedPatternFileNamingStrategy(PathName, "chunk-"),
chunkHeader.ChunkSize,
0,
_checkpoint,
new InMemoryCheckpoint(),
new InMemoryCheckpoint(-1),
new InMemoryCheckpoint(-1)));
db.Open();
var bytes = new byte[3994]; // this gives exactly 4097 size of record, with 3993 (rec size 4096) everything works fine!
new Random().NextBytes(bytes);
var writer = new TFChunkWriter(db);
var record = new PrepareLogRecord(logPosition: 137,
correlationId: _correlationId,
eventId: _eventId,
transactionPosition: 789,
transactionOffset: 543,
eventStreamId: "WorldEnding",
expectedVersion: 1234,
timeStamp: new DateTime(2012, 12, 21),
flags: PrepareFlags.SingleWrite,
eventType: "type",
data: bytes,
metadata: new byte[] { 0x07, 0x17 });
long pos;
Assert.IsTrue(writer.Write(record, out pos));
writer.Close();
db.Dispose();
Assert.AreEqual(record.GetSizeWithLengthPrefixAndSuffix() + 137, _checkpoint.Read());
using (var filestream = File.Open(filename, FileMode.Open, FileAccess.Read))
{
filestream.Seek(ChunkHeader.Size + 137 + sizeof(int), SeekOrigin.Begin);
var reader = new BinaryReader(filestream);
var read = LogRecord.ReadFrom(reader);
Assert.AreEqual(record, read);
}
}
开发者ID:thinkbeforecoding,项目名称:EventStore,代码行数:50,代码来源:when_writing_an_existing_chunked_transaction_file_with_checksum_and_data_bigger_than_buffer.cs
示例14: try_read_returns_record_when_writerchecksum_ahead
public void try_read_returns_record_when_writerchecksum_ahead()
{
var recordToWrite = new PrepareLogRecord(logPosition: 0,
correlationId: _correlationId,
eventId: _eventId,
transactionPosition: 0,
transactionOffset: 0,
eventStreamId: "WorldEnding",
expectedVersion: 1234,
timeStamp: new DateTime(2012, 12, 21),
flags: PrepareFlags.None,
eventType: "type",
data: new byte[] { 1, 2, 3, 4, 5 },
metadata: new byte[] { 7, 17 });
using (var fs = new FileStream(GetFilePathFor("chunk-000000.000000"), FileMode.CreateNew, FileAccess.Write))
{
fs.SetLength(ChunkHeader.Size + ChunkFooter.Size + 10000);
var chunkHeader = new ChunkHeader(TFChunk.CurrentChunkVersion, 10000, 0, 0, false, Guid.NewGuid()).AsByteArray();
var writer = new BinaryWriter(fs);
writer.Write(chunkHeader);
recordToWrite.WriteWithLengthPrefixAndSuffixTo(writer);
fs.Close();
}
var writerchk = new InMemoryCheckpoint(128);
var chaserchk = new InMemoryCheckpoint(Checkpoint.Chaser, 0);
var db = new TFChunkDb(new TFChunkDbConfig(PathName,
new VersionedPatternFileNamingStrategy(PathName, "chunk-"),
10000,
0,
writerchk,
chaserchk,
new InMemoryCheckpoint(-1),
new InMemoryCheckpoint(-1)));
db.Open();
var chaser = new TFChunkChaser(db, writerchk, chaserchk);
chaser.Open();
LogRecord record;
var recordRead = chaser.TryReadNext(out record);
chaser.Close();
Assert.AreEqual(record.GetSizeWithLengthPrefixAndSuffix(), chaserchk.Read());
Assert.IsTrue(recordRead);
Assert.AreEqual(recordToWrite, record);
db.Close();
}
示例15: WriteTestScenario
protected override void WriteTestScenario()
{
_id1 = Guid.NewGuid();
_id2 = Guid.NewGuid();
long pos1, pos2, pos3, pos4;
_prepare1 = new PrepareLogRecord(0, _id1, _id1, 0, 0, "test1", ExpectedVersion.NoStream, DateTime.UtcNow,
PrepareFlags.SingleWrite, "type", new byte[0], new byte[0]);
Writer.Write(_prepare1, out pos1);
_prepare2 = new PrepareLogRecord(pos1, _id2, _id2, pos1, 0, "test1", 0, DateTime.UtcNow,
PrepareFlags.SingleWrite, "type", new byte[0], new byte[0]);
Writer.Write(_prepare2, out pos2);
Writer.Write(new CommitLogRecord(pos2, _id1, 0, DateTime.UtcNow, 0), out pos3);
Writer.Write(new CommitLogRecord(pos3, _id2, pos1, DateTime.UtcNow, 1), out pos4);
}
开发者ID:base31,项目名称:geteventstore_EventStore,代码行数:15,代码来源:when_building_an_index_off_tfile_with_two_events_in_stream.cs