コード例 #1
0
 public override void DoAction(bool onRemote, bool isFromMe)
 {
     if (onRemote && isFromMe)
     {
         return;
     }
     Debug.WriteLine(String.Format("@> {0} RequestBackupIndexMessage received. onRemote: {1}, isFromMe: {2}, id: {3}", AppDomain.CurrentDomain.FriendlyName, onRemote, isFromMe, SenseNet.ContentRepository.Storage.Data.RepositoryConfiguration.IndexBackupCreatorId));
     if (Environment.MachineName == _machine && SenseNet.ContentRepository.Storage.Data.RepositoryConfiguration.IndexBackupCreatorId == _indexBackupCreatorId)
     {
         Debug.WriteLine(String.Format("@> {0} =========== BackupIndex START id: {1}", AppDomain.CurrentDomain.FriendlyName, SenseNet.ContentRepository.Storage.Data.RepositoryConfiguration.IndexBackupCreatorId));
         string msg = null;
         BackupTools.DistributedNotifyProgress = true;
         try
         {
             new IndexBackupStartedMessage("Index backup has started.").Send();
             BackupTools.SynchronousBackupIndex();
             msg = String.Concat(BackupTools.Progress.Summary);
         }
         catch (Exception e)
         {
             //TODO: full exception
             msg = e.Message;
         }
         finally
         {
             BackupTools.DistributedNotifyProgress = false;
         }
         new IndexBackupFinishedMessage(msg).Send();
         Debug.WriteLine(String.Format("@> {0} =========== BackupIndex END. id: {1}", AppDomain.CurrentDomain.FriendlyName, SenseNet.ContentRepository.Storage.Data.RepositoryConfiguration.IndexBackupCreatorId));
     }
 }
コード例 #2
0
        internal static void ForceRestore()
        {
            try
            {
                PauseIndexing();
                ApplyChanges();
                BackupTools.RestoreIndex(true, null);

                var directory = FSDirectory.Open(new System.IO.DirectoryInfo(IndexDirectory.CurrentDirectory));
                //_writerRestartLock.EnterWriteLock();
                //try
                //{
                //    _writer = new IndexWriter(directory, IndexManager.GetAnalyzer(), false);
                //    _reader = _writer.GetReader();
                //}
                //finally
                //{
                //    _writerRestartLock.ExitWriteLock();
                //}
                using (var wrFrame = IndexWriterFrame.Get(true)) // // ForceRestore
                {
                    _writer = new IndexWriter(directory, IndexManager.GetAnalyzer(), false);
                    _reader = _writer.GetReader();
                }

                ExecuteUnprocessedIndexingActivities(null);
            }
            finally
            {
                ContinueIndexing();
            }
        }
コード例 #3
0
        private static void Startup(System.IO.TextWriter consoleOut)
        {
            try
            {
                //We can't handle cache invalidation as it would call into LuceneManager
                //we only process lucene messages
                var safeMessageTypes = new List <Type>();
                safeMessageTypes.Add(typeof(DistributedLuceneActivity.LuceneActivityDistributor));
                ClusterChannel.ProcessedMessageTypes = safeMessageTypes;

                //we positively start the message cluster
                int dummy  = SenseNet.ContentRepository.DistributedApplication.Cache.Count;
                var dummy2 = SenseNet.ContentRepository.DistributedApplication.ClusterChannel;

                if (SenseNet.ContentRepository.RepositoryInstance.RestoreIndexOnStartup())
                {
                    BackupTools.RestoreIndex(false, consoleOut);
                }

                CreateWriterAndReader();

                using (new SystemAccount())
                    ExecuteUnprocessedIndexingActivities(consoleOut);

                Warmup();

                var commitStart = new ThreadStart(CommitWorker);
                new Thread(commitStart).Start();
            }
            finally
            {
                ClusterChannel.ProcessedMessageTypes = null;
            }
        }
