当前位置: 首页>>代码示例>>C#>>正文


C# TFChunkDb.Dispose方法代码示例

本文整理汇总了C#中EventStore.Core.TransactionLog.Chunks.TFChunkDb.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# TFChunkDb.Dispose方法的具体用法?C# TFChunkDb.Dispose怎么用?C# TFChunkDb.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventStore.Core.TransactionLog.Chunks.TFChunkDb的用法示例。


在下文中一共展示了TFChunkDb.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: try_read_returns_false_when_writer_checksum_is_equal_to_reader_checksum

        public void try_read_returns_false_when_writer_checksum_is_equal_to_reader_checksum()
        {
            var writerchk = new InMemoryCheckpoint();
            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();
            writerchk.Write(12);
            writerchk.Flush();
            chaserchk.Write(12);
            chaserchk.Flush();

            var chaser = new TFChunkChaser(db, writerchk, chaserchk);
            chaser.Open();

            LogRecord record;
            Assert.IsFalse(chaser.TryReadNext(out record));
            Assert.AreEqual(12, chaserchk.Read());

            chaser.Close();
            db.Dispose();
        }
开发者ID:danieldeb,项目名称:EventStore,代码行数:28,代码来源:when_chasing_a_chunked_transaction_log.cs

示例2: with_a_writer_checksum_of_zero_and_no_files_is_valid

 public void with_a_writer_checksum_of_zero_and_no_files_is_valid()
 {
     var db = new TFChunkDb(new TFChunkDbConfig(PathName,
                                                new PrefixFileNamingStrategy(PathName, "prefix.tf"),
                                                10000,
                                                0,
                                                new InMemoryCheckpoint(0),
                                                new ICheckpoint[0]));
     Assert.DoesNotThrow(db.OpenVerifyAndClean);
     db.Dispose();
 }
开发者ID:jpierson,项目名称:EventStore,代码行数:11,代码来源:when_verifying_chunked_transaction_db_without_previous_files.cs

示例3: with_a_writer_checksum_of_nonzero_and_no_files_a_corrupted_database_exception_is_thrown

 public void with_a_writer_checksum_of_nonzero_and_no_files_a_corrupted_database_exception_is_thrown()
 {
     var db = new TFChunkDb(new TFChunkDbConfig(PathName,
                                                new PrefixFileNamingStrategy(PathName, "prefix.tf"),
                                                10000,
                                                0,
                                                new InMemoryCheckpoint(500),
                                                new ICheckpoint[0]));
     var exc = Assert.Throws<CorruptDatabaseException>(db.OpenVerifyAndClean);
     Assert.IsInstanceOf<ChunkNotFoundException>(exc.InnerException);
     db.Dispose();
 }
开发者ID:jpierson,项目名称:EventStore,代码行数:12,代码来源:when_verifying_chunked_transaction_db_without_previous_files.cs

示例4: allows_first_correct_file_when_checkpoint_is_zero

 public void allows_first_correct_file_when_checkpoint_is_zero()
 {
     var config = new TFChunkDbConfig(PathName,
                                      new PrefixFileNamingStrategy(PathName, "prefix.tf"),
                                      10000,
                                      0,
                                      new InMemoryCheckpoint(),
                                      new ICheckpoint[0]);
     var db = new TFChunkDb(config);
     CreateChunk(Path.Combine(PathName, config.FileNamingStrategy.GetFilenameFor(0)), config.ChunkSize, config.ChunkSize);
     Assert.DoesNotThrow(() => db.OpenVerifyAndClean(verifyHash: false));
     db.Dispose();
 }
开发者ID:soto,项目名称:EventStore,代码行数:13,代码来源:when_validating_chunked_transaction_db.cs

