Changeset 970


Ignore:
Timestamp:
12/11/08 16:41:05 (12 years ago)
Author:
msteinbi
Message:

Implementation of ClientCommunicator, heartbet and pulljob (#399)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs

    r941 r970  
    1616  /// </summary>
    1717  public class ClientCommunicator: IClientCommunicator {
    18     LinkedList<long> jobs;
    1918    int nrOfJobs = 1;
    2019
    2120    IClientAdapter clientAdapter;
     21    IJobAdapter jobAdapter;
    2222
    2323    public ClientCommunicator() {
    24       clientAdapter = ServiceLocator.GetClientAdapter();
     24      clientAdapter = ServiceLocator.GetClientAdapter();
     25      jobAdapter = ServiceLocator.GetJobAdapter();
    2526
    26       jobs = new LinkedList<long>();
    27       for (long i = 0; i < nrOfJobs; i++) {
    28         jobs.AddFirst(i);
    29       }
    3027    }
    3128
     
    5956      response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_HARDBEAT_RECEIVED;
    6057      response.ActionRequest = new List<MessageContainer>();
    61       if (jobs.Count > 0)
     58      List<Job> allJobs = new List<Job>(jobAdapter.GetAllJobs());
     59      if (allJobs.Count > 0)
    6260        response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.FetchJob));
    6361      else
     
    7068      ResponseJob response = new ResponseJob();
    7169      lock (this) {
    72         if (jobs.Last != null) {
    73           response.JobId = jobs.Last.Value;
    74           jobs.RemoveLast();
     70        LinkedList<Job> allJobs = new LinkedList<Job>(jobAdapter.GetAllJobs());
     71        if (allJobs.Last != null) {
     72          response.JobId = allJobs.Last.Value.JobId;
     73          jobAdapter.DeleteJob(allJobs.Last.Value);   
    7574          response.SerializedJob = PersistenceManager.SaveToGZip(new TestJob());
    7675          response.Success = true;
Note: See TracChangeset for help on using the changeset viewer.