Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/28/13 13:57:49 (12 years ago)
Author:
ascheibe
Message:

#2019

  • added missing transactions in the Hive service
  • split scheduling transaction into smaller transactions
  • improved speed of job uploading (AddTask)
  • changed highest isolation level from Serializable to RepeatableRead as phantom reads shouldn't be a problem
Location:
trunk/sources/HeuristicLab.Services.Hive/3.3/Manager
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Services.Hive/3.3/Manager/EventManager.cs

    r7862 r9257  
    5050        SetTimeoutTasksWaiting();
    5151        DeleteObsoleteSlaves();
    52       }, true);
     52      });
    5353
    5454      trans.UseTransaction(() => {
    5555        FinishParentTasks();
    5656        UpdateStatistics();
    57       }, false);
     57      });
    5858    }
    5959
  • trunk/sources/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs

    r9123 r9257  
    3737      get { return ServiceLocator.Instance.TaskScheduler; }
    3838    }
     39    private DataAccess.ITransactionManager trans {
     40      get { return ServiceLocator.Instance.TransactionManager; }
     41    }
    3942
    4043    /// <summary>
     
    4447    public List<MessageContainer> ProcessHeartbeat(Heartbeat heartbeat) {
    4548      List<MessageContainer> actions = new List<MessageContainer>();
    46       Slave slave = dao.GetSlave(heartbeat.SlaveId);
     49      Slave slave = null;
     50      slave = trans.UseTransaction(() => { return dao.GetSlave(heartbeat.SlaveId); });
     51
    4752      if (slave == null) {
    4853        actions.Add(new MessageContainer(MessageContainer.MessageType.SayHello));
     
    6267        slave.SlaveState = (heartbeat.JobProgress != null && heartbeat.JobProgress.Count > 0) ? SlaveState.Calculating : SlaveState.Idle;
    6368        slave.LastHeartbeat = DateTime.Now;
    64         dao.UpdateSlave(slave);
     69
     70        trans.UseTransaction(() => { dao.UpdateSlave(slave); });
    6571
    6672        // update task data
     
    7682              DA.LogFactory.GetLogger(this.GetType().Namespace).Log("HeartbeatManager: The mutex used for scheduling could not be aquired.");
    7783            else {
    78               var availableTasks = taskScheduler.Schedule(dao.GetWaitingTasks(slave));
     84              IEnumerable<TaskInfoForScheduler> availableTasks = null;
     85              availableTasks = trans.UseTransaction(() => { return taskScheduler.Schedule(dao.GetWaitingTasks(slave)); });
    7986              if (availableTasks.Any()) {
    8087                var task = availableTasks.First();
     
    99106
    100107    private void AssignJob(Slave slave, Guid taskId) {
    101       var task = dao.UpdateTaskState(taskId, DataAccess.TaskState.Transferring, slave.Id, null, null);
     108      trans.UseTransaction(() => {
     109        var task = dao.UpdateTaskState(taskId, DataAccess.TaskState.Transferring, slave.Id, null, null);
    102110
    103       // from now on the task has some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout)
    104       task.LastHeartbeat = DateTime.Now;
    105       dao.UpdateTask(task);
     111        // from now on the task has some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout)
     112        task.LastHeartbeat = DateTime.Now;
     113        dao.UpdateTask(task);
     114      });
    106115    }
    107116
     
    121130        // process the jobProgresses
    122131        foreach (var jobProgress in heartbeat.JobProgress) {
    123           Task curTask = dao.GetTask(jobProgress.Key);
     132          Task curTask = null;
     133          curTask = trans.UseTransaction(() => { return dao.GetTask(jobProgress.Key); });
    124134          if (curTask == null) {
    125135            // task does not exist in db
     
    150160                  break;
    151161              }
    152               dao.UpdateTask(curTask);
     162              trans.UseTransaction(() => { dao.UpdateTask(curTask); });
    153163            }
    154164          }
     
    159169
    160170    private bool TaskIsAllowedToBeCalculatedBySlave(Guid slaveId, Task curTask) {
    161       var assignedResourceIds = dao.GetAssignedResources(curTask.Id).Select(x => x.Id);
    162       var slaveResourceIds = dao.GetParentResources(slaveId).Select(x => x.Id);
    163       return assignedResourceIds.Any(x => slaveResourceIds.Contains(x));
     171      return trans.UseTransaction(() => {
     172        var assignedResourceIds = dao.GetAssignedResources(curTask.Id).Select(x => x.Id);
     173        var slaveResourceIds = dao.GetParentResources(slaveId).Select(x => x.Id);
     174        return assignedResourceIds.Any(x => slaveResourceIds.Contains(x));
     175      });
    164176    }
    165177
    166178    private bool SlaveIsAllowedToCalculate(Guid slaveId) {
    167179      // the slave may only calculate if there is no downtime right now. this needs to be checked for every parent resource also
    168       return dao.GetParentResources(slaveId).All(r => dao.GetDowntimes(x => x.ResourceId == r.Id && x.DowntimeType == DA.DowntimeType.Offline && (DateTime.Now >= x.StartDate) && (DateTime.Now <= x.EndDate)).Count() == 0);
     180      return trans.UseTransaction(() => { return dao.GetParentResources(slaveId).All(r => dao.GetDowntimes(x => x.ResourceId == r.Id && x.DowntimeType == DA.DowntimeType.Offline && (DateTime.Now >= x.StartDate) && (DateTime.Now <= x.EndDate)).Count() == 0); });
    169181    }
    170182
    171183    private bool ShutdownSlaveComputer(Guid slaveId) {
    172       return dao.GetParentResources(slaveId).Any(r => dao.GetDowntimes(x => x.ResourceId == r.Id && x.DowntimeType == DA.DowntimeType.Shutdown && (DateTime.Now >= x.StartDate) && (DateTime.Now <= x.EndDate)).Count() != 0);
     184      return trans.UseTransaction(() => { return dao.GetParentResources(slaveId).Any(r => dao.GetDowntimes(x => x.ResourceId == r.Id && x.DowntimeType == DA.DowntimeType.Shutdown && (DateTime.Now >= x.StartDate) && (DateTime.Now <= x.EndDate)).Count() != 0); });
    173185    }
    174186  }
Note: See TracChangeset for help on using the changeset viewer.