NotifyAboutWork() публичный Метод

public NotifyAboutWork ( ) : void
Результат void
Пример #1
0
        public void Execute()
        {
            using (LogContext.WithDatabase(context.DatabaseName))
            {
                Init();
                var  name        = GetType().Name;
                var  workComment = "WORK BY " + name;
                bool isIdle      = false;
                while (context.RunIndexing)
                {
                    bool foundWork;
                    try
                    {
                        bool onlyFoundIdleWork;
                        foundWork = ExecuteIndexing(isIdle, out onlyFoundIdleWork);
                        if (foundWork && onlyFoundIdleWork == false)
                        {
                            isIdle = false;
                        }

                        while (context.RunIndexing) // we want to drain all of the pending tasks before the next run
                        {
                            if (ExecuteTasks() == false)
                            {
                                break;
                            }
                            foundWork = true;
                        }
                    }
                    catch (OutOfMemoryException oome)
                    {
                        foundWork = true;
                        HandleOutOfMemoryException(oome);
                    }
                    catch (AggregateException ae)
                    {
                        foundWork = true;
                        var actual = ae.ExtractSingleInnerException();
                        var oome   = actual as OutOfMemoryException;
                        if (oome == null)
                        {
                            if (IsEsentOutOfMemory(actual))
                            {
                                autoTuner.OutOfMemoryExceptionHappened();
                            }
                            Log.ErrorException("Failed to execute indexing", ae);
                        }
                        else
                        {
                            HandleOutOfMemoryException(oome);
                        }
                    }
                    catch (OperationCanceledException)
                    {
                        Log.Info("Got rude cancellation of indexing as a result of shutdown, aborting current indexing run");
                        return;
                    }
                    catch (Exception e)
                    {
                        foundWork = true; // we want to keep on trying, anyway, not wait for the timeout or more work
                        Log.ErrorException("Failed to execute indexing", e);
                        if (IsEsentOutOfMemory(e))
                        {
                            autoTuner.OutOfMemoryExceptionHappened();
                        }
                    }
                    if (foundWork == false && context.RunIndexing)
                    {
                        isIdle = context.WaitForWork(context.Configuration.TimeToWaitBeforeRunningIdleIndexes, ref workCounter, () =>
                        {
                            try
                            {
                                FlushIndexes();
                            }
                            catch (Exception e)
                            {
                                Log.WarnException("Could not flush indexes properly", e);
                            }
                        }, name);
                    }
                    else // notify the tasks executer that it has work to do
                    {
                        context.ShouldNotifyAboutWork(() => workComment);
                        context.NotifyAboutWork();
                    }
                }
                Dispose();
            }
        }
Пример #2
0
        public void Execute()
        {
            using (LogContext.WithDatabase(context.DatabaseName))
            {
                Init();

                var name        = GetType().Name;
                var workComment = "WORK BY " + name;

                bool isIdle = false;
                while (ShouldRun)
                {
                    bool foundWork;
                    try
                    {
                        bool onlyFoundIdleWork;
                        foundWork = ExecuteIndexing(isIdle, out onlyFoundIdleWork);
                        if (foundWork && onlyFoundIdleWork == false)
                        {
                            isIdle = false;
                        }

                        var foundTasksWork = ExecuteTasks();
                        foundWork = foundWork || foundTasksWork;
                    }
                    catch (OutOfMemoryException oome)
                    {
                        foundWork = true;
                        HandleOutOfMemoryException(oome);
                    }
                    catch (AggregateException ae)
                    {
                        foundWork = true;
                        var actual = ae.ExtractSingleInnerException();
                        var oome   = actual as OutOfMemoryException;
                        if (oome == null)
                        {
                            if (TransactionalStorageHelper.IsOutOfMemoryException(actual))
                            {
                                autoTuner.HandleOutOfMemory();
                            }
                            Log.ErrorException("Failed to execute indexing", ae);
                        }
                        else
                        {
                            HandleOutOfMemoryException(oome);
                        }
                    }
                    catch (OperationCanceledException)
                    {
                        Log.Info("Got rude cancellation of indexing as a result of shutdown, aborting current indexing run");
                        return;
                    }
                    catch (Exception e)
                    {
                        foundWork = true; // we want to keep on trying, anyway, not wait for the timeout or more work
                        Log.ErrorException("Failed to execute indexing", e);
                        if (TransactionalStorageHelper.IsOutOfMemoryException(e))
                        {
                            autoTuner.HandleOutOfMemory();
                        }
                    }
                    if (foundWork == false && ShouldRun)
                    {
                        isIdle = context.WaitForWork(context.Configuration.Indexing.TimeToWaitBeforeRunningIdleIndexes.AsTimeSpan, ref workCounter, () =>
                        {
                            try
                            {
                                FlushIndexes();
                            }
                            catch (Exception e)
                            {
                                Log.WarnException("Could not flush indexes properly", e);
                            }

                            try
                            {
                                CleanupPrefetchers();
                            }
                            catch (Exception e)
                            {
                                Log.WarnException("Could not cleanup prefetchers properly", e);
                            }

                            try
                            {
                                CleanupScheduledReductions();
                            }
                            catch (Exception e)
                            {
                                Log.WarnException("Could not cleanup scheduled reductions properly", e);
                            }
                        }, name);
                    }
                    else // notify the tasks executer that it has work to do
                    {
                        context.ShouldNotifyAboutWork(() => workComment);
                        context.NotifyAboutWork();
                    }
                }
                Dispose();
            }
        }
