Beispiel #1
0
        public static Tuple <FileCheckpointWriter, FilePageWriter> CreateWriterRaw(DirectoryInfo folder, string stream)
        {
            var streamDir = Path.Combine(folder.FullName, stream);
            var di        = new DirectoryInfo(streamDir);

            if (!di.Exists)
            {
                di.Create();
            }
            var pagesFile      = new FileInfo(Path.Combine(di.FullName, Constants.StreamFileName));
            var checkpointFile = new FileInfo(Path.Combine(di.FullName, Constants.PositionFileName));

            var pages      = new FilePageWriter(pagesFile);
            var checkpoint = new FileCheckpointWriter(checkpointFile);

            return(Tuple.Create(checkpoint, pages));
        }
Beispiel #2
0
        public static MessageWriter CreateAndInitWriter(DirectoryInfo folder, string stream)
        {
            var streamDir = Path.Combine(folder.FullName, stream);
            var di = new DirectoryInfo(streamDir);
            if (!di.Exists) {
                di.Create();
            }
            var pagesFile = new FileInfo(Path.Combine(di.FullName, Constants.StreamFileName));
            var checkpointFile = new FileInfo(Path.Combine(di.FullName, Constants.PositionFileName));

            var pages = new FilePageWriter(pagesFile);
            var checkpoint = new FileCheckpointWriter(checkpointFile);

            var writer = new MessageWriter(pages, checkpoint);
            writer.Init();
            return writer;
        }
        public void Setup()
        {
            _folder = Path.Combine(Path.GetTempPath(), "syntethic_test");
            if (!Directory.Exists(_folder)) {
                Directory.CreateDirectory(_folder);
            }

            var streamFile = new FileInfo(Path.Combine(_folder, Constants.StreamFileName));
            var checkFile = new FileInfo(Path.Combine(_folder, Constants.PositionFileName));

            var pageWriter = new FilePageWriter(streamFile);
            var pageReader = new FilePageReader(streamFile);
            var checkReader = new FileCheckpointReader(checkFile);
            var checkWriter = new FileCheckpointWriter(checkFile);

            Writer = new MessageWriter(pageWriter, checkWriter);
            Reader = new MessageReader(checkReader, pageReader);
            CheckpointReader = checkReader;
            PageWriter = pageWriter;
            Writer.Init();
        }