|
|
@ -73,7 +73,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_isRunning)
|
|
|
|
if (_isRunning)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.Info("Another instance of this job is already running. Ignoring request.");
|
|
|
|
Logger.Trace("Queue is already running. Ignoring scheduler's request.");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_isRunning = true;
|
|
|
|
_isRunning = true;
|
|
|
@ -112,19 +112,19 @@ namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
/// <remarks>Job is only added to the queue if same job with the same targetId doesn't already exist in the queue.</remarks>
|
|
|
|
/// <remarks>Job is only added to the queue if same job with the same targetId doesn't already exist in the queue.</remarks>
|
|
|
|
public virtual bool QueueJob(Type jobType, int targetId = 0)
|
|
|
|
public virtual bool QueueJob(Type jobType, int targetId = 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.Debug("Adding job ({0}:{1}) to the queue", jobType, targetId);
|
|
|
|
Logger.Debug("Adding [{0}:{1}] to the queue", jobType.Name, targetId);
|
|
|
|
lock (Queue)
|
|
|
|
lock (Queue)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var queueTuple = new Tuple<Type, int>(jobType, targetId);
|
|
|
|
var queueTuple = new Tuple<Type, int>(jobType, targetId);
|
|
|
|
|
|
|
|
|
|
|
|
if (Queue.Contains(queueTuple))
|
|
|
|
if (Queue.Contains(queueTuple))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.Info("Job ({0}:{1}) already exists in queue. Skipping.", jobType, targetId);
|
|
|
|
Logger.Info("[{0}:{1}] already exists in job queue. Skipping.", jobType.Name, targetId);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Queue.Add(queueTuple);
|
|
|
|
Queue.Add(queueTuple);
|
|
|
|
Logger.Trace("Job ({0}:{1}) added to the queue", jobType, targetId);
|
|
|
|
Logger.Trace("Job [{0}:{1}] added to the queue", jobType.Name, targetId);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -132,7 +132,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_isRunning)
|
|
|
|
if (_isRunning)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.Trace("Queue is already running. Ignoring request.");
|
|
|
|
Logger.Trace("Queue is already running. No need to start it up.");
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_isRunning = true;
|
|
|
|
_isRunning = true;
|
|
|
@ -150,7 +150,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.ErrorException("Error has occured in queue processor thread", e);
|
|
|
|
Logger.ErrorException("Error has occurred in queue processor thread", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -158,13 +158,13 @@ namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
_jobThread = new Thread(starter) { Name = "JobQueueThread", Priority = ThreadPriority.BelowNormal };
|
|
|
|
_jobThread = new Thread(starter) { Name = "JobQueueThread" };
|
|
|
|
_jobThread.Start();
|
|
|
|
_jobThread.Start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.Warn("Execution lock has has fucked up. Thread still active. Ignoring request.");
|
|
|
|
Logger.Error("Execution lock has fucked up. Thread still active. Ignoring request.");
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -230,7 +230,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
var jobImplementation = _jobs.Where(t => t.GetType() == jobType).FirstOrDefault();
|
|
|
|
var jobImplementation = _jobs.Where(t => t.GetType() == jobType).FirstOrDefault();
|
|
|
|
if (jobImplementation == null)
|
|
|
|
if (jobImplementation == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.Error("Unable to locate implementation for '{0}'. Make sure its properly registered.", jobType.ToString());
|
|
|
|
Logger.Error("Unable to locate implementation for '{0}'. Make sure it is properly registered.", jobType);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -240,7 +240,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.Debug("Starting job '{0}'. Last execution {1}", settings.Name, settings.LastExecution);
|
|
|
|
Logger.Debug("Starting '{0}' job. Last execution {1}", settings.Name, settings.LastExecution);
|
|
|
|
|
|
|
|
|
|
|
|
var sw = Stopwatch.StartNew();
|
|
|
|
var sw = Stopwatch.StartNew();
|
|
|
|
|
|
|
|
|
|
|
@ -257,7 +257,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.ErrorException("An error has occurred while executing timer job " + jobImplementation.Name, e);
|
|
|
|
Logger.ErrorException("An error has occurred while executing job " + jobImplementation.Name, e);
|
|
|
|
_notification.Status = ProgressNotificationStatus.Failed;
|
|
|
|
_notification.Status = ProgressNotificationStatus.Failed;
|
|
|
|
_notification.CurrentMessage = jobImplementation.Name + " Failed.";
|
|
|
|
_notification.CurrentMessage = jobImplementation.Name + " Failed.";
|
|
|
|
|
|
|
|
|
|
|
|