Ignore:
Timestamp:
01/15/09 14:53:13 (12 years ago)
Author:
msteinbi
Message:

Implementing Lifecycle Management (#453)

File:
1 edited

Legend:

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

    r1127 r1133  
    5858      lifecycleManager = ServiceLocator.GetLifecycleManager();
    5959
    60       lifecycleManager.OnServerHeartbeat +=
    61         new EventHandler(lifecycleManager_OnServerHeartbeat);
     60      lifecycleManager.RegisterHeartbeat(
     61        new EventHandler(lifecycleManager_OnServerHeartbeat));
    6262
    6363      lastHeartbeats = new Dictionary<Guid, DateTime>();
     
    9090                foreach (Job job in allJobs) {
    9191                  if (job.Client.ClientId == client.ClientId) {
    92                     // TODO check for job results
     92                    List<JobResult> allJobResults = new List<JobResult>(jobResultAdapter.GetAll());
     93                    foreach (JobResult jR in allJobResults) {
     94                      JobResult lastJobResult = null;
     95                      if (jR.Job != null && jR.Job.Id == job.Id) {
     96                        if (lastJobResult != null) {
     97
     98                        }
     99                      }
     100                    }
     101
     102
    93103                    job.Client = null;
    94104                    job.Percentage = 0;
     
    231241      long jobId,
    232242      byte[] result,
     243      double percentage,
    233244      Exception exception, 
    234245      bool finished) {
     
    239250      Job job =
    240251        jobAdapter.GetById(jobId);
     252
     253      if (job.Client == null)    {
     254        response.Success = false;
     255        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
     256        return response;
     257      }
     258      if (job.Client.ClientId != clientId) {
     259        response.Success = false;
     260        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_CLIENT_FOR_JOB;
     261        return response;
     262      }
    241263      if (job == null) {
    242264        response.Success = false;
    243         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JO_WITH_THIS_ID;
     265        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOB_WITH_THIS_ID;
    244266        return response;
    245267      }
     
    249271        return response;
    250272      }
     273      job.SerializedJob = result;
     274      job.Percentage = percentage;
     275
    251276      if (finished) {
    252277        job.State = State.finished;
     
    263288      jobResult.Job = job;
    264289      jobResult.Result = result;
     290      jobResult.Percentage = percentage;
    265291      jobResult.Exception = exception;
    266292
    267       jobResultAdapter.Update(jobResult);   
     293      jobResultAdapter.Update(jobResult);
     294      jobAdapter.Update(job);
    268295
    269296      response.Success = true;
Note: See TracChangeset for help on using the changeset viewer.