Example #1
0
 /// <summary>
 /// Enqueue a new Tracker into the all trackers queue.
 /// </summary>
 /// <param name="client">
 /// The TrackerData sent from the tracker
 /// </param>
 /// <returns>
 /// true if added successfully, false otherwise
 /// </returns>
 public void EnqueueNewTracker(TrackerData client)
 {
     lock (allTrackers)
     {
         if (! allTrackers.Contains(client))
         {
             allTrackers.Add(client);
         }
     }
 }
Example #2
0
 protected bool Equals(TrackerData other)
 {
     return string.Equals(Guid, other.Guid);
 }
Example #3
0
        /// <summary>
        /// Make a deep copy of <code>rhs</code>.
        /// If rhs is null, then null is returned.
        /// </summary>
        /// <param name="rhs">
        /// The <see cref="TrackerData"/> to make a copy of.
        /// </param>
        /// <returns>
        /// A TrackerData that is a copy of <code>rhs</code>, null if <code>rhs</code> is null.
        /// </returns>
        public static TrackerData DeepCopy(TrackerData rhs)
        {
            if (rhs == null)
            {
                return null;
            }

            TrackerData copy = new TrackerData()
            {
                Guid = string.Copy(rhs.Guid),
                HostName = string.Copy(rhs.HostName),
                Status = rhs.Status,
                LastCheckinTime = rhs.LastCheckinTime,
                CurrentJob = JobData.DeepCopy(rhs.CurrentJob) ?? JobData.EmptyJob
            };

            return copy;
        }
Example #4
0
 private bool TrackerShouldBeRemoved(TrackerData td, long currTime)
 {
     return TimeSinceLastCheckin(td, currTime) > 3*lateCheckinLimit &&
            td.Status == TrackerStatus.NO_RESPONSE;
 }
Example #5
0
 private long TimeSinceLastCheckin(TrackerData td, long curTime)
 {
     return curTime - td.LastCheckinTime;
 }
Example #6
0
        private bool RequeueJobIfNeeded(TrackerData td)
        {
            bool wasRemoved = false;
            JobData jd = td.CurrentJob;

            if (!jd.Equals(JobData.EmptyJob) && jd.Status == JobStatus.RUNNNG)
            {
                JobData removedJob = null;
                wasRemoved = runningJobs.TryRemove(Guid.Parse(jd.Guid), out removedJob);
                if (wasRemoved)
                {
                    removedJob.Status = JobStatus.QUEUED;
                    PushJob(removedJob);

                    logger.InfoFormat("Job {0} ({1}) was requeued because its tracker went offline.",
                        removedJob.FriendlyName, removedJob.Guid);
                }
            }

            return wasRemoved;
        }
Example #7
0
 private bool IsLate(TrackerData td, long currTime)
 {
     return TimeSinceLastCheckin(td, currTime) > lateCheckinLimit;
 }
Example #8
0
 /// <summary>
 /// Update the tracker specified by <code>td</code> with the 
 /// info from <code>td</code>.
 /// </summary>
 /// <param name="td">
 /// The updated TrackerData for some tracker.
 /// </param>
 public void UpdateTracker(TrackerData td)
 {
     td.LastCheckinTime = Utils.CurrentUTCMillies();
     lock (allTrackers)
     {
         int i = allTrackers.FindIndex(t => t.Equals(td));
         if (i < 0)
             allTrackers.Add(td);
         else
             allTrackers[i] = td;
     }
 }
Example #9
0
 /// <summary>
 /// Return a list of trackers. The <code>trackers</code> parameter will
 /// be allocated and populated with ref's to the TrackerDatas in this queue.
 /// </summary>
 /// <param name="trackers">
 /// A handle to an uninitialized array of TrackerData.
 /// </param>
 public void GetTrackersArray(out TrackerData[] trackers)
 {
     lock (allTrackers)
     {
         trackers = new TrackerData[allTrackers.Count];
         allTrackers.CopyTo(trackers, 0);
     }
 }