Пример #1
0
 public bool Shutdown(DocumentIndexShutdownSetup setup)
 {
     if (!_isAlive)
     {
         return(true);
     }
     if (ShouldShutdown(setup))
     {
         Log("[Shutdown] started");
         DoOptimize(true);
         try
         {
             _hoot.FreeMemory(false);
             _hoot.Shutdown();
             if (setup.CleanStorage)
             {
                 string[] files = Directory.GetFiles(_hoot.Path, _hoot.FileName + ".*", SearchOption.AllDirectories);
                 foreach (var file in files)
                 {
                     File.Delete(file);
                 }
             }
             _shuttedDown();
             Log("[Shutdown] finished successfull");
             return(true);
         }
         finally
         {
             _isAlive = false;
         }
     }
     return(false);
 }
Пример #2
0
 public bool Shutdown(DocumentIndexShutdownSetup setup)
 {
     lock (_gate)
     {
         if (!_isAlive)
         {
             return(true);
         }
         if (setup.ForceShutdown || _lastUsedTime.AddMinutes(_documentIndexSetup.AliveTimeoutInMinutes) < DateTime.UtcNow)
         {
             try
             {
                 _shuttingDown();
                 _hoot.FreeMemory(false);
                 _hoot.Shutdown();
                 if (setup.CleanStorage)
                 {
                     string[] files = Directory.GetFiles(_hoot.Path, _hoot.FileName + ".*", SearchOption.AllDirectories);
                     foreach (var file in files)
                     {
                         File.Delete(file);
                     }
                 }
                 return(true);
             }
             finally
             {
                 _isAlive = false;
             }
         }
     }
     return(false);
 }
		public static void ShutdownDocumentIndexesIfRunning(this IDocumentIndexProvider documentIndexProvider, AccountName accountName, DocumentIndexShutdownSetup setup)
		{
			IEnumerable<IDocumentIndex> documentIndexes = documentIndexProvider.DocumentTypes.Select(t => documentIndexProvider.GetDocumentIndex(accountName, t)).Choose();
			foreach (IDocumentIndex documentIndex in documentIndexes)
			{
				documentIndex.Shutdown(setup);
			}
		}
		public static void ShutdownDocumentIndexes(this IDocumentIndexProvider documentIndexProvider, IPluginContext context, DocumentIndexShutdownSetup setup, IActivityLogger logger)
		{
			foreach (IDocumentIndex documentIndex in GetDocumentIndexes(documentIndexProvider, context, runningOnly:false))
			{
				var success = documentIndex.Shutdown(setup);
				logger.DebugFormat("{0} was {1} shutted down", documentIndex.Type.TypeToken, success ? string.Empty : "not");
			}
		}
		public static void ShutdownDocumentIndexesIfRunning(this IDocumentIndexProvider documentIndexProvider, IPluginContext context, DocumentIndexShutdownSetup setup, IActivityLogger logger)
		{
			foreach (IDocumentIndex documentIndex in GetDocumentIndexes(documentIndexProvider, context, runningOnly:true))
			{
				if (documentIndex.Shutdown(setup))
				{
					logger.DebugFormat("{0} was shutted down", documentIndex.Type.TypeToken);
				}
			}
		}
Пример #6
0
        public bool Shutdown(DocumentIndexShutdownSetup setup)
        {
            if (!ShouldShutdown(setup))
            {
                return(false);
            }
            bool characterResult = _charactersIndex.Shutdown(setup);
            bool numberResult    = _numberIndex.Shutdown(setup);

            return(characterResult && numberResult);
        }
 public bool ShouldShutdown(DocumentIndexShutdownSetup setup)
 {
     lock (_gate)
     {
         if (_documentIndex == null)
         {
             return(false);
         }
         UpdateVersion();
         return(_documentIndex.ShouldShutdown(setup));
     }
 }
Пример #8
0
        public bool ShouldShutdown(DocumentIndexShutdownSetup setup)
        {
            if (!_isAlive)
            {
                Log("[ShouldShutdown] index is not alive");
                return(false);
            }
            if (setup.ForceShutdown)
            {
                Log("[ShouldShutdown] shutdown was forced");
                return(true);
            }
            var now            = DateTime.UtcNow;
            var isUsageTimeout = _lastUsedTime.AddMinutes(_documentIndexSetup.AliveTimeoutInMinutes) < now;

            Log("[ShouldShutdown] isUsageTimeout = {0}, last used time = {1}, current time = {2}".Fmt(isUsageTimeout, _lastUsedTime, now));
            return(isUsageTimeout);
        }
Пример #9
0
 public bool ShouldShutdown(DocumentIndexShutdownSetup setup)
 {
     return(_charactersIndex.ShouldShutdown(setup) && _numberIndex.ShouldShutdown(setup));
 }
Пример #10
0
 public static void ShutdownDocumentIndexes(this IDocumentIndexProvider documentIndexProvider, IPluginContext context, DocumentIndexShutdownSetup setup, IActivityLogger logger)
 {
     foreach (IDocumentIndex documentIndex in GetDocumentIndexes(documentIndexProvider, context, runningOnly:false))
     {
         var success = documentIndex.Shutdown(setup);
         logger.DebugFormat("{0} was {1} shutted down", documentIndex.Type.TypeToken, success ? string.Empty : "not");
     }
 }
Пример #11
0
 public static void ShutdownDocumentIndexesIfRunning(this IDocumentIndexProvider documentIndexProvider, IPluginContext context, DocumentIndexShutdownSetup setup, IActivityLogger logger)
 {
     foreach (IDocumentIndex documentIndex in GetDocumentIndexes(documentIndexProvider, context, runningOnly:true))
     {
         if (documentIndex.Shutdown(setup))
         {
             logger.DebugFormat("{0} was shutted down", documentIndex.Type.TypeToken);
         }
     }
 }
        public static void ShutdownDocumentIndexesIfRunning(this IDocumentIndexProvider documentIndexProvider, AccountName accountName, DocumentIndexShutdownSetup setup)
        {
            IEnumerable <IDocumentIndex> documentIndexes = documentIndexProvider.DocumentTypes.Select(t => documentIndexProvider.GetDocumentIndex(accountName, t)).Choose();

            foreach (IDocumentIndex documentIndex in documentIndexes)
            {
                documentIndex.Shutdown(setup);
            }
        }