Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6452


Ignore:
Timestamp:
06/20/11 14:16:53 (13 years ago)
Author:
cneumuel
Message:

#1233

  • renamed UptimeCalendar and Appointment to Downtime
  • added service methods to delete plugins and get plugin by hash
  • made reverted TransactionManager change, made it non-static and added interface
  • moved magic numbers to application settings
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
7 added
6 deleted
33 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Administration/3.4/Views/ResourcesView.cs

    r6451 r6452  
    277277        ServiceLocator.Instance.CallHiveService(service => {
    278278          var appointments = service.GetScheduleForResource(resourceId);
    279           ItemList<Appointment> ias = new ItemList<Appointment>();
     279          ItemList<Downtime> ias = new ItemList<Downtime>();
    280280          appointments.ForEach(a => ias.Add(a));
    281281          scheduleView.Invoke(new Action(() => scheduleView.Content = ias));
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Administration/3.4/Views/ScheduleView.cs

    r6451 r6452  
    3333namespace HeuristicLab.Clients.Hive.Administration.Views {
    3434  [View("ScheduleView")]
    35   [Content(typeof(IItemList<Appointment>), IsDefaultView = true)]
     35  [Content(typeof(IItemList<Downtime>), IsDefaultView = true)]
    3636  public partial class ScheduleView : ItemView {
    37     public new IItemList<Appointment> Content {
    38       get { return (IItemList<Appointment>)base.Content; }
     37    public new IItemList<Downtime> Content {
     38      get { return (IItemList<Downtime>)base.Content; }
    3939      set { base.Content = value; }
    4040    }
     
    9393    private void UpdateCalendarFromContent() {
    9494      offlineTimes.Clear();
    95       foreach (Appointment app in Content) {
     95      foreach (Downtime app in Content) {
    9696        offlineTimes.Add(new HiveAppointment {
    9797          AllDayEvent = app.AllDayEvent,
     
    331331
    332332    private void btnSaveCal_Click(object sender, EventArgs e) {
    333       List<Appointment> appointments = new List<Appointment>();
     333      List<Downtime> appointments = new List<Downtime>();
    334334      foreach (HiveAppointment app in offlineTimes) {
    335335        if (app.Deleted) {
     
    340340          });
    341341        } else if (app.Changed) {
    342           Appointment apdto = new Appointment {
     342          Downtime apdto = new Downtime {
    343343            AllDayEvent = app.AllDayEvent,
    344344            EndDate = app.EndDate,
     
    355355        //TODO: find a sane way to do this
    356356        ServiceLocator.Instance.CallHiveService(service => {
    357           foreach (Appointment app in appointments) {
     357          foreach (Downtime app in appointments) {
    358358            service.AddAppointment(app);
    359359          }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/WcfService.cs

    r6426 r6452  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Common;
    25 using HeuristicLab.Hive;
    26 using HeuristicLab.PluginInfrastructure;
    2725
    2826namespace HeuristicLab.Clients.Hive.SlaveCore {
     
    6260    public void UpdateJob(Job job) {
    6361      CallHiveService(s => s.UpdateJob(job));
    64     }
    65 
    66     public Guid AddChildJob(Guid parentJobId, Job job, IJob jobDataObject) {
    67       return CallHiveService(s => {
    68         JobData jobData = new JobData();
    69         IEnumerable<Type> types;
    70         jobData.Data = PersistenceUtil.Serialize(jobDataObject, out types);
    71         var plugins = new List<IPluginDescription>();
    72         PluginUtil.CollectDeclaringPlugins(plugins, types);
    73         job.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, new List<Plugin>(), new List<Plugin>(), plugins);
    74         return s.AddChildJob(parentJobId, job, jobData);
    75       });
    76     }
    77 
    78     public IEnumerable<JobData> GetChildJobs(Guid? parentJobId) {
    79       return CallHiveService(service => {
    80         IEnumerable<LightweightJob> msg = service.GetLightweightChildJobs(parentJobId, false, false);
    81 
    82         List<JobData> jobs = new List<JobData>();
    83         foreach (LightweightJob ljob in msg)
    84           jobs.Add(service.GetJobData(ljob.Id));
    85 
    86         return jobs;
    87       });
    88     }
    89 
    90     public void DeleteChildJobs(Guid jobId) {
    91       CallHiveService(s => s.DeleteChildJobs(jobId));
    9262    }
    9363    #endregion
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Tests/ExperimentManagerTests.cs

    r6433 r6452  
    4747      rhc.HiveExperiment.HiveJobs.Add(new OptimizerHiveJob(optimizer));
    4848     
    49       HiveClient.StartExperiment((Exception ex) => TestContext.WriteLine(ex.ToString()), rhc);
     49      HiveClient.StartExperiment((Exception ex) => TestContext.WriteLine(ex.ToString()), rhc, new CancellationToken());
    5050
    5151      while (rhc.HiveExperiment.ExecutionState != Core.ExecutionState.Stopped) {
    5252        Thread.Sleep(500);
    5353      }
    54 
    5554    }
    5655
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Tests/HeuristicLab.Clients.Hive.Tests-3.4.csproj

    r6433 r6452  
    363363    </ProjectReference>
    364364  </ItemGroup>
    365   <ItemGroup>
    366     <None Include="app.config" />
    367   </ItemGroup>
    368365  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
    369366  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Tests/Mocks/MockServiceLocator.cs

    r5599 r6452  
    33
    44namespace HeuristicLab.Clients.Hive.Tests {
    5   public class MockServiceLocator {
     5  public class MockServiceLocator : IServiceLocator {
    66    private string username;
    77    public string Username {
     
    2828      return call(GetService());
    2929    }
     30
     31    #region IServiceLocator Members
     32
     33    public void CallHiveService(Action<IHiveService> call) {
     34      // how to do this?
     35    }
     36
     37    public T CallHiveService<T>(Func<IHiveService, T> call) {
     38      // how to do this?
     39      throw new NotImplementedException();
     40    }
     41
     42    #endregion
    3043  }
    3144}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HeuristicLab.Clients.Hive-3.4.csproj

    r6431 r6452  
    120120    <None Include="app_services.config" />
    121121    <None Include="app.config" />
    122     <None Include="ClassDiagram2.cd" />
     122    <None Include="ClassDiagram.cd" />
    123123    <None Include="HeuristicLabClientsHivePlugin.cs.frame" />
    124124    <Compile Include="Exceptions\AddJobToHiveException.cs" />
     
    151151    <Compile Include="Exceptions\ServiceClientFactoryException.cs" />
    152152    <Compile Include="ScopeExtensions.cs" />
    153     <Compile Include="ServiceClients\Appointment.cs" />
     153    <Compile Include="ServiceClients\Downtime.cs" />
    154154    <Compile Include="ServiceClients\HiveItemCollection.cs" />
    155155    <Compile Include="ServiceClients\IHiveItem.cs" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HiveClient.cs

    r6444 r6452  
    192192    private Semaphore jobUploadSemaphore = new Semaphore(4, 4); // todo: take magic number into config
    193193    private static object jobCountLocker = new object();
     194    private static object pluginLocker = new object();
    194195    private void UploadExperiment(RefreshableHiveExperiment refreshableHiveExperiment, CancellationToken cancellationToken) {
    195196      try {
     
    285286          jobCount[0]++;
    286287        }
    287         JobData jobData = null;
    288         List<IPluginDescription> plugins = null;
    289 
    290         TryAndRepeat(() => { // workaround for persistence bug (thread-safe access to bitmaps) - remove later
    291           if (hiveJob.ItemJob.ComputeInParallel && (hiveJob.ItemJob.Item is Optimization.Experiment || hiveJob.ItemJob.Item is Optimization.BatchRun)) {
    292             hiveJob.Job.IsParentJob = true;
    293             hiveJob.Job.FinishWhenChildJobsFinished = true;
    294             jobData = hiveJob.GetAsJobData(true, out plugins);
    295           } else {
    296             hiveJob.Job.IsParentJob = false;
    297             hiveJob.Job.FinishWhenChildJobsFinished = false;
    298             jobData = hiveJob.GetAsJobData(false, out plugins);
    299           }
    300         }, 30, "Could not serialize job");
     288        JobData jobData;
     289        List<IPluginDescription> plugins;
     290
     291        if (hiveJob.ItemJob.ComputeInParallel && (hiveJob.ItemJob.Item is Optimization.Experiment || hiveJob.ItemJob.Item is Optimization.BatchRun)) {
     292          hiveJob.Job.IsParentJob = true;
     293          hiveJob.Job.FinishWhenChildJobsFinished = true;
     294          jobData = hiveJob.GetAsJobData(true, out plugins);
     295        } else {
     296          hiveJob.Job.IsParentJob = false;
     297          hiveJob.Job.FinishWhenChildJobsFinished = false;
     298          jobData = hiveJob.GetAsJobData(false, out plugins);
     299        }
    301300        cancellationToken.ThrowIfCancellationRequested();
    302301
    303302        TryAndRepeat(() => {
    304303          if (!cancellationToken.IsCancellationRequested) {
    305             ServiceLocator.Instance.CallHiveService((s) => hiveJob.Job.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins));
     304            lock (pluginLocker) {
     305              ServiceLocator.Instance.CallHiveService((s) => hiveJob.Job.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins));
     306            }
    306307          }
    307308        }, -1, "Failed to upload plugins");
     
    333334            var arguments = (Tuple<HiveJob, HiveJob>)tuple;
    334335            UploadJobWithChildren(progress, arguments.Item1, arguments.Item2, groups, jobCount, totalJobCount, configPluginId, hiveExperimentId, log, isPrivileged, cancellationToken);
    335           }, new Tuple<HiveJob, HiveJob>(child, hiveJob ))
     336          }, new Tuple<HiveJob, HiveJob>(child, hiveJob))
    336337          .ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted));
    337338        }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveServiceClient.cs

    r6426 r6452  
    8282  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.StateLog))]
    8383  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Job))]
    84   [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Appointment))]
     84  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Downtime))]
    8585  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.PluginData))]
    8686  public partial class HiveItem : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
     
    938938      "nsfer")]
    939939  [System.SerializableAttribute()]
    940   public partial class Appointment : HeuristicLab.Clients.Hive.HiveItem {
     940  public partial class Downtime : HeuristicLab.Clients.Hive.HiveItem {
    941941
    942942    [System.Runtime.Serialization.OptionalFieldAttribute()]
     
    15061506
    15071507    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AddAppointment", ReplyAction = "http://tempuri.org/IHiveService/AddAppointmentResponse")]
    1508     System.Guid AddAppointment(HeuristicLab.Clients.Hive.Appointment appointment);
     1508    System.Guid AddAppointment(HeuristicLab.Clients.Hive.Downtime appointment);
    15091509
    15101510    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/DeleteAppointment", ReplyAction = "http://tempuri.org/IHiveService/DeleteAppointmentResponse")]
     
    15121512
    15131513    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/UpdateAppointment", ReplyAction = "http://tempuri.org/IHiveService/UpdateAppointmentResponse")]
    1514     void UpdateAppointment(HeuristicLab.Clients.Hive.Appointment appointment);
     1514    void UpdateAppointment(HeuristicLab.Clients.Hive.Downtime appointment);
    15151515
    15161516    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetScheduleForResource", ReplyAction = "http://tempuri.org/IHiveService/GetScheduleForResourceResponse")]
    1517     System.Collections.Generic.List<HeuristicLab.Clients.Hive.Appointment> GetScheduleForResource(System.Guid resourceId);
     1517    System.Collections.Generic.List<HeuristicLab.Clients.Hive.Downtime> GetScheduleForResource(System.Guid resourceId);
    15181518
    15191519    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AddJob", ReplyAction = "http://tempuri.org/IHiveService/AddJobResponse")]
     
    16941694    }
    16951695
    1696     public System.Guid AddAppointment(HeuristicLab.Clients.Hive.Appointment appointment) {
     1696    public System.Guid AddAppointment(HeuristicLab.Clients.Hive.Downtime appointment) {
    16971697      return base.Channel.AddAppointment(appointment);
    16981698    }
     
    17021702    }
    17031703
    1704     public void UpdateAppointment(HeuristicLab.Clients.Hive.Appointment appointment) {
     1704    public void UpdateAppointment(HeuristicLab.Clients.Hive.Downtime appointment) {
    17051705      base.Channel.UpdateAppointment(appointment);
    17061706    }
    17071707
    1708     public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Appointment> GetScheduleForResource(System.Guid resourceId) {
     1708    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Downtime> GetScheduleForResource(System.Guid resourceId) {
    17091709      return base.Channel.GetScheduleForResource(resourceId);
    17101710    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/Util/PluginUtil.cs

    r6444 r6452  
    3030namespace HeuristicLab.Clients.Hive {
    3131  public static class PluginUtil {
    32     private static object locker = new object();
    3332
    3433    /// <summary>
     
    4140    /// <returns></returns>
    4241    public static List<Guid> GetPluginDependencies(IHiveService service, List<Plugin> onlinePlugins, List<Plugin> alreadyUploadedPlugins, IEnumerable<IPluginDescription> neededPlugins) {
    43       lock (locker) {
    44         var pluginIds = new List<Guid>();
    45         Dictionary<IPluginDescription, byte[]> checksumsNeededPlugins = CalcChecksumsForPlugins(neededPlugins);
     42      var pluginIds = new List<Guid>();
     43      Dictionary<IPluginDescription, byte[]> checksumsNeededPlugins = CalcChecksumsForPlugins(neededPlugins);
    4644
    47         foreach (var neededPlugin in checksumsNeededPlugins) {
    48           Plugin foundPlugin = alreadyUploadedPlugins.FirstOrDefault(p => p.Hash.SequenceEqual(neededPlugin.Value));
     45      foreach (var neededPlugin in checksumsNeededPlugins) {
     46        Plugin foundPlugin = alreadyUploadedPlugins.FirstOrDefault(p => p.Hash.SequenceEqual(neededPlugin.Value));
     47        if (foundPlugin == null) {
     48          foundPlugin = onlinePlugins.FirstOrDefault(p => {
     49            if (p.Hash != null) {
     50              return p.Hash.SequenceEqual(neededPlugin.Value);
     51            } else {
     52              return false;
     53            }
     54          });
     55
    4956          if (foundPlugin == null) {
    50             foundPlugin = onlinePlugins.FirstOrDefault(p => {
    51               if (p.Hash != null) {
    52                 return p.Hash.SequenceEqual(neededPlugin.Value);
    53               } else {
    54                 return false;
    55               }
    56             });
    57 
    58             if (foundPlugin == null) {
    59               Plugin p = CreatePlugin(neededPlugin.Key, neededPlugin.Value);
    60               List<PluginData> pd = CreatePluginDatas(neededPlugin.Key);
    61               try {
    62                 p.Id = service.AddPlugin(p, pd);
    63                 alreadyUploadedPlugins.Add(p);
    64                 pluginIds.Add(p.Id);
    65               }
    66               catch (FaultException<PluginAlreadyExistsFault> fault) {
    67                 onlinePlugins.Add(service.GetPlugin(fault.Detail.Id));
    68               }
    69             } else {
    70               pluginIds.Add(foundPlugin.Id);
     57            Plugin p = CreatePlugin(neededPlugin.Key, neededPlugin.Value);
     58            List<PluginData> pd = CreatePluginDatas(neededPlugin.Key);
     59            try {
     60              p.Id = service.AddPlugin(p, pd);
     61              alreadyUploadedPlugins.Add(p);
     62              pluginIds.Add(p.Id);
     63            }
     64            catch (FaultException<PluginAlreadyExistsFault> fault) {
     65              onlinePlugins.Add(service.GetPlugin(fault.Detail.Id));
    7166            }
    7267          } else {
    7368            pluginIds.Add(foundPlugin.Id);
    7469          }
     70        } else {
     71          pluginIds.Add(foundPlugin.Id);
    7572        }
    76         return pluginIds;
    7773      }
     74      return pluginIds;
    7875    }
    7976
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HiveEngine.cs

    r6444 r6452  
    9494    #region constructors and cloning
    9595    public HiveEngine() {
    96       ResourceNames = "HEAL";
    97       Priority = 0;
     96      this.ResourceNames = "HEAL";
     97      this.Priority = 0;
    9898      this.log = new ThreadSafeLog(this.log);
    9999    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/HeuristicLab.Services.Hive.Common-3.4.csproj

    r6369 r6452  
    9494  </ItemGroup>
    9595  <ItemGroup>
    96     <Compile Include="ApplicationConstants.cs" />
    9796    <Compile Include="DataTransfer\SlaveStatistics.cs" />
    9897    <Compile Include="DataTransfer\Statistics.cs" />
    9998    <Compile Include="DataTransfer\UserStatistics.cs" />
     99    <Compile Include="ITransactionManager.cs" />
    100100    <Compile Include="ServiceFaults\PluginAlreadyExistsFault.cs" />
     101    <Compile Include="Settings.Designer.cs">
     102      <AutoGen>True</AutoGen>
     103      <DesignTimeSharedInput>True</DesignTimeSharedInput>
     104      <DependentUpon>Settings.settings</DependentUpon>
     105    </Compile>
     106    <None Include="app.config" />
    101107    <None Include="HeuristicLabServicesHiveCommonPlugin.cs.frame" />
    102     <Compile Include="DataTransfer\Appointment.cs" />
     108    <Compile Include="DataTransfer\Downtime.cs" />
    103109    <Compile Include="DataTransfer\Command.cs" />
    104110    <Compile Include="DataTransfer\HiveExperimentPermission.cs" />
     
    125131    <None Include="Properties\AssemblyInfo.cs.frame" />
    126132    <Compile Include="ServiceContracts\IHiveService.cs" />
     133    <None Include="Settings.settings">
     134      <Generator>PublicSettingsSingleFileGenerator</Generator>
     135      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
     136    </None>
    127137  </ItemGroup>
    128138  <ItemGroup>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/ServiceContracts/IHiveService.cs

    r6431 r6452  
    127127    Plugin GetPlugin(Guid pluginId);
    128128    [OperationContract]
     129    Plugin GetPluginByHash(byte[] hash);
     130    [OperationContract]
    129131    [FaultContract(typeof(PluginAlreadyExistsFault))]
    130132    Guid AddPlugin(Plugin plugin, List<PluginData> pluginData);
     
    133135    [OperationContract]
    134136    IEnumerable<PluginData> GetPluginDatas(List<Guid> pluginIds);
     137    [OperationContract]
     138    void DeletePlugin(Guid pluginId);
    135139    #endregion
    136140
     
    182186    #endregion
    183187
    184     #region Appointment Methods
    185     [OperationContract]
    186     Guid AddAppointment(Appointment appointment);
    187 
    188     [OperationContract]
    189     void DeleteAppointment(Guid appointmentId);
    190 
    191     [OperationContract]
    192     void UpdateAppointment(Appointment appointment);
    193 
    194     [OperationContract]
    195     IEnumerable<Appointment> GetScheduleForResource(Guid resourceId);
     188    #region Downtime Methods
     189    [OperationContract]
     190    Guid AddDowntime(Downtime downtime);
     191
     192    [OperationContract]
     193    void DeleteDowntime(Guid downtimeId);
     194
     195    [OperationContract]
     196    void UpdateDowntime(Downtime downtime);
     197
     198    [OperationContract]
     199    IEnumerable<Downtime> GetDowntimesForResource(Guid resourceId);
    196200    #endregion
    197201  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Convert.cs

    r6426 r6452  
    113113    #endregion
    114114
    115     #region Appointment
    116     public static DT.Appointment ToDto(UptimeCalendar source) {
    117       if (source == null) return null;
    118       return new DT.Appointment { Id = source.UptimeCalendarId, AllDayEvent = source.AllDayEvent, EndDate = source.EndDate, Recurring = source.Recurring, RecurringId = source.RecurringId, ResourceId = source.ResourceId, StartDate = source.StartDate };
    119     }
    120     public static UptimeCalendar ToEntity(DT.Appointment source) {
    121       if (source == null) return null;
    122       var entity = new UptimeCalendar(); ToEntity(source, entity);
    123       return entity;
    124     }
    125     public static void ToEntity(DT.Appointment source, UptimeCalendar target) {
    126       if ((source != null) && (target != null)) {
    127         target.UptimeCalendarId = source.Id; target.AllDayEvent = source.AllDayEvent; target.EndDate = source.EndDate; target.Recurring = source.Recurring; target.RecurringId = source.RecurringId; target.ResourceId = source.ResourceId; target.StartDate = source.StartDate;
     115    #region Downtimes
     116    public static DT.Downtime ToDto(Downtime source) {
     117      if (source == null) return null;
     118      return new DT.Downtime { Id = source.DowntimeId, AllDayEvent = source.AllDayEvent, EndDate = source.EndDate, Recurring = source.Recurring, RecurringId = source.RecurringId, ResourceId = source.ResourceId, StartDate = source.StartDate };
     119    }
     120    public static Downtime ToEntity(DT.Downtime source) {
     121      if (source == null) return null;
     122      var entity = new Downtime(); ToEntity(source, entity);
     123      return entity;
     124    }
     125    public static void ToEntity(DT.Downtime source, Downtime target) {
     126      if ((source != null) && (target != null)) {
     127        target.DowntimeId = source.Id; target.AllDayEvent = source.AllDayEvent; target.EndDate = source.EndDate; target.Recurring = source.Recurring; target.RecurringId = source.RecurringId; target.ResourceId = source.ResourceId; target.StartDate = source.StartDate;
    128128      }
    129129    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HeuristicLab.Services.Hive.DataAccess-3.4.csproj

    r6431 r6452  
    109109    <Compile Include="Properties\AssemblyInfo.cs" />
    110110    <None Include="Properties\AssemblyInfo.cs.frame" />
    111     <Compile Include="Properties\Settings.Designer.cs">
     111    <Compile Include="Settings.Designer.cs">
    112112      <AutoGen>True</AutoGen>
    113113      <DesignTimeSharedInput>True</DesignTimeSharedInput>
     
    130130      <SubType>Designer</SubType>
    131131    </None>
    132     <None Include="Properties\Settings.settings">
     132    <None Include="Settings.settings">
    133133      <Generator>SettingsSingleFileGenerator</Generator>
    134134      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs

    r6431 r6452  
    2424using System.Linq;
    2525using System.Linq.Expressions;
    26 using HeuristicLab.Services.Hive.Common;
    2726using HeuristicLab.Services.Hive.Common.DataTransfer;
    28 using HeuristicLab.Services.Hive.DataAccess.Properties;
    2927using DT = HeuristicLab.Services.Hive.Common.DataTransfer;
    3028
     
    3331    public static HiveDataContext CreateContext(bool longRunning = false) {
    3432      var context = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString);
    35       if (longRunning) context.CommandTimeout = (int)ApplicationConstants.LongRunningDatabaseCommandTimeout.TotalSeconds;     
     33      if (longRunning) context.CommandTimeout = (int)Settings.Default.LongRunningDatabaseCommandTimeout.TotalSeconds;     
    3634      return context;
    3735    }
     
    109107                           where child.ParentJobId == ar.Job.JobId
    110108                           select child).Count() > 0
    111                     orderby ar.Job.Priority, db.Random() descending
     109                    orderby ar.Job.Priority descending, db.Random()
    112110                    select Convert.ToDto(ar.Job);
    113111        return count == 0 ? query.ToArray() : query.Take(count).ToArray();
     
    127125                       && ar.Job.CoresNeeded <= slave.FreeCores
    128126                       && ar.Job.MemoryNeeded <= slave.FreeMemory
    129                     orderby ar.Job.Priority, db.Random() descending // take random job to avoid the race condition that occurs when this method is called concurrently (the same job would be returned)
     127                    orderby ar.Job.Priority descending, db.Random() // take random job to avoid the race condition that occurs when this method is called concurrently (the same job would be returned)
    130128                    select Convert.ToDto(ar.Job);
    131129        var waitingJobs = (count == 0 ? query : query.Take(count)).ToArray();
     
    634632    #endregion
    635633
    636     #region Appointment Methods
    637     public Appointment GetAppointment(Guid id) {
    638       using (var db = CreateContext()) {
    639         return Convert.ToDto(db.UptimeCalendars.SingleOrDefault(x => x.UptimeCalendarId == id));
    640       }
    641     }
    642 
    643     public IEnumerable<Appointment> GetAppointments(Expression<Func<UptimeCalendar, bool>> predicate) {
    644       using (var db = CreateContext()) {
    645         return db.UptimeCalendars.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
    646       }
    647     }
    648 
    649     public Guid AddAppointment(Appointment dto) {
    650       using (var db = CreateContext()) {
    651         var entity = Convert.ToEntity(dto);
    652         db.UptimeCalendars.InsertOnSubmit(entity);
    653         db.SubmitChanges();
    654         return entity.UptimeCalendarId;
    655       }
    656     }
    657 
    658     public void UpdateAppointment(Appointment dto) {
    659       using (var db = CreateContext()) {
    660         var entity = db.UptimeCalendars.FirstOrDefault(x => x.UptimeCalendarId == dto.Id);
    661         if (entity == null) db.UptimeCalendars.InsertOnSubmit(Convert.ToEntity(dto));
    662         else Convert.ToEntity(dto, entity);
    663         db.SubmitChanges();
    664       }
    665     }
    666 
    667     public void DeleteAppointment(Guid id) {
    668       using (var db = CreateContext()) {
    669         var entity = db.UptimeCalendars.FirstOrDefault(x => x.UptimeCalendarId == id);
    670         if (entity != null) db.UptimeCalendars.DeleteOnSubmit(entity);
     634    #region Downtime Methods
     635    public DT.Downtime GetDowntime(Guid id) {
     636      using (var db = CreateContext()) {
     637        return Convert.ToDto(db.Downtimes.SingleOrDefault(x => x.DowntimeId == id));
     638      }
     639    }
     640
     641    public IEnumerable<DT.Downtime> GetDowntimes(Expression<Func<Downtime, bool>> predicate) {
     642      using (var db = CreateContext()) {
     643        return db.Downtimes.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     644      }
     645    }
     646
     647    public Guid AddDowntime(DT.Downtime dto) {
     648      using (var db = CreateContext()) {
     649        var entity = Convert.ToEntity(dto);
     650        db.Downtimes.InsertOnSubmit(entity);
     651        db.SubmitChanges();
     652        return entity.DowntimeId;
     653      }
     654    }
     655
     656    public void UpdateDowntime(DT.Downtime dto) {
     657      using (var db = CreateContext()) {
     658        var entity = db.Downtimes.FirstOrDefault(x => x.DowntimeId == dto.Id);
     659        if (entity == null) db.Downtimes.InsertOnSubmit(Convert.ToEntity(dto));
     660        else Convert.ToEntity(dto, entity);
     661        db.SubmitChanges();
     662      }
     663    }
     664
     665    public void DeleteDowntime(Guid id) {
     666      using (var db = CreateContext()) {
     667        var entity = db.Downtimes.FirstOrDefault(x => x.DowntimeId == id);
     668        if (entity != null) db.Downtimes.DeleteOnSubmit(entity);
    671669        db.SubmitChanges();
    672670      }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.dbml

    r6431 r6452  
    11<?xml version="1.0" encoding="utf-8"?><Database Name="HeuristicLab.Hive" Class="HiveDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
     2  <Connection Mode="AppSettings" ConnectionString="Data Source=localhost;Initial Catalog=HeuristicLab.Hive-3.4;Integrated Security=True" SettingsObjectName="HeuristicLab.Services.Hive.DataAccess.Properties.Settings" SettingsPropertyName="HeuristicLab_Hive_LinqConnectionString" Provider="System.Data.SqlClient" />
    23  <Table Name="dbo.AssignedResources" Member="AssignedResources">
    34    <Type Name="AssignedResource">
     
    3839      <Association Name="Resource_AssignedResource" Member="AssignedResources" ThisKey="ResourceId" OtherKey="ResourceId" Type="AssignedResource" />
    3940      <Association Name="Resource_Resource" Member="ChildResources" ThisKey="ResourceId" OtherKey="ParentResourceId" Type="Resource" />
    40       <Association Name="Resource_UptimeCalendar" Member="UptimeCalendars" ThisKey="ResourceId" OtherKey="ResourceId" Type="UptimeCalendar" />
     41      <Association Name="Resource_Downtime" Member="Downtimes" Storage="_UptimeCalendars" ThisKey="ResourceId" OtherKey="ResourceId" Type="Downtime" />
    4142      <Association Name="Resource_StateLog" Member="StateLogs" ThisKey="ResourceId" OtherKey="SlaveId" Type="StateLog" />
    4243      <Association Name="Resource_Resource" Member="ParentResource" ThisKey="ParentResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" />
     
    8283    </Type>
    8384  </Table>
    84   <Table Name="dbo.UptimeCalendar" Member="UptimeCalendars">
    85     <Type Name="UptimeCalendar">
    86       <Column Name="UptimeCalendarId" Type="System.Guid" DbType="UniqueIdentifier" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
     85  <Table Name="dbo.Downtime" Member="Downtimes">
     86    <Type Name="Downtime">
     87      <Column Name="DowntimeId" Storage="_UptimeCalendarId" Type="System.Guid" DbType="UniqueIdentifier" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
    8788      <Column Name="ResourceId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="false" />
    8889      <Column Name="StartDate" Type="System.DateTime" DbType="DateTime" CanBeNull="false" />
     
    9192      <Column Name="Recurring" Type="System.Boolean" DbType="Bit" CanBeNull="false" />
    9293      <Column Name="RecurringId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="false" />
    93       <Association Name="Resource_UptimeCalendar" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" DeleteRule="CASCADE" />
     94      <Association Name="Resource_Downtime" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" DeleteRule="CASCADE" />
    9495    </Type>
    9596  </Table>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.dbml.layout

    r6431 r6452  
    3434    </classShape>
    3535    <classShape Id="8d5712f7-7a1a-4a89-bd4d-fd60200d3306" absoluteBounds="13.5, 2.5, 2, 2.1554996744791666">
    36       <DataClassMoniker Name="/HiveDataContext/UptimeCalendar" />
     36      <DataClassMoniker Name="/HiveDataContext/Downtime" />
    3737      <nestedChildShapes>
    3838        <elementListCompartment Id="7d8f121b-35bb-4753-a25f-3fac1562e68e" absoluteBounds="13.515, 2.9600000000000009, 1.9700000000000002, 1.5954996744791665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     
    6969      </nodes>
    7070    </inheritanceConnector>
    71     <associationConnector edgePoints="[(11.9843735 : 2.57859537760417); (11.9843735 : 4.69314697265625); (10.875 : 4.69314697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     71    <associationConnector edgePoints="[(12.25 : 2.57859537760417); (12.25 : 4.69314697265625); (10.875 : 4.69314697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    7272      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_AssignedResource" />
    7373      <nodes>
     
    9797      </nodes>
    9898    </associationConnector>
    99     <associationConnector edgePoints="[(12.781252 : 2.57859537760417); (12.781252 : 3.54212367513021); (13.5 : 3.54212367513021)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    100       <AssociationMoniker Name="/HiveDataContext/Resource/Resource_UptimeCalendar" />
    101       <nodes>
    102         <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" />
    103         <classShapeMoniker Id="8d5712f7-7a1a-4a89-bd4d-fd60200d3306" />
    104       </nodes>
    105     </associationConnector>
    10699    <classShape Id="6bc13f26-f9a8-4597-b054-35be34190d12" absoluteBounds="4.125, 1, 2, 1.3862939453125">
    107100      <DataClassMoniker Name="/HiveDataContext/JobData" />
     
    228221      </nodes>
    229222    </associationConnector>
     223    <associationConnector edgePoints="[(12.781252 : 2.57859537760417); (12.781252 : 3.64829952604167); (13.5 : 3.64829952604167)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     224      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_Downtime" />
     225      <nodes>
     226        <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" />
     227        <classShapeMoniker Id="8d5712f7-7a1a-4a89-bd4d-fd60200d3306" />
     228      </nodes>
     229    </associationConnector>
    230230  </nestedChildShapes>
    231231</ordesignerObjectsDiagram>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.designer.cs

    r6431 r6452  
    1212namespace HeuristicLab.Services.Hive.DataAccess
    1313{
    14   using System.Data.Linq;
    15   using System.Data.Linq.Mapping;
    16   using System.Data;
    17   using System.Collections.Generic;
    18   using System.Reflection;
    19   using System.Linq;
    20   using System.Linq.Expressions;
    21   using System.ComponentModel;
    22   using System;
     14  using System;
     15  using System.ComponentModel;
     16  using System.Data.Linq;
     17  using System.Data.Linq.Mapping;
    2318 
    2419 
     
    4641    partial void UpdateJob(Job instance);
    4742    partial void DeleteJob(Job instance);
    48     partial void InsertUptimeCalendar(UptimeCalendar instance);
    49     partial void UpdateUptimeCalendar(UptimeCalendar instance);
    50     partial void DeleteUptimeCalendar(UptimeCalendar instance);
     43    partial void InsertDowntime(Downtime instance);
     44    partial void UpdateDowntime(Downtime instance);
     45    partial void DeleteDowntime(Downtime instance);
    5146    partial void InsertHiveExperiment(HiveExperiment instance);
    5247    partial void UpdateHiveExperiment(HiveExperiment instance);
     
    8176    #endregion
    8277   
     78    public HiveDataContext() :
     79        base(global::HeuristicLab.Services.Hive.DataAccess.Settings.Default.HeuristicLab_Hive_LinqConnectionString, mappingSource)
     80    {
     81      OnCreated();
     82    }
     83   
    8384    public HiveDataContext(string connection) :
    8485        base(connection, mappingSource)
     
    145146    }
    146147   
    147     public System.Data.Linq.Table<UptimeCalendar> UptimeCalendars
    148     {
    149       get
    150       {
    151         return this.GetTable<UptimeCalendar>();
     148    public System.Data.Linq.Table<Downtime> Downtimes
     149    {
     150      get
     151      {
     152        return this.GetTable<Downtime>();
    152153      }
    153154    }
     
    877878    private EntitySet<Resource> _ChildResources;
    878879   
    879     private EntitySet<UptimeCalendar> _UptimeCalendars;
     880    private EntitySet<Downtime> _UptimeCalendars;
    880881   
    881882    private EntitySet<StateLog> _StateLogs;
     
    901902      this._AssignedResources = new EntitySet<AssignedResource>(new Action<AssignedResource>(this.attach_AssignedResources), new Action<AssignedResource>(this.detach_AssignedResources));
    902903      this._ChildResources = new EntitySet<Resource>(new Action<Resource>(this.attach_ChildResources), new Action<Resource>(this.detach_ChildResources));
    903       this._UptimeCalendars = new EntitySet<UptimeCalendar>(new Action<UptimeCalendar>(this.attach_UptimeCalendars), new Action<UptimeCalendar>(this.detach_UptimeCalendars));
     904      this._UptimeCalendars = new EntitySet<Downtime>(new Action<Downtime>(this.attach_UptimeCalendars), new Action<Downtime>(this.detach_UptimeCalendars));
    904905      this._StateLogs = new EntitySet<StateLog>(new Action<StateLog>(this.attach_StateLogs), new Action<StateLog>(this.detach_StateLogs));
    905906      this._ParentResource = default(EntityRef<Resource>);
     
    10171018    }
    10181019   
    1019     [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_UptimeCalendar", Storage="_UptimeCalendars", ThisKey="ResourceId", OtherKey="ResourceId")]
    1020     public EntitySet<UptimeCalendar> UptimeCalendars
     1020    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_Downtime", Storage="_UptimeCalendars", ThisKey="ResourceId", OtherKey="ResourceId")]
     1021    public EntitySet<Downtime> Downtimes
    10211022    {
    10221023      get
     
    11211122    }
    11221123   
    1123     private void attach_UptimeCalendars(UptimeCalendar entity)
     1124    private void attach_UptimeCalendars(Downtime entity)
    11241125    {
    11251126      this.SendPropertyChanging();
     
    11271128    }
    11281129   
    1129     private void detach_UptimeCalendars(UptimeCalendar entity)
     1130    private void detach_UptimeCalendars(Downtime entity)
    11301131    {
    11311132      this.SendPropertyChanging();
     
    20402041  }
    20412042 
    2042   [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.UptimeCalendar")]
    2043   public partial class UptimeCalendar : INotifyPropertyChanging, INotifyPropertyChanged
     2043  [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Downtime")]
     2044  public partial class Downtime : INotifyPropertyChanging, INotifyPropertyChanged
    20442045  {
    20452046   
     
    20662067    partial void OnValidate(System.Data.Linq.ChangeAction action);
    20672068    partial void OnCreated();
    2068     partial void OnUptimeCalendarIdChanging(System.Guid value);
    2069     partial void OnUptimeCalendarIdChanged();
     2069    partial void OnDowntimeIdChanging(System.Guid value);
     2070    partial void OnDowntimeIdChanged();
    20702071    partial void OnResourceIdChanging(System.Guid value);
    20712072    partial void OnResourceIdChanged();
     
    20822083    #endregion
    20832084   
    2084     public UptimeCalendar()
     2085    public Downtime()
    20852086    {
    20862087      this._Resource = default(EntityRef<Resource>);
     
    20892090   
    20902091    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UptimeCalendarId", AutoSync=AutoSync.OnInsert, DbType="UniqueIdentifier", IsPrimaryKey=true, IsDbGenerated=true)]
    2091     public System.Guid UptimeCalendarId
     2092    public System.Guid DowntimeId
    20922093    {
    20932094      get
     
    20992100        if ((this._UptimeCalendarId != value))
    21002101        {
    2101           this.OnUptimeCalendarIdChanging(value);
     2102          this.OnDowntimeIdChanging(value);
    21022103          this.SendPropertyChanging();
    21032104          this._UptimeCalendarId = value;
    2104           this.SendPropertyChanged("UptimeCalendarId");
    2105           this.OnUptimeCalendarIdChanged();
     2105          this.SendPropertyChanged("DowntimeId");
     2106          this.OnDowntimeIdChanged();
    21062107        }
    21072108      }
     
    22322233    }
    22332234   
    2234     [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_UptimeCalendar", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true, DeleteRule="CASCADE")]
     2235    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_Downtime", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true, DeleteRule="CASCADE")]
    22352236    public Resource Resource
    22362237    {
     
    22492250          {
    22502251            this._Resource.Entity = null;
    2251             previousValue.UptimeCalendars.Remove(this);
     2252            previousValue.Downtimes.Remove(this);
    22522253          }
    22532254          this._Resource.Entity = value;
    22542255          if ((value != null))
    22552256          {
    2256             value.UptimeCalendars.Add(this);
     2257            value.Downtimes.Add(this);
    22572258            this._ResourceId = value.ResourceId;
    22582259          }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Interfaces/IHiveDao.cs

    r6431 r6452  
    129129    #endregion
    130130
    131     #region Appointment Methods
    132     DT.Appointment GetAppointment(Guid id);
    133     IEnumerable<DT.Appointment> GetAppointments(Expression<Func<UptimeCalendar, bool>> predicate);
    134     Guid AddAppointment(DT.Appointment dto);
    135     void UpdateAppointment(DT.Appointment dto);
    136     void DeleteAppointment(Guid id);
     131    #region Downtime Methods
     132    DT.Downtime GetDowntime(Guid id);
     133    IEnumerable<DT.Downtime> GetDowntimes(Expression<Func<Downtime, bool>> predicate);
     134    Guid AddDowntime(DT.Downtime dto);
     135    void UpdateDowntime(DT.Downtime dto);
     136    void DeleteDowntime(Guid id);
    137137    #endregion
    138138
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Tools/Prepare Hive Database.sql

    r6431 r6452  
    7373ALTER TABLE dbo.Resource WITH NOCHECK ADD CONSTRAINT [DF_Resource_ResourceId] DEFAULT (NEWSEQUENTIALID()) FOR ResourceId;
    7474
    75 ALTER TABLE dbo.UptimeCalendar ALTER COLUMN UptimeCalendarId ADD ROWGUIDCOL;
    76 ALTER TABLE dbo.UptimeCalendar WITH NOCHECK ADD CONSTRAINT [DF_UptimeCalendar_UptimeCalendarId] DEFAULT (NEWSEQUENTIALID()) FOR UptimeCalendarId;
     75ALTER TABLE dbo.Downtime ALTER COLUMN DowntimeId ADD ROWGUIDCOL;
     76ALTER TABLE dbo.Downtime WITH NOCHECK ADD CONSTRAINT [DF_Downtime_DowntimeId] DEFAULT (NEWSEQUENTIALID()) FOR DowntimeId;
    7777
    7878ALTER TABLE dbo.HiveExperiment ALTER COLUMN HiveExperimentId ADD ROWGUIDCOL;
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/TransactionManager.cs

    r6444 r6452  
    2424using HeuristicLab.Services.Hive.Common;
    2525
    26 namespace HeuristicLab.Services.Hive.DataAccess {
    27   public static class TransactionManager {
    28     public static void UseTransaction(Action call, bool serializable = false, bool longRunning = false) {
     26namespace HeuristicLab.Services.Hive.DataAccess { 
     27  public class TransactionManager : ITransactionManager {   
     28    public void UseTransaction(Action call, bool serializable = false, bool longRunning = false) {
    2929      int n = 10;
    3030      while (n > 0) {
     
    4646    }
    4747
    48     public static T UseTransaction<T>(Func<T> call, bool serializable = false, bool longRunning = false) {
     48    public T UseTransaction<T>(Func<T> call, bool serializable = false, bool longRunning = false) {
    4949      int n = 10;
    5050      while (n > 0) {
     
    6868    }
    6969
    70     private static TransactionScope CreateTransaction(bool serializable, bool longRunning) {
     70    private TransactionScope CreateTransaction(bool serializable, bool longRunning) {
    7171      var options = new TransactionOptions();
    7272      if (serializable)
     
    7676
    7777      if (longRunning)
    78         options.Timeout = ApplicationConstants.LongRunningDatabaseCommandTimeout;
     78        options.Timeout = Settings.Default.LongRunningDatabaseCommandTimeout;
    7979
    8080      return new TransactionScope(TransactionScopeOption.Required, options);
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/app.config

    r5264 r6452  
    22<configuration>
    33  <configSections>
     4    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
     5      <section name="HeuristicLab.Services.Hive.DataAccess.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
     6    </sectionGroup>
    47  </configSections>
    58  <connectionStrings>
    6     <add name="HeuristicLab.Services.Hive.DataAccess.Properties.Settings.HeuristicLab_Hive_LinqConnectionString" connectionString="Data Source=localhost;Initial Catalog=HeuristicLab.Hive-3.4;Integrated Security=True;" providerName="System.Data.SqlClient"/>
     9    <add name="HeuristicLab.Services.Hive.DataAccess.Properties.Settings.HeuristicLab_Hive_LinqConnectionString"
     10      connectionString="Data Source=localhost;Initial Catalog=HeuristicLab.Hive-3.4;Integrated Security=True;"
     11      providerName="System.Data.SqlClient" />
    712  </connectionStrings>
    8 <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
     13<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup><applicationSettings>
     14    <HeuristicLab.Services.Hive.DataAccess.Settings>
     15      <setting name="LongRunningDatabaseCommandTimeout" serializeAs="String">
     16        <value>00:05:00</value>
     17      </setting>
     18    </HeuristicLab.Services.Hive.DataAccess.Settings>
     19  </applicationSettings>
     20</configuration>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/DaoTests.cs

    r6431 r6452  
    7070      plugin1.UserId = Guid.Empty;
    7171      plugin1.DateCreated = DateTime.Now;
     72      plugin1.Hash = new byte[] { 1, 2, 3 };
    7273
    7374      DT.PluginData pluginData1 = new DT.PluginData();
     
    135136      Assert.AreEqual(null, dao.GetJobData(job1.Id));
    136137      Assert.AreEqual(null, dao.GetHiveExperiment(he.Id));
     138
     139      dao.DeletePlugin(plugin1.Id);
     140      Assert.AreEqual(null, dao.GetPlugin(plugin1.Id));
    137141    }
    138142
     
    177181      plugin1.Version = new Version("1.0.0.0");
    178182      plugin1.UserId = Guid.Empty;
     183      plugin1.Hash = new byte[] { 1, 2, 3 };
    179184
    180185      plugin1.Id = dao.AddPlugin(plugin1);
     
    186191      Assert.AreEqual(plugin1.UserId, plugin1loaded.UserId);
    187192      Assert.AreEqual(plugin1.DateCreated.ToString(), plugin1loaded.DateCreated.ToString());
     193      Assert.IsTrue(plugin1.Hash.SequenceEqual(plugin1loaded.Hash));
    188194
    189195      DT.PluginData pluginData1 = new DT.PluginData();
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/Mocks/MockLifecycleManager.cs

    r6372 r6452  
    2020#endregion
    2121
    22 
    2322namespace HeuristicLab.Services.Hive.Tests.Mocks {
    2423  public class MockLifecycleManager : ILifecycleManager {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/Mocks/MockServiceLocator.cs

    r6431 r6452  
    4444
    4545    public ILifecycleManager LifecycleManager {
    46       get {
    47         return defaultServiceLocator.LifecycleManager;
    48       }
     46      get { return defaultServiceLocator.LifecycleManager; }
     47    }
     48    public ITransactionManager TransactionManager {
     49      get { return defaultServiceLocator.TransactionManager; }
    4950    }
    5051
    5152    public HeartbeatManager HeartbeatManager {
    52       get {
    53         return defaultServiceLocator.HeartbeatManager;
    54       }
     53      get { return defaultServiceLocator.HeartbeatManager; }
    5554    }
    56 
    5755  }
    5856}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/ServiceTests.cs

    r6431 r6452  
    6666      };
    6767
     68      // delete plugin first (otherwise the system would not allow it because of the same hash code
     69      var hash = new byte[] { 1, 2, 3 };
     70      var p = service.GetPluginByHash(hash);
     71      if (p != null) service.DeletePlugin(p.Id);
     72
    6873      // create plugin
    6974      DT.Plugin plugin1 = new DT.Plugin();
     
    7277      plugin1.UserId = Guid.Empty;
    7378      plugin1.DateCreated = DateTime.Now;
    74 
     79      plugin1.Hash = hash;
     80     
    7581      DT.PluginData pluginData1 = new DT.PluginData();
    7682      pluginData1.FileName = "Tests.MyPlugin-1.0.dll";
     
    167173      Assert.AreEqual(job.Id, actions[0].JobId);
    168174
    169       // create appointment which should make slave unavailable for calculation
    170       Guid appointmentId = service.AddAppointment(new Appointment { ResourceId = slave.Id, StartDate = DateTime.Now - TimeSpan.FromMinutes(1), EndDate = DateTime.Now + TimeSpan.FromMinutes(1), Recurring = false });
     175      // create downtime which should make slave unavailable for calculation
     176      Guid downtimeId = service.AddDowntime(new Downtime { ResourceId = slave.Id, StartDate = DateTime.Now - TimeSpan.FromMinutes(1), EndDate = DateTime.Now + TimeSpan.FromMinutes(1), Recurring = false });
    171177
    172178      progress.Clear();
     
    177183      Assert.AreEqual(Guid.Empty, actions[0].JobId);
    178184
    179       service.DeleteAppointment(appointmentId);
     185      service.DeleteDowntime(downtimeId);
    180186
    181187      // delete
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Web/Hive-3.4/Web.config

    r6369 r6452  
    22<configuration>
    33
     4  <configSections>
     5    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
     6      <section name="HeuristicLab.Services.Hive.DataAccess.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
     7      <section name="HeuristicLab.Services.Hive.Common.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
     8    </sectionGroup>
     9  </configSections>
     10
     11  <applicationSettings>
     12    <HeuristicLab.Services.Hive.DataAccess.Settings>
     13      <!-- Timeout for long running database command (storing or loading jobData) -->
     14      <setting name="LongRunningDatabaseCommandTimeout" serializeAs="String">
     15        <value>00:05:33</value>
     16      </setting>
     17    </HeuristicLab.Services.Hive.DataAccess.Settings>
     18   
     19    <HeuristicLab.Services.Hive.Common.Settings>
     20      <!-- If a slave does not send a heartbeat for this time, it is set offline which means all of its jobs are rescheduled -->
     21      <setting name="SlaveHeartbeatTimeout" serializeAs="String">
     22        <value>00:01:00</value>
     23      </setting>
     24
     25      <!-- When a job is in state `Calculating` this is the maximum time it does not have to send heartbeats, otherwise its rescheduled -->
     26      <setting name="CalculatingJobHeartbeatTimeout" serializeAs="String">
     27        <value>00:05:30</value>
     28      </setting>
     29
     30      <!-- When a job is in state `Transferring` this is the maximum time it does not have to send heartbeats, otherwise its rescheduled -->
     31      <setting name="TransferringJobHeartbeatTimeout" serializeAs="String">
     32        <value>00:05:30</value>
     33      </setting>
     34    </HeuristicLab.Services.Hive.Common.Settings>
     35  </applicationSettings>
     36 
    437  <connectionStrings>
    538    <add name="HeuristicLab.Authentication" connectionString="data source=localhost;Integrated Security=SSPI;Initial Catalog=HeuristicLab.Authentication"/>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeartbeatManager.cs

    r6444 r6452  
    142142
    143143    private bool SlaveIsAllowedToCalculate(Guid slaveId) {
    144       // appointment==doNotCompute! the slave may only calculate if there is no appointment right now. this needs to be checked for every parent resource also
    145       return dao.GetParentResources(slaveId).All(r => dao.GetAppointments(x => x.ResourceId == r.Id && (DateTime.Now >= x.StartDate) && (DateTime.Now <= x.EndDate)).Count() == 0);
     144      // the slave may only calculate if there is no downtime right now. this needs to be checked for every parent resource also
     145      return dao.GetParentResources(slaveId).All(r => dao.GetDowntimes(x => x.ResourceId == r.Id && (DateTime.Now >= x.StartDate) && (DateTime.Now <= x.EndDate)).Count() == 0);
    146146    }
    147147  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs

    r6431 r6452  
    2727using HeuristicLab.Services.Hive.Common.DataTransfer;
    2828using HeuristicLab.Services.Hive.Common.ServiceContracts;
    29 using DA = HeuristicLab.Services.Hive.DataAccess;
    3029
    3130namespace HeuristicLab.Services.Hive {
     
    4544    private IAuthorizationManager author {
    4645      get { return ServiceLocator.Instance.AuthorizationManager; }
     46    } 
     47    private ITransactionManager trans {
     48      get { return ServiceLocator.Instance.TransactionManager; }
    4749    }
    4850    private ILifecycleManager lifecycleManager {
     
    5658    public Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> resourceIds) {
    5759      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    58       return DA.TransactionManager.UseTransaction(() => {
     60      return trans.UseTransaction(() => {
    5961        job.Id = dao.AddJob(job);
    6062        jobData.JobId = job.Id;
     
    7173    public Guid AddChildJob(Guid parentJobId, Job job, JobData jobData) {
    7274      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    73       return DA.TransactionManager.UseTransaction(() => {
     75      return trans.UseTransaction(() => {
    7476        job.ParentJobId = parentJobId;
    7577        return AddJob(job, jobData, dao.GetAssignedResources(parentJobId).Select(x => x.Id));
     
    109111    public void UpdateJob(Job job) {
    110112      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    111       DA.TransactionManager.UseTransaction(() => {
     113      trans.UseTransaction(() => {
    112114        dao.UpdateJob(job);
    113115      });
     
    116118    public void UpdateJobData(Job job, JobData jobData) {
    117119      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    118       //DA.TransactionManager.UseTransaction(() => { // cneumuel: try without transaction
     120      //trans.UseTransaction(() => { // cneumuel: try without transaction
    119121      jobData.LastUpdate = DateTime.Now;
    120122      dao.UpdateJob(job);
     
    125127    public void DeleteJob(Guid jobId) {
    126128      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    127       DA.TransactionManager.UseTransaction(() => {
     129      trans.UseTransaction(() => {
    128130        dao.DeleteJob(jobId);
    129131      });
     
    132134    public void DeleteChildJobs(Guid parentJobId) {
    133135      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    134       DA.TransactionManager.UseTransaction(() => {
     136      trans.UseTransaction(() => {
    135137        var jobs = GetChildJobs(parentJobId, true, false);
    136138        foreach (var job in jobs) {
     
    143145    public Job UpdateJobState(Guid jobId, JobState jobState, Guid? slaveId, Guid? userId, string exception) {
    144146      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    145       return DA.TransactionManager.UseTransaction(() => {
     147      return trans.UseTransaction(() => {
    146148        Job job = dao.UpdateJobState(jobId, jobState, slaveId, userId, exception);
    147149
     
    161163      });
    162164    }
     165
     166    public IEnumerable<Job> GetJobsByResourceId(Guid resourceId) {
     167      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
     168      return trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId));
     169    }
    163170    #endregion
    164171
     
    166173    public void StopJob(Guid jobId) {
    167174      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    168       DA.TransactionManager.UseTransaction(() => {
     175      trans.UseTransaction(() => {
    169176        var job = dao.GetJob(jobId);
    170177        if (job.State == JobState.Calculating || job.State == JobState.Transferring) {
     
    181188    public void PauseJob(Guid jobId) {
    182189      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    183       DA.TransactionManager.UseTransaction(() => {
     190      trans.UseTransaction(() => {
    184191        var job = dao.GetJob(jobId);
    185192        if (job.State == JobState.Calculating || job.State == JobState.Transferring) {
     
    194201    public void RestartJob(Guid jobId) {
    195202      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    196       DA.TransactionManager.UseTransaction(() => {
     203      trans.UseTransaction(() => {
    197204        Job job = dao.UpdateJobState(jobId, JobState.Waiting, null, author.UserId, string.Empty);
    198205        job.Command = null;
     
    223230    public Guid AddHiveExperiment(HiveExperiment hiveExperimentDto) {
    224231      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    225       return DA.TransactionManager.UseTransaction(() => {
     232      return trans.UseTransaction(() => {
    226233        hiveExperimentDto.OwnerUserId = author.UserId;
    227234        hiveExperimentDto.DateCreated = DateTime.Now;
     
    232239    public void UpdateHiveExperiment(HiveExperiment hiveExperimentDto) {
    233240      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    234       DA.TransactionManager.UseTransaction(() => {
     241      trans.UseTransaction(() => {
    235242        dao.UpdateHiveExperiment(hiveExperimentDto);
    236243      });
     
    239246    public void DeleteHiveExperiment(Guid hiveExperimentId) {
    240247      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    241       DA.TransactionManager.UseTransaction(() => {
     248      trans.UseTransaction(() => {
    242249        HiveExperiment he = dao.GetHiveExperiment(hiveExperimentId);
    243250        dao.DeleteHiveExperiment(hiveExperimentId); // child jobs will be deleted by db-trigger
     
    249256    public void Hello(Slave slaveInfo) {
    250257      authen.AuthenticateForAnyRole(HiveRoles.Slave);
    251       DA.TransactionManager.UseTransaction(() => {
     258      trans.UseTransaction(() => {
    252259        var slave = dao.GetSlave(slaveInfo.Id);
    253260
     
    280287    public void GoodBye(Guid slaveId) {
    281288      authen.AuthenticateForAnyRole(HiveRoles.Slave);
    282       DA.TransactionManager.UseTransaction(() => {
     289      trans.UseTransaction(() => {
    283290        var slave = dao.GetSlave(slaveId);
    284291        if (slave != null) {
     
    294301      authen.AuthenticateForAnyRole(HiveRoles.Slave);
    295302      TriggerLifecycle(false);
    296       return DA.TransactionManager.UseTransaction(() => heartbeatManager.ProcessHeartbeat(heartbeat));
     303      return trans.UseTransaction(() => heartbeatManager.ProcessHeartbeat(heartbeat));
    297304    }
    298305    #endregion
     
    301308    public Guid AddPlugin(Plugin plugin, List<PluginData> pluginDatas) {
    302309      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    303       return DA.TransactionManager.UseTransaction(() => {
     310      return trans.UseTransaction(() => {
    304311        plugin.UserId = author.UserId;
    305312        plugin.DateCreated = DateTime.Now;
     
    325332    }
    326333
     334    public Plugin GetPluginByHash(byte[] hash) {
     335      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     336      return dao.GetPlugins(x => x.Hash == hash).FirstOrDefault();
     337    }
     338
    327339    public IEnumerable<Plugin> GetPlugins() {
    328340      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     
    334346      List<PluginData> pluginDatas = new List<PluginData>();
    335347
    336       return DA.TransactionManager.UseTransaction(() => {
     348      return trans.UseTransaction(() => {
    337349        foreach (Guid guid in pluginIds) {
    338350          pluginDatas.AddRange(dao.GetPluginDatas(x => x.PluginId == guid).ToList());
     
    342354    }
    343355
     356    public void DeletePlugin(Guid pluginId) {
     357      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     358      dao.DeletePlugin(pluginId);
     359    }
    344360    #endregion
    345361
     
    347363    public Guid AddSlave(Slave slave) {
    348364      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    349       return DA.TransactionManager.UseTransaction(() => dao.AddSlave(slave));
     365      return trans.UseTransaction(() => dao.AddSlave(slave));
    350366    }
    351367
    352368    public Guid AddSlaveGroup(SlaveGroup slaveGroup) {
    353369      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    354       return DA.TransactionManager.UseTransaction(() => dao.AddSlaveGroup(slaveGroup));
     370      return trans.UseTransaction(() => dao.AddSlaveGroup(slaveGroup));
    355371    }
    356372
     
    377393    public void UpdateSlave(Slave slave) {
    378394      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    379       DA.TransactionManager.UseTransaction(() => {
     395      trans.UseTransaction(() => {
    380396        dao.UpdateSlave(slave);
    381397      });
     
    384400    public void UpdateSlaveGroup(SlaveGroup slaveGroup) {
    385401      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    386       DA.TransactionManager.UseTransaction(() => {
     402      trans.UseTransaction(() => {
    387403        dao.UpdateSlaveGroup(slaveGroup);
    388404      });
     
    391407    public void DeleteSlave(Guid slaveId) {
    392408      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    393       DA.TransactionManager.UseTransaction(() => {
     409      trans.UseTransaction(() => {
    394410        dao.DeleteSlave(slaveId);
    395411      });
     
    398414    public void DeleteSlaveGroup(Guid slaveGroupId) {
    399415      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    400       DA.TransactionManager.UseTransaction(() => {
     416      trans.UseTransaction(() => {
    401417        dao.DeleteSlaveGroup(slaveGroupId);
    402418      });
     
    405421    public void AddResourceToGroup(Guid slaveGroupId, Guid resourceId) {
    406422      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    407       DA.TransactionManager.UseTransaction(() => {
     423      trans.UseTransaction(() => {
    408424        var resource = dao.GetResource(resourceId);
    409425        resource.ParentResourceId = slaveGroupId;
     
    414430    public void RemoveResourceFromGroup(Guid slaveGroupId, Guid resourceId) {
    415431      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    416       DA.TransactionManager.UseTransaction(() => {
     432      trans.UseTransaction(() => {
    417433        var resource = dao.GetResource(resourceId);
    418434        resource.ParentResourceId = null;
     
    423439    public Guid GetResourceId(string resourceName) {
    424440      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    425       return DA.TransactionManager.UseTransaction(() => {
     441      return trans.UseTransaction(() => {
    426442        var resource = dao.GetResources(x => x.Name == resourceName).FirstOrDefault();
    427443        if (resource != null) {
     
    435451    public void TriggerLifecycle(bool force) {
    436452      // use a serializable transaction here to ensure not two threads execute this simultaniously (mutex-lock would not work since IIS may use multiple AppDomains)
    437       DA.TransactionManager.UseTransaction(() => {
     453      trans.UseTransaction(() => {
    438454        DateTime lastCleanup = dao.GetLastCleanup();
    439455        if (force || DateTime.Now - lastCleanup > TimeSpan.FromSeconds(59)) {
     
    462478    #endregion
    463479
    464     #region Appointment Methods
    465     public Guid AddAppointment(Appointment appointment) {
     480    #region Downtime Methods
     481    public Guid AddDowntime(Downtime downtime) {
    466482      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    467       return DA.TransactionManager.UseTransaction(() => dao.AddAppointment(appointment));
    468     }
    469 
    470     public void DeleteAppointment(Guid appointmentId) {
     483      return trans.UseTransaction(() => dao.AddDowntime(downtime));
     484    }
     485
     486    public void DeleteDowntime(Guid downtimeId) {
    471487      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    472       DA.TransactionManager.UseTransaction(() => {
    473         dao.DeleteAppointment(appointmentId);
    474       });
    475     }
    476 
    477     public void UpdateAppointment(Appointment appointment) {
     488      trans.UseTransaction(() => {
     489        dao.DeleteDowntime(downtimeId);
     490      });
     491    }
     492
     493    public void UpdateDowntime(Downtime downtime) {
    478494      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    479       DA.TransactionManager.UseTransaction(() => {
    480         dao.UpdateAppointment(appointment);
    481       });
    482     }
    483 
    484     public IEnumerable<Appointment> GetScheduleForResource(Guid resourceId) {
     495      trans.UseTransaction(() => {
     496        dao.UpdateDowntime(downtime);
     497      });
     498    }
     499
     500    public IEnumerable<Downtime> GetDowntimesForResource(Guid resourceId) {
    485501      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    486       return DA.TransactionManager.UseTransaction(() => dao.GetAppointments(x => x.ResourceId == resourceId));
    487     }
    488 
    489     public IEnumerable<Job> GetJobsByResourceId(Guid resourceId) {
    490       authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    491       return DA.TransactionManager.UseTransaction(() => dao.GetJobsByResourceId(resourceId));
     502      return trans.UseTransaction(() => dao.GetDowntimes(x => x.ResourceId == resourceId));
    492503    }
    493504    #endregion
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Interfaces/IServiceLocator.cs

    r6431 r6452  
    2828    IHiveDao HiveDao { get; }
    2929    ILifecycleManager LifecycleManager { get; }
     30    ITransactionManager TransactionManager { get; }
    3031    HeartbeatManager HeartbeatManager { get; }
    3132  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/LifecycleManager.cs

    r6431 r6452  
    7676      var slaves = dao.GetSlaves(x => x.SlaveState != SlaveState.Offline);
    7777      foreach (Slave slave in slaves) {
    78         if (!slave.LastHeartbeat.HasValue || (DateTime.Now - slave.LastHeartbeat.Value) > ApplicationConstants.SlaveHeartbeatTimeout) {
     78        if (!slave.LastHeartbeat.HasValue || (DateTime.Now - slave.LastHeartbeat.Value) > Settings.Default.SlaveHeartbeatTimeout) {
    7979          slave.SlaveState = SlaveState.Offline;
    8080          SetJobsWaiting(slave.Id);
     
    107107    /// </summary>
    108108    private void SetTimeoutJobsWaiting() {
    109       var jobs = dao.GetJobs(x => (x.State == JobState.Calculating && (DateTime.Now - x.LastHeartbeat) > ApplicationConstants.CalculatingJobHeartbeatTimeout)
    110                                || (x.State == JobState.Transferring && (DateTime.Now - x.LastHeartbeat) > ApplicationConstants.TransferringJobHeartbeatTimeout));
     109      var jobs = dao.GetJobs(x => (x.State == JobState.Calculating && (DateTime.Now - x.LastHeartbeat) > Settings.Default.CalculatingJobHeartbeatTimeout)
     110                               || (x.State == JobState.Transferring && (DateTime.Now - x.LastHeartbeat) > Settings.Default.TransferringJobHeartbeatTimeout));
    111111      foreach (var j in jobs) {
    112112        Job job = dao.UpdateJobState(j.Id, JobState.Waiting, null, null, "Slave timed out.");
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/ServiceLocator.cs

    r6431 r6452  
    6666    }
    6767
     68    private ITransactionManager transactionManager;
     69    public ITransactionManager TransactionManager {
     70      get {
     71        if (transactionManager == null) transactionManager = new TransactionManager();
     72        return transactionManager;
     73      }
     74    }
     75
    6876    private HeartbeatManager heartbeatManager;
    6977    public HeartbeatManager HeartbeatManager {
Note: See TracChangeset for help on using the changeset viewer.