Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1752


Ignore:
Timestamp:
05/07/09 14:23:48 (15 years ago)
Author:
msteinbi
Message:

time to life added for new assigned jobs (#531)

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Contracts/3.2/ApplicationConstants.cs

    r1596 r1752  
    2929
    3030    public static int HEARTBEAT_MAX_DIF = 120; // value in seconds
     31    public static int JOB_TIME_TO_LIVE = 5;
    3132
    3233    public static string RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS = "Logged in";
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs

    r1716 r1752  
    4545    private static Dictionary<Guid, DateTime> lastHeartbeats =
    4646      new Dictionary<Guid,DateTime>();
     47    private static Dictionary<Guid, int> newAssignedJobs =
     48      new Dictionary<Guid, int>();
    4749
    4850    private static ReaderWriterLockSlim heartbeatLock =
     
    110112                foreach (Job job in jobAdapter.GetActiveJobsOf(client)) {
    111113                  jobManager.ResetJobsDependingOnResults(job);
     114                  lock (newAssignedJobs) {
     115                    if (newAssignedJobs.ContainsKey(job.Id))
     116                      newAssignedJobs.Remove(job.Id);
     117                  }
    112118                }
    113119
     
    317323          }
    318324          if (!found) {
    319             currJob.State = State.offline;
    320             jobAdapter.Update(currJob);
     325            lock (newAssignedJobs) {
     326              if (newAssignedJobs.ContainsKey(currJob.Id)) {
     327                newAssignedJobs[currJob.Id]--;
     328
     329                if (newAssignedJobs[currJob.Id] <= 0) {
     330                  currJob.State = State.offline;
     331                  jobAdapter.Update(currJob);
     332                  newAssignedJobs.Remove(currJob.Id);
     333                }
     334              } else {
     335                currJob.State = State.offline;
     336                jobAdapter.Update(currJob);
     337              }
     338            } // lock
     339          } else {
     340            lock (newAssignedJobs) {
     341              if (newAssignedJobs.ContainsKey(currJob.Id))
     342                newAssignedJobs.Remove(currJob.Id);
     343            }
    321344          }
    322345        }
     
    338361        response.Success = true;
    339362        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED;
     363        lock (newAssignedJobs) {
     364          newAssignedJobs.Add(job2Calculate.Id, ApplicationConstants.JOB_TIME_TO_LIVE);
     365        }
    340366      } else {
    341367        response.Success = false;
Note: See TracChangeset for help on using the changeset viewer.