Example #1
0
			///////////////////////////////

			// Clean-up is called whenever we know that a task will never
			// be executed.  It is never called on tasks for who DoTaskReal
			// has been called (except when rescheduled).  Cleanup is also
			// called when a task is cancelled.

			public void Cleanup ()
			{
				try {
					DoCleanup ();
				} catch (Exception ex) {
					Logger.Log.Warn (ex, "Caught exception cleaning up task '{0}'", Tag);
				} finally {
					Reschedule = false;
					scheduler = null;
				}
			}
Example #2
0
			///////////////////////////////
			
			public void DoTask ()
			{
				if (! cancelled) {
					if (Debug)
						Logger.Log.Debug ("Starting task {0}", Tag);
					child_task_group = null;
					Reschedule = false;
					TouchAllTaskGroups ();

					Stopwatch sw = new Stopwatch ();
					sw.Start ();
						
					try {
						DoTaskReal ();
					} catch (Exception ex) {
						misfires ++;
						Logger.Log.Warn (ex,
								 "Caught exception in DoTaskReal\n" +
								 "        Tag: {0}\n" +
								 "    Creator: {1}\n" +
								 "Description: {2}\n" +
								 "   Priority: {3} ({4})", 
								 Tag, Creator, Description, Priority, SubPriority);
						if (misfires >= MAX_TASK_EXCEPTION) {
							Log.Warn ("More than {5} exceptions in DoTaskReal. Disabling further execution of task:\n" +
								 "        Tag: {0}\n" +
								 "    Creator: {1}\n" +
								 "Description: {2}\n" +
								 "   Priority: {3} ({4})", 
								 Tag, Creator, Description, Priority, SubPriority, MAX_TASK_EXCEPTION);
							Cancel ("Exceptions in DoTaskReal");
						}
					}
					sw.Stop ();
					if (Debug)
						Logger.Log.Debug ("Finished task {0} in {1}", Tag, sw);

					if (cancelled) {
						return;
					} else if (Reschedule) {
						++count;
						if (Debug)
							Log.Debug ("Rescheduling task {0}", Tag);
						scheduler.Add (this); // re-add ourselves
					} else {
						DecrementAllTaskGroups ();
						scheduler = null;
					}
				}
			}
Example #3
0
			public void Schedule (Scheduler scheduler)
			{
				if (this.cancelled)
					return; // do not schedule a cancelled task

				// Increment the task groups the first
				// time a task is scheduled.
				if (this.scheduler == null)
					IncrementAllTaskGroups ();
				this.timestamp = DateTime.Now;
				this.scheduler = scheduler;
				this.cancelled = false;
			}
Example #4
0
		static private void ShutdownHook (Scheduler.Task task)
		{
			try {
				Synchronize (SynchronizationTarget.Remote);

				// FIXME: This may not be safe to do here
				Logger.Log.Debug ("Purging locally synchronized indexes");
				Directory.Delete (local_index_dir, true);
			} catch (Exception ex) {
				Logger.Log.Error (ex, "Caught exception while doing shutdown synchronization");
			}
		}
Example #5
0
		////////////////////////////////////////////////////////////////

		static private void SynchronizeHook (Scheduler.Task task)
                {
			try {
				Synchronize (SynchronizationTarget.Remote);
			} catch (Exception ex) {
				Logger.Log.Error (ex, "Caught exception while synchronizing");
			}

                        task.Reschedule = true;
                        task.TriggerTime = DateTime.Now.AddMinutes (sync_interval_in_minutes);
                }
Example #6
0
		// Ouch! What a name ?!
		private void ContinueIndexerIndexableIndexing (Scheduler.Task task)
		{
			Flush (true);
		}