Exemplo n.º 1
0
        public void ShouldDeleteOutDatedPartitionVersionWhenNotInUse()
        {
            int days   = 40;
            var server = new AsyncJournalServer(TimeSpan.FromSeconds(1));

            using (IJournal <PocoType> journal = WriteJournal(EPartitionType.Month, TimeSpan.FromDays(1), days, server))
            {
                using (var rtx = journal.OpenReadTx())
                {
                    var newVersion       = new PartitionDate(START_DATE, 1, EPartitionType.Month).Name;
                    var newPartitionPath = Path.Combine(_directoryPath, newVersion);
                    Directory.CreateDirectory(newPartitionPath);

                    using (var rtx2 = journal.OpenReadTx())
                    {
                        var len = rtx.All().Length.Value;
                    }
                }

                // Act.
                server.DoEvents();

                // Verify.
                var oldVersion       = new PartitionDate(START_DATE, 0, EPartitionType.Month).Name;
                var oldPartitionPath = Path.Combine(_directoryPath, oldVersion);
                Assert.That(Directory.Exists(oldPartitionPath), Is.EqualTo(false));
            }
        }
Exemplo n.º 2
0
        public long ShouldUseNewPartitionOnRecreate(bool clearPartition1, int days)
        {
            var server = new AsyncJournalServer(TimeSpan.FromSeconds(1));

            using (IJournal <PocoType> journal = WriteJournal(EPartitionType.Month, TimeSpan.FromDays(1), days, server))
            {
                using (var rtx = journal.OpenReadTx())
                {
                    var newVersion       = new PartitionDate(START_DATE, 1, EPartitionType.Month).Name;
                    var newPartitionPath = Path.Combine(_directoryPath, newVersion);
                    Directory.CreateDirectory(newPartitionPath);

                    using (var rtx2 = journal.OpenReadTx())
                    {
                        var len = rtx2.All().Length.Value;
                    }
                }

                // Act.
                server.DoEvents();


                // Verify.
                using (var rtx = journal.OpenReadTx())
                {
                    return(rtx.All().Length.Value);
                }
            }
        }