Ejemplo 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));
            }
        }
Ejemplo 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);
                }
            }
        }
Ejemplo n.º 3
0
        public long ShouldDiscoverPartitionNewVersionsOnNewTransactions(bool clearPartition1, int days)
        {
            using (IJournal <PocoType> journal = WriteJournal(EPartitionType.Month, TimeSpan.FromDays(1), days))
            {
                if (clearPartition1)
                {
                    var newVersion = new PartitionDate(START_DATE, 1, EPartitionType.Month).Name;
                    Directory.CreateDirectory(Path.Combine(_directoryPath, newVersion));
                }

                using (var rtx = journal.OpenReadTx())
                {
                    return(rtx.All().Length ?? 0L);
                }
            }
        }
Ejemplo n.º 4
0
        public void ShouldKeepBothPartitionVersionWhenInUse()
        {
            int days = 40;

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

                    using (var rtx2 = journal.OpenReadTx())
                    {
                        Assert.That(rtx2.All().Length.Value, Is.EqualTo(days - 31));
                    }
                    Assert.That(rtx.All().Length.Value, Is.EqualTo(days));
                }
            }
        }
Ejemplo n.º 5
0
        public long ShouldHandleDeletedPartitoinAfterRestart(bool clearPartition1, int days)
        {
            using (WriteJournal(EPartitionType.Month, TimeSpan.FromDays(1), days))
            {
            }

            if (clearPartition1)
            {
                var newVersion = new PartitionDate(START_DATE, 0, EPartitionType.Month).Name;
                Directory.Delete(Path.Combine(_directoryPath, newVersion), true);
            }

            using (IJournal <PocoType> journal = new JournalBuilder()
                                                 .WithLocation(_directoryPath)
                                                 .ToJournal <PocoType>())
            {
                using (var rtx = journal.OpenReadTx())
                {
                    return(rtx.All().Length ?? 0L);
                }
            }
        }