Ejemplo n.º 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, ContentRepository.Storage.Data.RepositoryConfiguration.IndexBackupCreatorId));
     if (Environment.MachineName == _machine && ContentRepository.Storage.Data.RepositoryConfiguration.IndexBackupCreatorId == _indexBackupCreatorId)
     {
         Debug.WriteLine(String.Format("@> {0} =========== BackupIndex START id: {1}", AppDomain.CurrentDomain.FriendlyName, 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)
         {
             msg = e.Message;
         }
         finally
         {
             BackupTools.DistributedNotifyProgress = false;
         }
         new IndexBackupFinishedMessage(msg).Send();
         Debug.WriteLine(String.Format("@> {0} =========== BackupIndex END. id: {1}", AppDomain.CurrentDomain.FriendlyName, ContentRepository.Storage.Data.RepositoryConfiguration.IndexBackupCreatorId));
     }
 }
Ejemplo n.º 2
0
        /*======================================================================================================= IIndexPopulator Members */

        // caller: IndexPopulator.Populator, Import.Importer, Tests.Initializer, RunOnce
        public void ClearAndPopulateAll(bool backup = true)
        {
            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);
                        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 ... ");
                IndexingActivityManager.DeleteAllActivities();
                RepositoryInstance.Instance.ConsoleWriteLine("ok");
                if (backup)
                {
                    RepositoryInstance.Instance.ConsoleWrite("  Making backup ... ");
                    BackupTools.BackupIndexImmediatelly();
                    RepositoryInstance.Instance.ConsoleWriteLine("ok");
                }
                traceOperation.IsSuccessful = true;
            }
        }