Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/19/10 13:30:56 (14 years ago)
Author:
cneumuel
Message:

Split up "State" to "JobState" and "SlaveState" (#1159)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/SlaveCommunicator.cs

    r4263 r4264  
    8383
    8484        foreach (ClientDto client in allClients) {
    85           if (client.State != State.Offline && client.State != State.NullState) {
     85          if (client.State != SlaveState.Offline && client.State != SlaveState.NullState) {
    8686            heartbeatLock.EnterUpgradeableReadLock();
    8787
     
    8989              Logger.Info("Client " + client.Id +
    9090                              " wasn't offline but hasn't sent heartbeats - setting offline");
    91               client.State = State.Offline;
     91              client.State = SlaveState.Offline;
    9292              DaoLocator.ClientDao.Update(client);
    9393              Logger.Info("Client " + client.Id +
     
    114114                Logger.Debug("setting client offline");
    115115                // client must be set offline
    116                 client.State = State.Offline;
     116                client.State = SlaveState.Offline;
    117117
    118118                //clientAdapter.Update(client);
     
    147147
    148148    private void CheckForPendingJobs() {
    149       IList<JobDto> pendingJobsInDB = new List<JobDto>(DaoLocator.JobDao.GetJobsByState(State.Pending));
     149      IList<JobDto> pendingJobsInDB = new List<JobDto>(DaoLocator.JobDao.GetJobsByState(JobState.Pending));
    150150
    151151      foreach (JobDto currJob in pendingJobsInDB) {
     
    153153          if (pendingJobs.ContainsKey(currJob.Id)) {
    154154            if (pendingJobs[currJob.Id] <= 0) {
    155               currJob.State = State.Offline;
     155              currJob.State = JobState.Offline;
    156156              DaoLocator.JobDao.Update(currJob);
    157157            } else {
     
    186186      //Really set offline?
    187187      //Reconnect issues with the currently calculating jobs
    188       slaveInfo.State = State.Idle;
     188      slaveInfo.State = SlaveState.Idle;
    189189      slaveInfo.CalendarSyncStatus = dbClient != null ? dbClient.CalendarSyncStatus : CalendarState.NotAllowedToFetch;
    190190
     
    255255      Logger.Debug("END Finished Client Fetching");
    256256      // check if the client is logged in
    257       if (client.State == State.Offline || client.State == State.NullState) {
     257      if (client.State == SlaveState.Offline || client.State == SlaveState.NullState) {
    258258        // response.Success = false;
    259259        response.StatusMessage = ResponseStatus.ProcessHeartBeat_UserNotLoggedIn;
     
    359359            response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));
    360360            Logger.Error("There is no job calculated by this user " + hbData.SlaveId + " Job: " + curJob);
    361           } else if (curJob.State == State.Abort) {
     361          } else if (curJob.State == JobState.Aborted) {
    362362            // a request to abort the job has been set
    363363            response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));
    364             curJob.State = State.Finished;
     364            curJob.State = JobState.Finished;
    365365          } else {
    366366            // save job progress
    367367            curJob.Percentage = jobProgress.Value;
    368368
    369             if (curJob.State == State.RequestSnapshot) {
     369            if (curJob.State == JobState.SnapshotRequested) {
    370370              // a request for a snapshot has been set
    371371              response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.RequestSnapshot, curJob.Id));
    372               curJob.State = State.RequestSnapshotSent;
     372              curJob.State = JobState.SnapshotSent;
    373373            }
    374374          }
     
    394394                Logger.Error("Job TTL reached Zero, Job gets removed: " + currJob + " and set back to offline. User that sucks: " + currJob.Client);
    395395
    396                 currJob.State = State.Offline;
     396                currJob.State = JobState.Offline;
    397397                DaoLocator.JobDao.Update(currJob);
    398398
     
    403403            } else {
    404404              Logger.Error("Job ID wasn't with the heartbeats:  " + currJob);
    405               currJob.State = State.Offline;
     405              currJob.State = JobState.Offline;
    406406              DaoLocator.JobDao.Update(currJob);
    407407            }
     
    516516        return response;
    517517      }
    518       if (job.JobInfo.State == State.Abort) {
     518      if (job.JobInfo.State == JobState.Aborted) {
    519519        //response.Success = false;
    520520        response.StatusMessage = ResponseStatus.ProcessJobResult_JobAborted;
     
    545545        return response;
    546546      }
    547       if (job.JobInfo.State == State.Finished) {
     547      if (job.JobInfo.State == JobState.Finished) {
    548548        response.StatusMessage = ResponseStatus.Ok;
    549549        response.JobId = jobId;
     
    555555      }
    556556      //Todo: RequestsnapshotSent => calculating?
    557       if (job.JobInfo.State == State.RequestSnapshotSent) {
    558         job.JobInfo.State = State.Calculating;
    559       }
    560       if (job.JobInfo.State != State.Calculating && job.JobInfo.State != State.Pending) {
     557      if (job.JobInfo.State == JobState.SnapshotSent) {
     558        job.JobInfo.State = JobState.Calculating;
     559      }
     560      if (job.JobInfo.State != JobState.Calculating && job.JobInfo.State != JobState.Pending) {
    561561        //response.Success = false;
    562562        response.StatusMessage = ResponseStatus.ProcessJobResult_InvalidJobState;
     
    571571
    572572      if (!string.IsNullOrEmpty(exception)) {
    573         job.JobInfo.State = State.Failed;
     573        job.JobInfo.State = JobState.Failed;
    574574        job.JobInfo.Exception = exception;
    575575        job.JobInfo.DateFinished = DateTime.Now;
    576576      } else if (finished) {
    577         job.JobInfo.State = State.Finished;
     577        job.JobInfo.State = JobState.Finished;
    578578        job.JobInfo.DateFinished = DateTime.Now;
    579579      }
     
    638638        return response;
    639639      }
    640       if (client.State == State.Calculating) {
     640      if (client.State == SlaveState.Calculating) {
    641641        // check wich job the client was calculating and reset it
    642642        IEnumerable<JobDto> jobsOfClient = DaoLocator.JobDao.FindActiveJobsOfSlave(client);
    643643        foreach (JobDto job in jobsOfClient) {
    644           if (job.State != State.Finished)
     644          if (job.State != JobState.Finished)
    645645            DaoLocator.JobDao.SetJobOffline(job);
    646646        }
    647647      }
    648648
    649       client.State = State.Offline;
     649      client.State = SlaveState.Offline;
    650650      DaoLocator.ClientDao.Update(client);
    651651
     
    668668        return response;
    669669      }
    670       if (job.State == State.Finished) {
     670      if (job.State == JobState.Finished) {
    671671        //response.Success = true;
    672672        response.StatusMessage = ResponseStatus.IsJobStillNeeded_JobAlreadyFinished;
     
    674674        return response;
    675675      }
    676       job.State = State.Pending;
     676      job.State = JobState.Pending;
    677677      lock (pendingJobs) {
    678678        pendingJobs.Add(job.Id, PENDING_TIMEOUT);
Note: See TracChangeset for help on using the changeset viewer.