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)

Location:
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3
Files:
4 edited

Legend:

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

    r4263 r4264  
    2121
    2222    public bool ExistsJobForSlave(HeartBeatData hbData) {
    23       List<JobDto> allOfflineJobsForSlave = new List<JobDto>(DaoLocator.JobDao.FindFittingJobsForSlave(State.Offline, hbData.FreeCores, hbData.FreeMemory, hbData.SlaveId));
     23      List<JobDto> allOfflineJobsForSlave = new List<JobDto>(DaoLocator.JobDao.FindFittingJobsForSlave(JobState.Offline, hbData.FreeCores, hbData.FreeMemory, hbData.SlaveId));
    2424      return (allOfflineJobsForSlave != null && allOfflineJobsForSlave.Count > 0);
    2525    }
     
    3131        using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = ApplicationConstants.ISOLATION_LEVEL_SCOPE })) {
    3232          ClientDto slave = DaoLocator.ClientDao.FindById(slaveId);
    33           LinkedList<JobDto> allOfflineJobsForSlave = new LinkedList<JobDto>(DaoLocator.JobDao.FindFittingJobsForSlave(State.Offline, slave.NrOfFreeCores, slave.FreeMemory, slave.Id));
     33          LinkedList<JobDto> allOfflineJobsForSlave = new LinkedList<JobDto>(DaoLocator.JobDao.FindFittingJobsForSlave(JobState.Offline, slave.NrOfFreeCores, slave.FreeMemory, slave.Id));
    3434          if (allOfflineJobsForSlave != null && allOfflineJobsForSlave.Count > 0) {
    3535            jobToCalculate = allOfflineJobsForSlave.First.Value;
    36             jobToCalculate.State = State.Calculating;
     36            jobToCalculate.State = JobState.Calculating;
    3737            jobToCalculate.Client = slave;
    38             jobToCalculate.Client.State = State.Calculating;
     38            jobToCalculate.Client.State = SlaveState.Calculating;
    3939            jobToCalculate.DateCalculated = DateTime.Now;
    4040            DaoLocator.JobDao.AssignSlaveToJob(slave.Id, jobToCalculate.Id);
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Facades/ServerConsoleFacade.cs

    r4263 r4264  
    108108    }
    109109
    110     public ResponseList<JobDto> GetAllJobsWithFilter(State jobState, int offset, int count) {
     110    public ResponseList<JobDto> GetAllJobsWithFilter(JobState jobState, int offset, int count) {
    111111      using (contextFactory.GetContext(false)) {
    112112        secMan.Authorize("AccessJobs", sessionID, Guid.Empty);
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/JobManager.cs

    r4263 r4264  
    5858      List<JobDto> allJobs = new List<JobDto>(DaoLocator.JobDao.FindAll());
    5959      foreach (JobDto curJob in allJobs) {
    60         if (curJob.State != State.Calculating && curJob.State != State.Finished) {
     60        if (curJob.State != JobState.Calculating && curJob.State != JobState.Finished) {
    6161          DaoLocator.JobDao.SetJobOffline(curJob);
    6262        }
     
    8686    }
    8787
    88     public ResponseList<JobDto> GetAllJobsWithFilter(State jobState, int offset, int count) {
     88    public ResponseList<JobDto> GetAllJobsWithFilter(JobState jobState, int offset, int count) {
    8989      ResponseList<JobDto> response = new ResponseList<JobDto>();
    9090      response.List = new List<JobDto>(DaoLocator.JobDao.FindWithLimitations(jobState, offset, count));
     
    153153
    154154      if (job != null && job.JobInfo != null) {
    155         if (job.JobInfo.State != State.Offline) {
     155        if (job.JobInfo.State != JobState.Offline) {
    156156          response.StatusMessage = ResponseStatus.AddNewJob_JobStateMustBeOffline;
    157157          return response;
     
    222222
    223223      //if it's a snapshot but the result hasn't reached the server yet...
    224       if (snapshot && (job.State == State.RequestSnapshot || job.State == State.RequestSnapshotSent)) {
     224      if (snapshot && (job.State == JobState.SnapshotRequested || job.State == JobState.SnapshotSent)) {
    225225        response.StatusMessage = ResponseStatus.GetLastSerializedResult_JobResultNotYetThere;
    226226
     
    229229
    230230      //if it's NOT a snapshot, NEITHER request NOR is it finished
    231       if (!requested && !snapshot && job.State != State.Finished) {
     231      if (!requested && !snapshot && job.State != JobState.Finished) {
    232232        response.StatusMessage = ResponseStatus.GetLastSerializedResult_JobResultNotYetThere;
    233233
     
    248248
    249249      JobDto job = DaoLocator.JobDao.FindById(jobId);
    250       if (job.State == State.RequestSnapshot || job.State == State.RequestSnapshotSent) {
     250      if (job.State == JobState.SnapshotRequested || job.State == JobState.SnapshotSent) {
    251251        response.StatusMessage = ResponseStatus.RequestSnapshot_SnapshotAlreadyRequested;
    252252        return response;
    253253      }
    254       if (job.State != State.Calculating) {
     254      if (job.State != JobState.Calculating) {
    255255        response.StatusMessage = ResponseStatus.RequestSnapshot_JobIsNotBeeingCalculated;
    256256        return response;
    257257      }
    258258      // job is in correct state
    259       job.State = State.RequestSnapshot;
     259      job.State = JobState.SnapshotRequested;
    260260      DaoLocator.JobDao.Update(job);
    261261
     
    275275        return response; // no commit needed
    276276      }
    277       if (job.State == State.Abort) {
     277      if (job.State == JobState.Aborted) {
    278278        //response.Success = true;
    279279        response.StatusMessage = ResponseStatus.AbortJob_AbortAlreadyRequested;
    280280        return response; // no commit needed
    281281      }
    282       if (job.State != State.Calculating && job.State != State.RequestSnapshot && job.State != State.RequestSnapshotSent) {
     282      if (job.State != JobState.Calculating && job.State != JobState.SnapshotRequested && job.State != JobState.SnapshotSent) {
    283283        //response.Success = false;
    284284        response.StatusMessage = ResponseStatus.AbortJob_JobIsNotBeeingCalculated;
     
    286286      }
    287287      // job is in correct state
    288       job.State = State.Abort;
     288      job.State = JobState.Aborted;
    289289      DaoLocator.JobDao.Update(job);
    290290
  • 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.