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)); } }
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); } } }
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); } } }
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)); } } }
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); } } }