Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1160


Ignore:
Timestamp:
01/21/09 16:22:25 (15 years ago)
Author:
msteinbi
Message:

Implementing Lifecycle Management (#453)

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/app.config

    r1144 r1160  
    55    <connectionStrings>
    66        <add name="HeuristicLab.Hive.Server.ADODataAccess.Properties.Settings.HiveServerConnectionString"
    7             connectionString="Data Source=10.22.20.84;Initial Catalog=HiveServer;Persist Security Info=True;User ID=hive;Password=hive"
     7            connectionString="Data Source=10.22.20.84;Initial Catalog=HiveServerTesting;Persist Security Info=True;User ID=hive;Password=hive"
    88            providerName="System.Data.SqlClient" />
    99    </connectionStrings>
  • trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs

    r1158 r1160  
    8080    void lifecycleManager_OnServerHeartbeat(object sender, EventArgs e) {
    8181      List<ClientInfo> allClients = new List<ClientInfo>(clientAdapter.GetAll());
    82       List<Job> allJobs = new List<Job>(jobAdapter.GetAll());
    8382
    8483      foreach (ClientInfo client in allClients) {
     
    8988            client.State = State.offline;
    9089            clientAdapter.Update(client);
     90            foreach (Job job in jobAdapter.GetJobsOf(client)) {
     91              jobManager.ResetJobsDependingOnResults(job);
     92            }
    9193          } else {
    9294            DateTime lastHbOfClient = lastHeartbeats[client.ClientId];
     
    98100              if (client.State == State.calculating) {
    99101                // check wich job the client was calculating and reset it
    100                 foreach (Job job in allJobs) {
    101                   if (job.Client.ClientId == client.ClientId) {
    102                     jobManager.ResetJobsDependingOnResults(job);
    103                   }
     102                foreach (Job job in jobAdapter.GetJobsOf(client)) {
     103                  jobManager.ResetJobsDependingOnResults(job);
    104104                }
    105105              }
     
    195195
    196196      if (hbData.jobProgress != null) {
     197        List<Job> jobsOfClient = new List<Job>(jobAdapter.GetJobsOf(clientAdapter.GetById(hbData.ClientId)));
     198        if (jobsOfClient == null || jobsOfClient.Count == 0) {
     199          response.Success = false;
     200          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
     201          return response;
     202        }
     203
    197204        foreach (KeyValuePair<long, double> jobProgress in hbData.jobProgress) {
    198205          Job curJob = jobAdapter.GetById(jobProgress.Key);
    199           curJob.Percentage = jobProgress.Value;
    200           jobAdapter.Update(curJob);
     206          if (curJob.Client == null || curJob.Client.ClientId != hbData.ClientId) {
     207            response.Success = false;
     208            response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
     209          } else {
     210            curJob.Percentage = jobProgress.Value;
     211            jobAdapter.Update(curJob);
     212          }
    201213        }
    202214      }
     
    228240        response.Success = true;
    229241        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED;
    230         return response;
     242      } else {
     243        response.Success = true;
     244        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT;
    231245      }
    232246
    233247      jobLock.ReleaseMutex();
    234 
    235       response.Success = true;
    236       response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT;
     248      /// End Critical section ///
     249
    237250      return response;
    238251    }
  • trunk/sources/HeuristicLab.Hive.Server.Core/JobManager.cs

    r1149 r1160  
    5050
    5151    public void ResetJobsDependingOnResults(Job job) {
    52       List<JobResult> allJobResults = new List<JobResult>(jobResultAdapter.GetAll());
     52      List<JobResult> allJobResults = new List<JobResult>(jobResultAdapter.GetResultsOf(job));
    5353      JobResult lastJobResult = null;
    5454      foreach (JobResult jR in allJobResults) {
    55         if (jR.Job != null && jR.Job.Id == job.Id) {
    56           if (lastJobResult != null) {
    57             // if lastJobResult was before the current jobResult the lastJobResult must be updated
    58             if ((jR.timestamp.Subtract(lastJobResult.timestamp)).Seconds > 0)
    59               lastJobResult = jR;
    60           }
    61         }
     55        // if lastJobResult was before the current jobResult the lastJobResult must be updated
     56        if (lastJobResult == null ||         
     57            (jR.timestamp > lastJobResult.timestamp))
     58          lastJobResult = jR;
    6259      }
    6360      if (lastJobResult != null) {
    64         job.Client = null;
    6561        job.Percentage = lastJobResult.Percentage;
    66         job.State = State.offline;
    6762        job.SerializedJob = lastJobResult.Result;
    6863      } else {
    69         job.Client = null;
    7064        job.Percentage = 0;
    71         job.State = State.offline;
    7265      }
     66
     67      job.Client = null;
     68      job.State = State.offline;
     69
    7370      jobAdapter.Update(job);
    7471    }
Note: See TracChangeset for help on using the changeset viewer.