Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1998


Ignore:
Timestamp:
06/04/09 15:12:36 (15 years ago)
Author:
msteinbi
Message:

added pending jobs functionality (#531)

Location:
trunk/sources
Files:
2 edited

Legend:

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

    r1939 r1998  
    2828namespace HeuristicLab.Hive.Contracts.BusinessObjects {
    2929
    30   public enum State { nullState, idle, calculating, offline, finished, abort, requestSnapshot, requestSnapshotSent };
     30  public enum State { nullState, idle, calculating, offline, finished, abort, requestSnapshot, requestSnapshotSent, pending };
    3131
    3232  [DataContract]
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs

    r1957 r1998  
    4747    private static Dictionary<Guid, int> newAssignedJobs =
    4848      new Dictionary<Guid, int>();
     49    private static Dictionary<Guid, int> pendingJobs =
     50      new Dictionary<Guid, int>();
    4951
    5052    private static ReaderWriterLockSlim heartbeatLock =
     
    5557    private IInternalJobManager jobManager;
    5658    private IScheduler scheduler;
     59
     60    private static int PENDING_TIMEOUT = 100;
    5761
    5862    /// <summary>
     
    139143          }
    140144        }
     145        CheckForPendingJobs(jobAdapter);
     146
    141147        tx.Commit();
    142148      }
     
    149155        if (session != null)
    150156          session.EndSession();
     157      }
     158    }
     159
     160    private void CheckForPendingJobs(IJobAdapter jobAdapter) {
     161      IList<Job> pendingJobsInDB = new List<Job>(jobAdapter.GetJobsByState(State.pending));
     162
     163      foreach (Job currJob in pendingJobsInDB) {
     164        lock (pendingJobs) {
     165          if (pendingJobs.ContainsKey(currJob.Id)) {
     166            if (pendingJobs[currJob.Id] <= 0) {
     167              currJob.State = State.offline;
     168              jobAdapter.Update(currJob);
     169            } else {
     170              pendingJobs[currJob.Id]--;
     171            }
     172          }
     173        }
    151174      }
    152175    }
     
    423446          job.State = State.calculating;
    424447        }
    425         if (job.State != State.calculating) {
     448        if (job.State != State.calculating && job.State != State.pending) {
    426449          response.Success = false;
    427450          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_JOB_STATE;
     
    587610          return response;
    588611        }
    589         //job.State = State.finished;
    590         //jobAdapter.Update(job);
     612        job.State = State.pending;
     613        lock (pendingJobs) {
     614          pendingJobs.Add(job.Id, PENDING_TIMEOUT);
     615        }
     616
     617        jobAdapter.Update(job);
    591618
    592619        response.Success = true;
Note: See TracChangeset for help on using the changeset viewer.