Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/06/11 17:49:27 (13 years ago)
Author:
cneumuel
Message:

#1233

  • added consideration of appointments in heartbeats
  • code cleanup
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/DataTransfer/Appointment.cs

    r5614 r6369  
    3838    [DataMember]
    3939    public Guid ResourceId { get; set; }
    40 
    41 
    4240  }
    4341}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/DataTransfer/HiveExperimentPermission.cs

    r5614 r6369  
    3737
    3838    public HiveExperimentPermission() { }
    39 
    40 
    4139  }
    4240}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/DataTransfer/HiveItem.cs

    r6367 r6369  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Runtime.Serialization;
    324
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/DataTransfer/JobData.cs

    r5614 r6369  
    3535
    3636    public JobData() { }
    37 
    3837  }
    3938}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/HeuristicLab.Services.Hive.Common-3.4.csproj

    r6229 r6369  
    129129    <None Include="HeuristicLab.snk" />
    130130  </ItemGroup>
    131   <ItemGroup>
    132     <Folder Include="obj\" />
    133   </ItemGroup>
     131  <ItemGroup />
    134132  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    135133  <PropertyGroup>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HeuristicLab.Services.Hive.DataAccess-3.4.csproj

    r5852 r6369  
    7171  </PropertyGroup>
    7272  <ItemGroup>
    73     <Reference Include="HeuristicLab.Clients.Common-3.3">
    74       <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Clients.Common-3.3.dll</HintPath>
    75     </Reference>
    7673    <Reference Include="HeuristicLab.Common-3.3">
    7774      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
     
    118115      <DependentUpon>Settings.settings</DependentUpon>
    119116    </Compile>
    120     <Compile Include="Tools\CreateHiveDatabaseApplication.cs" />
    121117    <Compile Include="TransactionManager.cs" />
    122118  </ItemGroup>
     
    151147  </ItemGroup>
    152148  <ItemGroup>
    153     <Content Include="Tools\cleanHiveDatabase.sql" />
    154149    <Content Include="Tools\prepareHiveDatabase.sql" />
    155150  </ItemGroup>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HeuristicLabServicesHiveDataAccessPlugin.cs.frame

    r6033 r6369  
    88  [Plugin("HeuristicLab.Services.Hive.DataAccess", "3.4.0.$WCREV$")]
    99  [PluginFile("HeuristicLab.Services.Hive.DataAccess-3.4.dll", PluginFileType.Assembly)]
    10   [PluginDependency("HeuristicLab.Clients.Common", "3.3")]
    1110  [PluginDependency("HeuristicLab.Common", "3.3")]
    1211  [PluginDependency("HeuristicLab.Core", "3.3")]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs

    r6367 r6369  
    152152
    153153    #region JobData Methods
    154 
    155154    public DT.JobData GetJobData(Guid id) {
    156155      using (var db = CreateContext()) {
     
    193192
    194193    #region StateLog Methods
    195 
    196194    public DT.StateLog GetStateLog(Guid id) {
    197195      using (var db = CreateContext()) {
     
    285283
    286284    #region HiveExperimentPermission Methods
    287 
    288285    public DT.HiveExperimentPermission GetHiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId) {
    289286      using (var db = CreateContext()) {
     
    322319      }
    323320    }
    324 
    325321    #endregion
    326322
     
    366362
    367363    #region PluginData Methods
    368 
    369364    public DT.PluginData GetPluginData(Guid id) {
    370365      using (var db = CreateContext()) {
     
    399394    public void DeletePluginData(Guid id) {
    400395      using (var db = CreateContext()) {
    401         var entity = db.PluginDatas.FirstOrDefault(x => x.PluginDataId == id); // todo: check if all the byte[] is loaded into memory here. otherwise work around to delete without loading it
     396        var entity = db.PluginDatas.FirstOrDefault(x => x.PluginDataId == id);
    402397        if (entity != null) db.PluginDatas.DeleteOnSubmit(entity);
    403398        db.SubmitChanges();
     
    611606      }
    612607    }
    613 
    614608    #endregion
    615609
     
    682676      using (var db = CreateContext()) {
    683677        return Convert.ToDto(db.Statistics.SingleOrDefault(x => x.StatisticsId == id));
    684 
    685678      }
    686679    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/HeuristicLab.Services.Hive-3.4.Tests.csproj

    r6362 r6369  
    125125      <Name>HeuristicLab.Clients.Hive.Slave-3.4</Name>
    126126    </ProjectReference>
     127    <ProjectReference Include="..\HeuristicLab.Clients.Hive\3.4\HeuristicLab.Clients.Hive-3.4.csproj">
     128      <Project>{B5EF1E5A-9F3D-40B9-B4B0-30AADF2E2CEB}</Project>
     129      <Name>HeuristicLab.Clients.Hive-3.4</Name>
     130    </ProjectReference>
    127131    <ProjectReference Include="..\HeuristicLab.Hive\3.4\HeuristicLab.Hive-3.4.csproj">
    128132      <Project>{F98A1740-9AC9-4D36-A582-6A2D0D06978D}</Project>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/ServiceTests.cs

    r6357 r6369  
    105105      job.HiveExperimentId = experiment.Id;
    106106      job.Id = service.AddJob(job, jobData, new List<Guid> { slave.Id });
    107      
     107
    108108      // test job
    109109      DT.Job jobLoaded = service.GetJob(job.Id);
     
    153153      Assert.AreEqual(1, jobsBySlave.Count());
    154154      Assert.AreEqual(job.Id, jobsBySlave.Single().Id);
    155      
     155
    156156      // set it to finished
    157157      service.UpdateJobState(jobLoaded.Id, JobState.Finished, slave.Id, null, null);
    158158
    159       // test if the job is returned for the resource
     159      // test if the job is returned for the resource (it should not be)
    160160      var jobsBySlave2 = service.GetJobsByResourceId(slave.Id);
    161161      Assert.AreEqual(0, jobsBySlave2.Count());
     162
     163      // set job waiting again
     164      service.UpdateJobState(job.Id, JobState.Waiting, null, null, string.Empty);
     165
     166      // get job again
     167      actions = service.Heartbeat(new Heartbeat() { SlaveId = slave.Id, AssignJob = true, FreeCores = 4, FreeMemory = 1024, JobProgress = new Dictionary<Guid, TimeSpan>() });
     168      Assert.AreEqual(1, actions.Count);
     169      Assert.AreEqual(MessageContainer.MessageType.CalculateJob, actions[0].Message);
     170      Assert.AreEqual(job.Id, actions[0].JobId);
     171
     172      // create appointment which should make slave unavailable for calculation
     173      Guid appointmentId = service.AddAppointment(new Appointment { ResourceId = slave.Id, StartDate = DateTime.Now - TimeSpan.FromMinutes(1), EndDate = DateTime.Now + TimeSpan.FromMinutes(1), Recurring = false });
     174
     175      progress.Clear();
     176      progress.Add(job.Id, new TimeSpan(1, 5, 10, 20, 30));
     177      actions = service.Heartbeat(new Heartbeat() { SlaveId = slave.Id, AssignJob = true, FreeCores = 4, FreeMemory = 1024, JobProgress = new Dictionary<Guid, TimeSpan>() });
     178      Assert.AreEqual(1, actions.Count);
     179      Assert.AreEqual(MessageContainer.MessageType.PauseAll, actions[0].Message);
     180      Assert.AreEqual(Guid.Empty, actions[0].JobId);
     181
     182      service.DeleteAppointment(appointmentId);
    162183
    163184      // delete
     
    177198    }
    178199
    179     List<DT.Job> jobs = new List<DT.Job>();
    180    
    181200    [TestMethod]
    182201    public void TestParentJobs() {
     
    282301      service.DeleteSlave(slave.Id);
    283302    }
    284 
    285     //[TestMethod]
    286     //public void TestHeartbeats() {
    287     //  var service = GetLocalService();
    288     //  // check if group already exists and delete
    289     //  var existingSlaveGroup = service.GetSlaveGroups().SingleOrDefault(g => g.Name == "TestGroup");
    290     //  if (existingSlaveGroup != null) {
    291     //    var slavesToDelete = service.GetSlaves().Where(s => s.ParentResourceId == existingSlaveGroup.Id);
    292     //    foreach (var slave in slavesToDelete) service.DeleteSlave(slave.Id);
    293     //    service.DeleteSlaveGroup(existingSlaveGroup.Id);
    294     //  }
    295 
    296     //  Guid groupId = service.AddSlaveGroup(new SlaveGroup() { Name = "TestGroup", Description = "Used for unit tests" });
    297 
    298     //  // create slaves
    299     //  var slaves = new List<DT.Slave>();
    300     //  for (int i = 0; i < 1; i++) {
    301     //    DT.Slave slave = new DT.Slave() {
    302     //      Cores = 2,
    303     //      Memory = 4096,
    304     //      Name = "Slave " + i,
    305     //      IsAllowedToCalculate = true,
    306     //      SlaveState = DT.SlaveState.Idle,
    307     //      CpuSpeed = 2800,
    308     //      FreeCores = 2,
    309     //      FreeMemory = 3000
    310     //    };
    311     //    // check if slave with this name already exists and delete
    312     //    var existingSlave = service.GetSlaves().Where(s => s.Name == slave.Name).SingleOrDefault();
    313     //    if (existingSlave != null) service.DeleteSlave(existingSlave.Id);
    314 
    315     //    slave.Id = service.AddSlave(slave);
    316     //    service.AddResourceToGroup(groupId, slave.Id);
    317     //    slaves.Add(slave);
    318     //  }
    319 
    320     //  // create jobs with different group, they should not be assigned
    321     //  existingSlaveGroup = service.GetSlaveGroups().SingleOrDefault(g => g.Name == "DummyGroup");
    322     //  if (existingSlaveGroup != null) service.DeleteSlaveGroup(existingSlaveGroup.Id);
    323 
    324     //  Guid dummyGroupId = service.AddSlaveGroup(new SlaveGroup() { Name = "DummyGroup", Description = "Used for unit tests; jobs from this group shall not be calculated" });
    325     //  // create dummy jobs
    326     //  var dummyJobs = new List<Job>();
    327     //  for (int i = 0; i < 2; i++) {
    328     //    Job job = new Job() {
    329     //      CoresNeeded = 1, MemoryNeeded = 0
    330     //    };
    331     //    JobData jobData = new JobData() { Data = PersistenceUtil.Serialize(new MockJob(500, false)) };
    332     //    job.Id = service.AddJob(job, jobData, new List<Guid> { dummyGroupId });
    333     //    dummyJobs.Add(job);
    334     //  }
    335 
    336     //  // create jobs
    337     //  for (int i = 0; i < 2; i++) {
    338     //    Job job = new Job() {
    339     //      CoresNeeded = 1, MemoryNeeded = 0
    340     //    };
    341     //    JobData jobData = new JobData() { Data = PersistenceUtil.Serialize(new MockJob(500, false)) };
    342     //    job.Id = service.AddJob(job, jobData, new List<Guid> { groupId });
    343     //    jobs.Add(job);
    344     //  }
    345 
    346     //  // send heartbeats
    347     //  foreach (var slave in slaves) {
    348     //    new Thread(new ParameterizedThreadStart(RunSlaveThread)).Start(slave);
    349     //  }
    350 
    351     //  IEnumerable<LightweightJob> lightweightJobs;
    352     //  do {
    353     //    Thread.Sleep(500);
    354     //    lightweightJobs = service.GetLightweightJobs(jobs.Select(x => x.Id));
    355     //  } while (!lightweightJobs.All(x => x.State == JobState.Finished));
    356 
    357     //  // delete slaves
    358     //  foreach (var slave in slaves) {
    359     //    service.DeleteSlave(slave.Id);
    360     //    Assert.AreEqual(null, service.GetSlave(slave.Id));
    361     //  }
    362 
    363     //  // delete groups
    364     //  service.DeleteSlaveGroup(groupId);
    365     //  service.DeleteSlaveGroup(dummyGroupId);
    366 
    367     //  // delete jobs
    368     //  foreach (var job in jobs) {
    369     //    service.DeleteJob(job.Id);
    370     //  }
    371 
    372     //  // delete dummy jobs
    373     //  foreach (var job in dummyJobs) {
    374     //    service.DeleteJob(job.Id);
    375     //  }
    376     //}
    377 
    378     //public void RunSlaveThread(object slaveobj) {
    379     //  try {
    380     //    var service = GetLocalService();
    381     //    Slave slave = (Slave)slaveobj;
    382     //    int freeCores = slave.Cores.Value;
    383 
    384     //    for (int i = 0; i < 10; i++) {
    385 
    386     //      var messages = service.Heartbeat(new Heartbeat() { SlaveId = slave.Id, FreeMemory = 2423, FreeCores = freeCores, JobProgress = new Dictionary<Guid, TimeSpan>() });
    387     //      if (messages.Count == 0) {
    388     //        Debug.WriteLine("No job available");
    389     //        return; // no more jobs
    390     //      }
    391 
    392     //      Debug.WriteLine("Messages: {0}", string.Join(", ", messages.Select(m => m.Message)));
    393 
    394     //      Assert.IsTrue(messages.Where(x => x.Message == MessageContainer.MessageType.AbortJob).Count() == 0);
    395     //      Assert.IsTrue(messages.Where(x => x.Message == MessageContainer.MessageType.SayHello).Count() == 0);
    396     //      Assert.IsTrue(messages.Where(x => x.Message == MessageContainer.MessageType.PauseJob).Count() == 0);
    397 
    398     //      var calculateJobMessage = messages.Where(x => x.Message == MessageContainer.MessageType.CalculateJob).SingleOrDefault();
    399     //      if (calculateJobMessage != null) {
    400     //        if (!jobs.Select(j => j.Id).Contains(calculateJobMessage.JobId))
    401     //          Assert.Fail("Got job which was not assigned to the slavegroup");
    402 
    403     //        Debug.WriteLine("Job available, calculating");
    404     //        Job job = service.GetJob(calculateJobMessage.JobId);
    405 
    406     //        JobData jobData = service.GetJobData(job.Id);
    407     //        IJob deserializedJob = PersistenceUtil.Deserialize<IJob>(jobData.Data);
    408     //        deserializedJob.Start();
    409     //        job.SetState(JobState.Finished);
    410     //        jobs.Where(x => x.Id == job.Id).Single().SetState(JobState.Finished);
    411     //        jobData.Data = PersistenceUtil.Serialize(deserializedJob);
    412     //        service.UpdateJobData(job, jobData);
    413     //        Debug.WriteLine("finished calculating");
    414     //      }
    415     //    }
    416     //  }
    417     //  catch (Exception e) {
    418     //    Assert.Fail(e.Message, e);
    419     //  }
    420     //}
    421303  }
    422304}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Web/Hive-3.4/Web.config

    r6178 r6369  
    3131    <bindings>
    3232      <wsHttpBinding>
    33 
    3433        <binding name="WSHttpBinding_IHiveService"
    3534                 receiveTimeout="00:10:00"
     
    7675
    7776  <system.webServer>
    78     <!--<modules runAllManagedModulesForAllRequests="true">
    79       <add name="HiveServerModule" type="HeuristicLab.Services.Hive.IISModules.HiveServerModule"/>
    80     </modules>-->
    81     <directoryBrowse enabled="true"/>
    82    
     77    <directoryBrowse enabled="true"/>   
    8378  </system.webServer>
    8479 
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/AuthorizationManager.cs

    r5511 r6369  
    3434    }
    3535
    36     //public void AuthorizeJobs(params Guid[] jobIds) {
    37     //  if (!IsAuthorizedForJobs(jobIds)) {
    38     //    throw new SecurityException("User '" + Identity.UserName + "' is not authorized to access job (Id: " + string.Join(", ", jobIds.Select(x => x.ToString()).ToArray()) + ")");
    39     //  }
    40     //}
    41 
    42     //private bool IsAuthorizedForJobs(params Guid[] jobIds) {
    43     //  return ServiceLocator.Instance.HiveDao.IsUserAuthorizedForJobs(UserId, jobIds);
    44     //}
    45 
    4636    public void Authorize(Guid userId) {
    47       if (userId != this.UserId) {
     37      if (userId != this.UserId)
    4838        throw new SecurityException("User '" + Identity.UserName + "' is not authorized to access object");
    49       }
    5039    }
    5140  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeartbeatManager.cs

    r6357 r6369  
    3131        slave.FreeMemory = heartbeat.FreeMemory;
    3232        slave.CpuUtilization = heartbeat.CpuUtilization;
    33         slave.IsAllowedToCalculate = true; // Todo: look into calendar
     33        slave.IsAllowedToCalculate = SlaveIsAllowedToCalculate(slave.Id);
    3434        slave.SlaveState = (heartbeat.JobProgress != null && heartbeat.JobProgress.Count > 0) ? SlaveState.Calculating : SlaveState.Idle;
    3535        slave.LastHeartbeat = DateTime.Now;
     
    3737
    3838        // update job data
    39         actions.AddRange(UpdateJobs(heartbeat));
     39        actions.AddRange(UpdateJobs(heartbeat, slave.IsAllowedToCalculate));
    4040
    4141        // assign new job
    4242        if (heartbeat.AssignJob && slave.IsAllowedToCalculate && heartbeat.FreeCores > 0) {
    43           // this part needs to be in a serializable transaction to avoid race conditions
    44           //trans.UseTransaction(() => {
    45             var availableJobs = dao.GetWaitingJobs(slave, 1);
    46             if (availableJobs.Count() > 0) {
    47               var job = availableJobs.First();
    48               actions.Add(new MessageContainer(MessageContainer.MessageType.CalculateJob, job.Id));
    49               AssignJob(slave, job);
    50             }
    51           //}, true);
     43          var availableJobs = dao.GetWaitingJobs(slave, 1);
     44          if (availableJobs.Count() > 0) {
     45            var job = availableJobs.First();
     46            actions.Add(new MessageContainer(MessageContainer.MessageType.CalculateJob, job.Id));
     47            AssignJob(slave, job);
     48          }
    5249        }
    5350      }
     
    6865    /// Checks if all the jobs sent by heartbeat are supposed to be calculated by this slave
    6966    /// </summary>
    70     private IEnumerable<MessageContainer> UpdateJobs(Heartbeat heartbeat) {
     67    private IEnumerable<MessageContainer> UpdateJobs(Heartbeat heartbeat, bool IsAllowedToCalculate) {
    7168      List<MessageContainer> actions = new List<MessageContainer>();
    7269
     
    7471        return actions;
    7572
    76       // process the jobProgresses
    77       foreach (var jobProgress in heartbeat.JobProgress) {
    78         Job curJob = dao.GetJob(jobProgress.Key);
    79         if (curJob == null) {
    80           // job does not exist in db
    81           actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, jobProgress.Key));
    82           LogFactory.GetLogger(this.GetType().Namespace).Log("Job does not exist in DB: " + jobProgress.Key);
    83         } else {
    84           if (curJob.CurrentStateLog.SlaveId == Guid.Empty || curJob.CurrentStateLog.SlaveId != heartbeat.SlaveId) {
    85             // assigned slave does not match heartbeat
    86             actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));
    87             LogFactory.GetLogger(this.GetType().Namespace).Log("The slave " + heartbeat.SlaveId + " is not supposed to calculate Job: " + curJob);
    88           } else if (!JobIsAllowedToBeCalculatedBySlave(heartbeat.SlaveId, curJob)) {
    89             // assigned resources ids of job do not match with slaveId (and parent resourceGroupIds); this might happen when slave is moved to different group
    90             actions.Add(new MessageContainer(MessageContainer.MessageType.PauseJob, curJob.Id));
     73      if (!IsAllowedToCalculate) {
     74        actions.Add(new MessageContainer(MessageContainer.MessageType.PauseAll));
     75      } else {
     76        // process the jobProgresses
     77        foreach (var jobProgress in heartbeat.JobProgress) {
     78          Job curJob = dao.GetJob(jobProgress.Key);
     79          if (curJob == null) {
     80            // job does not exist in db
     81            actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, jobProgress.Key));
     82            LogFactory.GetLogger(this.GetType().Namespace).Log("Job does not exist in DB: " + jobProgress.Key);
    9183          } else {
    92             // save job execution time
    93             curJob.ExecutionTime = jobProgress.Value;
    94             curJob.LastHeartbeat = DateTime.Now;
     84            if (curJob.CurrentStateLog.SlaveId == Guid.Empty || curJob.CurrentStateLog.SlaveId != heartbeat.SlaveId) {
     85              // assigned slave does not match heartbeat
     86              actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));
     87              LogFactory.GetLogger(this.GetType().Namespace).Log("The slave " + heartbeat.SlaveId + " is not supposed to calculate Job: " + curJob);
     88            } else if (!JobIsAllowedToBeCalculatedBySlave(heartbeat.SlaveId, curJob)) {
     89              // assigned resources ids of job do not match with slaveId (and parent resourceGroupIds); this might happen when slave is moved to different group
     90              actions.Add(new MessageContainer(MessageContainer.MessageType.PauseJob, curJob.Id));
     91            } else {
     92              // save job execution time
     93              curJob.ExecutionTime = jobProgress.Value;
     94              curJob.LastHeartbeat = DateTime.Now;
    9595
    96             switch (curJob.Command) {
    97               case Command.Stop:
    98                 actions.Add(new MessageContainer(MessageContainer.MessageType.StopJob, curJob.Id));
    99                 break;
    100               case Command.Pause:
    101                 actions.Add(new MessageContainer(MessageContainer.MessageType.PauseJob, curJob.Id));
    102                 break;
    103               case Command.Abort:
    104                 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));
    105                 break;
     96              switch (curJob.Command) {
     97                case Command.Stop:
     98                  actions.Add(new MessageContainer(MessageContainer.MessageType.StopJob, curJob.Id));
     99                  break;
     100                case Command.Pause:
     101                  actions.Add(new MessageContainer(MessageContainer.MessageType.PauseJob, curJob.Id));
     102                  break;
     103                case Command.Abort:
     104                  actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));
     105                  break;
     106              }
     107              dao.UpdateJob(curJob);
    106108            }
    107             dao.UpdateJob(curJob);
    108109          }
    109110        }
     
    117118      return assignedResourceIds.Any(x => slaveResourceIds.Contains(x));
    118119    }
     120
     121    private bool SlaveIsAllowedToCalculate(Guid slaveId) {
     122      // appointment==doNotCompute! the slave may only calculate if there is no appointment right now. this needs to be checked for every parent resource also
     123      return dao.GetParentResources(slaveId).All(r => dao.GetAppointments(x => x.ResourceId == r.Id && (DateTime.Now >= x.StartDate) && (DateTime.Now <= x.EndDate)).Count() == 0);
     124    }
    119125  }
    120126}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeuristicLab.Services.Hive-3.4.csproj

    r6362 r6369  
    7272  </PropertyGroup>
    7373  <ItemGroup>
    74     <Reference Include="HeuristicLab.Clients.Common-3.3">
    75       <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Clients.Common-3.3.dll</HintPath>
    76     </Reference>
    7774    <Reference Include="HeuristicLab.Common-3.3">
    7875      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
     
    135132    <None Include="HeuristicLab.snk" />
    136133  </ItemGroup>
    137   <ItemGroup>
    138     <Folder Include="Standalone\" />
    139   </ItemGroup>
     134  <ItemGroup />
    140135  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    141136  <ProjectExtensions>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeuristicLabServicesHivePlugin.cs.frame

    r6033 r6369  
    88  [Plugin("HeuristicLab.Services.Hive", "3.4.0.$WCREV$")]
    99  [PluginFile("HeuristicLab.Services.Hive-3.4.dll", PluginFileType.Assembly)]
    10   [PluginDependency("HeuristicLab.Clients.Common", "3.3")]
    1110  [PluginDependency("HeuristicLab.Common", "3.3")]
    1211  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveRoles.cs

    r6000 r6369  
    2020#endregion
    2121
    22 
    2322namespace HeuristicLab.Services.Hive {
    2423  public static class HiveRoles {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs

    r6367 r6369  
    317317      return trans.UseTransaction(() => {
    318318        foreach (Guid guid in pluginIds) {
    319           List<PluginData> pluginData = dao.GetPluginDatas(x => x.PluginId == guid).ToList();
    320           if (pluginData != null) {
    321             pluginDatas.AddRange(pluginData);
    322           } else {
    323             //ignore ?
    324           }
     319          pluginDatas.AddRange(dao.GetPluginDatas(x => x.PluginId == guid).ToList());
    325320        }
    326321        return pluginDatas;
     
    420415
    421416    public void TriggerLifecycle(bool force) {
    422       // use a serializable transaction here to ensure not two threads execute this simultaniously (locking would not work since IIS may use multiple AppDomains)
     417      // use a serializable transaction here to ensure not two threads execute this simultaniously (mutex-lock would not work since IIS may use multiple AppDomains)
    423418      trans.UseTransaction(() => {
    424419        DateTime lastCleanup = dao.GetLastCleanup();
     
    444439
    445440      if (includeParent) jobs.Add(GetJob(parentJobId.Value));
    446 
    447441      return jobs;
    448442    }
    449 
    450443    #endregion
    451444
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Interfaces/IAuthorizationManager.cs

    r5511 r6369  
    2929
    3030    /// <summary>
    31     /// Checks if the user is allowed to access all the jobs.
    32     /// throws an exception if one of those jobs is inaccessible
    33     /// </summary>
    34     /// <exception cref="SecurityException">thrown when access denied</exception>
    35     //void AuthorizeJobs(params Guid[] jobId);
    36 
    37     /// <summary>
    3831    /// Compares the current UserId with the given userId and takes appropriate actions if the mismatch
    3932    /// </summary>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Interfaces/ILifecycleManager.cs

    r5593 r6369  
    1 
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    222namespace HeuristicLab.Services.Hive {
    323  /// <summary>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Interfaces/IServiceLocator.cs

    r6362 r6369  
    1 using HeuristicLab.Services.Hive.DataAccess;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using HeuristicLab.Services.Hive.DataAccess;
    223
    324namespace HeuristicLab.Services.Hive {
Note: See TracChangeset for help on using the changeset viewer.