示例5: with_a_writer_checksum_of_zero_and_no_files_is_valid

 public void with_a_writer_checksum_of_zero_and_no_files_is_valid()
 {
     var db = new TFChunkDb(new TFChunkDbConfig(PathName,
                                                new VersionedPatternFileNamingStrategy(PathName, "chunk-"),
                                                10000,
                                                0,
                                                new InMemoryCheckpoint(0),
                                                new InMemoryCheckpoint(),
                                                new InMemoryCheckpoint(-1),
                                                new InMemoryCheckpoint(-1)));
     Assert.DoesNotThrow(() => db.Open());
     db.Dispose();
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:13,代码来源:when_validating_tfchunkdb_without_previous_files.cs

示例6: 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

示例7: with_file_of_wrong_size_database_corruption_is_detected

 public void with_file_of_wrong_size_database_corruption_is_detected()
 {
     var config = new TFChunkDbConfig(PathName,
                                      new PrefixFileNamingStrategy(PathName, "prefix.tf"),
                                      10000,
                                      0,
                                      new InMemoryCheckpoint(500),
                                      new ICheckpoint[0]);
     var db = new TFChunkDb(config);
     File.WriteAllText(Path.Combine(PathName, config.FileNamingStrategy.GetFilenameFor(0)), "this is just some test blahbydy blah");
     var ex = Assert.Throws<CorruptDatabaseException>(db.OpenVerifyAndClean);
     Assert.IsInstanceOf<BadChunkInDatabaseException>(ex.InnerException);
     db.Dispose();
 }
开发者ID:jpierson,项目名称:EventStore,代码行数:14,代码来源:when_validating_chunked_transaction_db.cs

示例8: allows_next_new_chunk_when_checksum_is_exactly_in_between_two_chunks

 public void allows_next_new_chunk_when_checksum_is_exactly_in_between_two_chunks()
 {
     var config = new TFChunkDbConfig(PathName,
                                      new PrefixFileNamingStrategy(PathName, "prefix.tf"),
                                      10000,
                                      0,
                                      new InMemoryCheckpoint(10000),
                                      new ICheckpoint[0]);
     var db = new TFChunkDb(config);
     CreateChunk(Path.Combine(PathName, config.FileNamingStrategy.GetFilenameFor(0)), config.ChunkSize, config.ChunkSize);
     CreateChunk(Path.Combine(PathName, config.FileNamingStrategy.GetFilenameFor(1)), config.ChunkSize, config.ChunkSize);
     Assert.DoesNotThrow(() => db.OpenVerifyAndClean(verifyHash: false));
     db.Dispose();
 }
开发者ID:soto,项目名称:EventStore,代码行数:14,代码来源:when_validating_chunked_transaction_db.cs

示例9: with_wrong_actual_chunk_size_in_chunk_footer

 public void with_wrong_actual_chunk_size_in_chunk_footer()
 {
     var config = new TFChunkDbConfig(PathName,
                                      new PrefixFileNamingStrategy(PathName, "prefix.tf"),
                                      10000,
                                      0,
                                      new InMemoryCheckpoint(10000),
                                      new ICheckpoint[0]);
     var db = new TFChunkDb(config);
     CreateChunk(Path.Combine(PathName, config.FileNamingStrategy.GetFilenameFor(0)), 10000, 12000);
     var ex = Assert.Throws<CorruptDatabaseException>(db.OpenVerifyAndClean);
     Assert.IsInstanceOf<BadChunkInDatabaseException>(ex.InnerException);
     db.Dispose();
 }
开发者ID:jpierson,项目名称:EventStore,代码行数:14,代码来源:when_validating_chunked_transaction_db.cs

示例10: 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

示例11: with_a_writer_checksum_of_nonzero_and_no_files_a_corrupted_database_exception_is_thrown

 public void with_a_writer_checksum_of_nonzero_and_no_files_a_corrupted_database_exception_is_thrown()
 {
     var db = new TFChunkDb(new TFChunkDbConfig(PathName,
                                                new VersionedPatternFileNamingStrategy(PathName, "chunk-"),
                                                10000,
                                                0,
                                                new InMemoryCheckpoint(500),
                                                new InMemoryCheckpoint(),
                                                new InMemoryCheckpoint(-1),
                                                new InMemoryCheckpoint(-1)));
     var exc = Assert.Throws<CorruptDatabaseException>(() => db.Open());
     Assert.IsInstanceOf<ChunkNotFoundException>(exc.InnerException);
     db.Dispose();
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:14,代码来源:when_validating_tfchunkdb_without_previous_files.cs

示例12: a_record_can_be_written

        public void a_record_can_be_written()
        {
            var filename = GetFilePathFor("prefix.tf0");
            var chunkHeader = new ChunkHeader(TFChunk.CurrentChunkVersion, 10000, 0, 0, false);
            var chunkBytes = chunkHeader.AsByteArray();
            var bytes = new byte[ChunkHeader.Size + 10000 + ChunkFooter.Size];
            Buffer.BlockCopy(chunkBytes, 0, bytes, 0, chunkBytes.Length);
            File.WriteAllBytes(filename, bytes);

            _checkpoint = new InMemoryCheckpoint(137);
            var db = new TFChunkDb(new TFChunkDbConfig(PathName,
                                                       new PrefixFileNamingStrategy(PathName, "prefix.tf"),
                                                       10000,
                                                       0,
                                                       _checkpoint,
                                                       new InMemoryCheckpoint(),
                                                       new ICheckpoint[0]));
            db.OpenVerifyAndClean();
            var tf = new TFChunkWriter(db);
            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();
            db.Dispose();

            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(ChunkHeader.Size + 137 + sizeof(int), SeekOrigin.Begin);
                var reader = new BinaryReader(filestream);
                var read = LogRecord.ReadFrom(reader);
                Assert.AreEqual(record, read);
            }
        }
开发者ID:base31,项目名称:geteventstore_EventStore,代码行数:47,代码来源:when_writing_an_existing_chunked_transaction_file_with_checksum.cs

示例13: with_a_writer_checksum_of_zero_the_first_chunk_is_created_with_correct_name

        public void with_a_writer_checksum_of_zero_the_first_chunk_is_created_with_correct_name()
        {
            var config = new TFChunkDbConfig(PathName,
                                             new PrefixFileNamingStrategy(PathName, "prefix.tf"),
                                             10000,
                                             0,
                                             new InMemoryCheckpoint(0),
                                             new ICheckpoint[0]);
            var db = new TFChunkDb(config);
            db.OpenVerifyAndClean();
            db.Dispose();

            Assert.AreEqual(1, Directory.GetFiles(PathName).Length);
            Assert.IsTrue(File.Exists(Path.Combine(PathName, "prefix.tf0")));
            var fileInfo = new FileInfo(Path.Combine(PathName, "prefix.tf0"));
            Assert.AreEqual(10000 + ChunkHeader.Size + ChunkFooter.Size, fileInfo.Length);
        }
开发者ID:jpierson,项目名称:EventStore,代码行数:17,代码来源:when_opening_chunked_transaction_file_db_without_previous_files.cs

示例14: with_a_writer_checksum_of_zero_the_first_chunk_is_created_with_correct_name

        public void with_a_writer_checksum_of_zero_the_first_chunk_is_created_with_correct_name()
        {
            var config = new TFChunkDbConfig(PathName,
                                             new VersionedPatternFileNamingStrategy(PathName, "chunk-"),
                                             10000,
                                             0,
                                             new InMemoryCheckpoint(0),
                                             new InMemoryCheckpoint(0),
                                             new InMemoryCheckpoint(-1),
                                             new InMemoryCheckpoint(-1));
            var db = new TFChunkDb(config);
            db.Open();
            db.Dispose();

            Assert.AreEqual(1, Directory.GetFiles(PathName).Length);
            Assert.IsTrue(File.Exists(GetFilePathFor("chunk-000000.000000")));
            var fileInfo = new FileInfo(GetFilePathFor("chunk-000000.000000"));
            Assert.AreEqual(10000 + ChunkHeader.Size + ChunkFooter.Size, fileInfo.Length);
        }
开发者ID:danieldeb,项目名称:EventStore,代码行数:19,代码来源:when_opening_chunked_transaction_file_db_without_previous_files.cs

示例15: a_record_can_be_written

        public void a_record_can_be_written()
        {
            _checkpoint = new InMemoryCheckpoint(0);
            var db = new TFChunkDb(new TFChunkDbConfig(PathName,
                                                       new VersionedPatternFileNamingStrategy(PathName, "chunk-"),
                                                       1000,
                                                       0,
                                                       _checkpoint,
                                                       new InMemoryCheckpoint(),
                                                       new InMemoryCheckpoint(-1),
                                                       new InMemoryCheckpoint(-1)));
            db.Open();
            var tf = new TFChunkWriter(db);
            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();
            db.Dispose();

            Assert.AreEqual(record.GetSizeWithLengthPrefixAndSuffix(), _checkpoint.Read());
            using (var filestream = File.Open(GetFilePathFor("chunk-000000.000000"), FileMode.Open, FileAccess.Read))
            {
                filestream.Position = ChunkHeader.Size;

                var reader = new BinaryReader(filestream);
                reader.ReadInt32();
                var read = LogRecord.ReadFrom(reader);
                Assert.AreEqual(record, read);
            }
        }
开发者ID:thinkbeforecoding,项目名称:EventStore,代码行数:42,代码来源:when_writing_a_new_chunked_transaction_file.cs


注:本文中的EventStore.Core.TransactionLog.Chunks.TFChunkDb.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。