Пример #3
0
 public void Execute()
 {
     using (new DisposableAction(() => LogContext.DatabaseName.Value = null))
     {
         LogContext.DatabaseName.Value = context.DatabaseName;
         var name        = GetType().Name;
         var workComment = "WORK BY " + name;
         while (context.DoWork)
         {
             var foundWork = false;
             try
             {
                 foundWork = ExecuteIndexing();
                 while (context.DoWork)                         // we want to drain all of the pending tasks before the next run
                 {
                     if (ExecuteTasks() == false)
                     {
                         break;
                     }
                     foundWork = true;
                 }
             }
             catch (OutOfMemoryException oome)
             {
                 foundWork = true;
                 HandleOutOfMemoryException(oome);
             }
             catch (AggregateException ae)
             {
                 foundWork = true;
                 var oome = ae.ExtractSingleInnerException() as OutOfMemoryException;
                 if (oome == null)
                 {
                     log.ErrorException("Failed to execute indexing", ae);
                 }
                 else
                 {
                     HandleOutOfMemoryException(oome);
                 }
             }
             catch (OperationCanceledException)
             {
                 log.Info("Got rude cancelation of indexing as a result of shutdown, aborting current indexing run");
                 return;
             }
             catch (Exception e)
             {
                 foundWork = true;                         // we want to keep on trying, anyway, not wait for the timeout or more work
                 log.ErrorException("Failed to execute indexing", e);
             }
             if (foundWork == false)
             {
                 context.WaitForWork(TimeSpan.FromHours(1), ref workCounter, FlushIndexes, name);
             }
             else                     // notify the tasks executer that it has work to do
             {
                 context.ShouldNotifyAboutWork(() => workComment);
                 context.NotifyAboutWork();
             }
         }
     }
 }
Пример #4
0
        public void Execute()
        {
            using (LogContext.WithResource(context.DatabaseName))
            {
                Init();

                var name        = GetType().Name;
                var workComment = "WORK BY " + name;

                bool isIdle = false;
                while (ShouldRun)
                {
                    bool foundWork;
                    try
                    {
                        bool onlyFoundIdleWork;
                        foundWork = ExecuteIndexing(isIdle, out onlyFoundIdleWork);
                        if (foundWork && onlyFoundIdleWork == false)
                        {
                            isIdle = false;
                        }

                        var foundTasksWork = ExecuteTasks();
                        foundWork = foundWork || foundTasksWork;
                    }
                    catch (OutOfMemoryException oome)
                    {
                        foundWork = true;
                        HandleSystemOutOfMemoryException(oome);
                    }
                    catch (OperationCanceledException)
                    {
                        Log.Info("Got rude cancellation of indexing, aborting current indexing run");
                        continue;
                    }
                    catch (AggregateException ae)
                    {
                        if (IsOperationCanceledException(ae))
                        {
                            Log.Info("Got rude cancellation of indexing, aborting current indexing run");
                            continue;
                        }

                        foundWork = true;
                        if (HandleIfOutOfMemory(ae, null) == false)
                        {
                            Log.ErrorException("Failed to execute indexing", ae);
                        }
                    }
                    catch (Exception e)
                    {
                        foundWork = true; // we want to keep on trying, anyway, not wait for the timeout or more work
                        if (HandleIfOutOfMemory(e, null) == false)
                        {
                            Log.ErrorException("Failed to execute indexing", e);
                        }
                    }
                    if (foundWork == false && ShouldRun)
                    {
                        isIdle = context.WaitForWork(context.Configuration.TimeToWaitBeforeRunningIdleIndexes, ref workCounter, () =>
                        {
                            try
                            {
                                FlushIndexes();
                            }
                            catch (Exception e)
                            {
                                Log.WarnException("Could not flush indexes properly", e);
                            }

                            try
                            {
                                CleanupPrefetchers();
                            }
                            catch (Exception e)
                            {
                                Log.WarnException("Could not cleanup prefetchers properly", e);
                            }

                            try
                            {
                                CleanupScheduledReductions();
                            }
                            catch (Exception e)
                            {
                                Log.WarnException("Could not cleanup scheduled reductions properly", e);
                            }
                        }, name);
                    }
                    else // notify the tasks executer that it has work to do
                    {
                        context.ShouldNotifyAboutWork(() => workComment);
                        context.NotifyAboutWork();
                    }
                }
                Dispose();
            }
        }