Пример #1
0
        private void CopyIndexFiles(IndexSnapshot snapshot, LuceneSearchManager indexManager,
                                    string backupDirectoryPath, CancellationToken cancellationToken)
        {
            using (var op = SnTrace.Index.StartOperation("BackupManager: Copy index files."))
            {
                var sourceDirectoryPath = indexManager.IndexDirectory.CurrentDirectory;

                // Calculate initial progress
                BackupInfo.CountOfFiles = snapshot.FileNames.Length;
                BackupInfo.TotalBytes   = snapshot.FileNames
                                          .Sum(x => new FileInfo(Path.Combine(sourceDirectoryPath, x)).Length);

                SnTrace.Index.Write("BackupManager: count of files: {0}, total bytes: {1}",
                                    BackupInfo.CountOfFiles, BackupInfo.TotalBytes);

                CopyFile(sourceDirectoryPath, backupDirectoryPath, snapshot.SegmentFileName, cancellationToken);

                foreach (var fileName in snapshot.FileNames)
                {
                    CopyFile(sourceDirectoryPath, backupDirectoryPath, fileName, cancellationToken);
                }

                op.Successful = true;
            }
        }
        /// <summary>
        /// Initializes an instance of the Lucene29LocalIndexingEngine class.
        /// </summary>
        /// <param name="indexDirectory">File system directory for storing the index.
        /// If not provided, <see cref="SearchManager.IndexDirectoryPath"/> will be used.</param>
        public Lucene29LocalIndexingEngine(IndexDirectory indexDirectory)
        {
            var indexDir = indexDirectory ?? new IndexDirectory(null, SearchManager.IndexDirectoryPath);

            LuceneSearchManager = new LuceneSearchManager(indexDir, Notification.NotificationSender);

            SetEventhandlers();
        }
Пример #3
0
 public static LucQuery Create(Query luceneQuery, LuceneSearchManager searchManager)
 {
     return(new LucQuery
     {
         Query = luceneQuery,
         LuceneSearchManager = searchManager
     });
 }
Пример #4
0
        public void Backup(IndexingActivityStatus state, string backupDirectoryPath,
                           LuceneSearchManager indexManager, CancellationToken cancellationToken)
        {
            using (var op = SnTrace.Index.StartOperation("BackupManager: INDEX BACKUP. Target: " + backupDirectoryPath))
            {
                SnTrace.Index.Write("BackupManager: IndexingActivityStatus: " + state);

                BackupInfo.StartedAt = DateTime.UtcNow;

                EnsureEmptyBackupDirectory(backupDirectoryPath, cancellationToken);

                using (var snapshot = indexManager.CreateSnapshot(state))
                    CopyIndexFiles(snapshot, indexManager, backupDirectoryPath, cancellationToken);

                BackupInfo.FinishedAt = DateTime.UtcNow;

                op.Successful = true;
            }
        }
Пример #5
0
 public LucQueryToStringVisitor(LuceneSearchManager searchManager)
 {
     LuceneSearchManager = searchManager;
 }