コード例 #4
0
        /*======================================================================================================= IIndexPopulator Members */

        // caller: IndexPopulator.Populator, Import.Importer, Tests.Initializer, RunOnce
        public void ClearAndPopulateAll(bool backup = true)
        {
            var lastActivityId = LuceneManager.GetLastStoredIndexingActivityId();
            var commitData     = CompletionState.GetCommitUserData(lastActivityId);

            using (var op = SnTrace.Index.StartOperation("IndexPopulator ClearAndPopulateAll"))
            {
                // recreate
                var writer = IndexManager.GetIndexWriter(true);
                try
                {
                    var excludedNodeTypes = LuceneManager.GetNotIndexedNodeTypes();
                    foreach (var docData in StorageContext.Search.LoadIndexDocumentsByPath("/Root", excludedNodeTypes))
                    {
                        var doc = IndexDocumentInfo.GetDocument(docData);
                        if (doc == null) // indexing disabled
                        {
                            continue;
                        }
                        writer.AddDocument(doc);
                        OnNodeIndexed(docData.Path);
                    }
                    RepositoryInstance.Instance.ConsoleWrite("  Commiting ... ");
                    writer.Commit(commitData);
                    RepositoryInstance.Instance.ConsoleWriteLine("ok");
                    RepositoryInstance.Instance.ConsoleWrite("  Optimizing ... ");
                    writer.Optimize();
                    RepositoryInstance.Instance.ConsoleWriteLine("ok");
                }
                finally
                {
                    writer.Close();
                }
                RepositoryInstance.Instance.ConsoleWrite("  Deleting indexing activities ... ");
                LuceneManager.DeleteAllIndexingActivities();
                RepositoryInstance.Instance.ConsoleWriteLine("ok");
                if (backup)
                {
                    RepositoryInstance.Instance.ConsoleWrite("  Making backup ... ");
                    BackupTools.BackupIndexImmediatelly();
                    RepositoryInstance.Instance.ConsoleWriteLine("ok");
                }
                op.Successful = true;
            }
        }
コード例 #5
0
        /*======================================================================================================= IIndexPopulator Members */

        // caller: IndexPopulator.Populator, Import.Importer, Tests.Initializer, RunOnce
        public void ClearAndPopulateAll()
        {
            var lastActivityId = IndexingActivityManager.GetLastActivityId();
            var commitData     = IndexManager.CreateCommitUserData(lastActivityId);

            using (var traceOperation = Logger.TraceOperation("IndexPopulator ClearAndPopulateAll"))
            {
                //-- recreate
                var writer = IndexManager.GetIndexWriter(true);
                try
                {
                    foreach (var docData in StorageContext.Search.LoadIndexDocumentsByPath("/Root"))
                    {
                        var doc = IndexDocumentInfo.GetDocument(docData);
                        writer.AddDocument(doc);
                        OnNodeIndexed(docData.Path);
                    }
                    RepositoryInstance.Instance.ConsoleWrite("  Commiting ... ");
                    writer.Commit(commitData);
                    RepositoryInstance.Instance.ConsoleWriteLine("ok");
                    RepositoryInstance.Instance.ConsoleWrite("  Optimizing ... ");
                    writer.Optimize();
                    RepositoryInstance.Instance.ConsoleWriteLine("ok");
                }
                finally
                {
                    writer.Close();
                }
                RepositoryInstance.Instance.ConsoleWrite("  Deleting indexing activities ... ");
                IndexingActivityManager.DeleteAllActivities();
                RepositoryInstance.Instance.ConsoleWriteLine("ok");
                RepositoryInstance.Instance.ConsoleWrite("  Making backup ... ");
                BackupTools.BackupIndexImmediatelly();
                RepositoryInstance.Instance.ConsoleWriteLine("ok");
                traceOperation.IsSuccessful = true;
            }
        }
コード例 #6
0
ファイル: LuceneManager.cs プロジェクト: sztomi/sensenet
        private static void Startup(System.IO.TextWriter consoleOut)
        {
            // we positively start the message cluster
            int dummy  = SenseNet.ContentRepository.DistributedApplication.Cache.Count;
            var dummy2 = SenseNet.ContentRepository.DistributedApplication.ClusterChannel;

            if (SenseNet.ContentRepository.RepositoryInstance.RestoreIndexOnStartup())
            {
                BackupTools.RestoreIndex(false, consoleOut);
            }

            CreateWriterAndReader();

            IndexingActivityQueue.Startup(consoleOut);

            Warmup();

            var commitStart = new ThreadStart(CommitWorker);
            var t           = new Thread(commitStart);

            t.Start();

            SnTrace.Index.Write("LM: 'CommitWorker' thread started. ManagedThreadId: {0}", t.ManagedThreadId);
        }
コード例 #7
0
ファイル: LuceneManager.cs プロジェクト: sztomi/sensenet
 public static void BackupAndShutDown()
 {
     ShutDown();
     BackupTools.BackupIndexImmediatelly();
 }
コード例 #8
0
ファイル: LuceneManager.cs プロジェクト: sztomi/sensenet
 public static void Backup()
 {
     BackupTools.SynchronousBackupIndex();
 }