Пример #1
0
        /// <exception cref="System.IO.IOException"/>
        internal virtual void CheckImageAndEditsFilesExistence(FilePath dir, bool shouldHaveImages
                                                               , bool shouldHaveEdits)
        {
            FSImageTransactionalStorageInspector ins = Inspect(dir);

            if (shouldHaveImages)
            {
                NUnit.Framework.Assert.IsTrue("Expect images in " + dir, ins.foundImages.Count >
                                              0);
            }
            else
            {
                NUnit.Framework.Assert.IsTrue("Expect no images in " + dir, ins.foundImages.IsEmpty
                                                  ());
            }
            IList <FileJournalManager.EditLogFile> editlogs = FileJournalManager.MatchEditLogs
                                                                  (new FilePath(dir, "current").ListFiles());

            if (shouldHaveEdits)
            {
                NUnit.Framework.Assert.IsTrue("Expect edits in " + dir, editlogs.Count > 0);
            }
            else
            {
                NUnit.Framework.Assert.IsTrue("Expect no edits in " + dir, editlogs.IsEmpty());
            }
        }
Пример #2
0
                /// <exception cref="System.IO.IOException"/>
                public virtual void PurgeLogsOlderThan(long minTxIdToKeep)
                {
                    IEnumerator <Storage.StorageDirectory> iter = storage.DirIterator();

                    while (iter.HasNext())
                    {
                        Storage.StorageDirectory dir = iter.Next();
                        IList <FileJournalManager.EditLogFile> editFiles = FileJournalManager.MatchEditLogs
                                                                               (dir.GetCurrentDir());
                        foreach (FileJournalManager.EditLogFile f in editFiles)
                        {
                            if (f.GetLastTxId() < minTxIdToKeep)
                            {
                                purger.PurgeLog(f);
                            }
                        }
                    }
                }
Пример #3
0
                public virtual void SelectInputStreams(ICollection <EditLogInputStream> streams, long
                                                       fromTxId, bool inProgressOk)
                {
                    IEnumerator <Storage.StorageDirectory> iter = storage.DirIterator();

                    while (iter.HasNext())
                    {
                        Storage.StorageDirectory dir = iter.Next();
                        IList <FileJournalManager.EditLogFile> editFiles;
                        try
                        {
                            editFiles = FileJournalManager.MatchEditLogs(dir.GetCurrentDir());
                        }
                        catch (IOException ioe)
                        {
                            throw new RuntimeException(ioe);
                        }
                        FileJournalManager.AddStreamsToCollectionFromFiles(editFiles, streams, fromTxId,
                                                                           inProgressOk);
                    }
                }
Пример #4
0
        /// <returns>
        /// the latest edits log, finalized or otherwise, from the given
        /// storage directory.
        /// </returns>
        /// <exception cref="System.IO.IOException"/>
        public static FileJournalManager.EditLogFile FindLatestEditsLog(Storage.StorageDirectory
                                                                        sd)
        {
            FilePath currentDir = sd.GetCurrentDir();
            IList <FileJournalManager.EditLogFile> foundEditLogs = Lists.NewArrayList(FileJournalManager
                                                                                      .MatchEditLogs(currentDir));

            return(Sharpen.Collections.Max(foundEditLogs, FileJournalManager.EditLogFile.CompareByStartTxid
                                           ));
        }
Пример #5
0
        /// <summary>tests that passing an invalid dir to matchEditLogs throws IOException</summary>
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestMatchEditLogInvalidDirThrowsIOException()
        {
            FilePath badDir = new FilePath("does not exist");

            FileJournalManager.MatchEditLogs(badDir);
        }