Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5511


Ignore:
Timestamp:
02/17/11 14:47:56 (13 years ago)
Author:
cneumuel
Message:

#1233

  • added StateLog to log state transitions of hive jobs
  • added permissions to hive experiments (in data access layer, no UI for that yet)
  • extended unit tests
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
4 added
30 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Tests/Mocks/MockHiveService.cs

    r5458 r5511  
    154154    }
    155155
    156     public void UpdateJob(Job jobDto, JobData jobDataDto) {
     156    public void UpdateJob(Job jobDto) {
    157157      Console.WriteLine("Update Job called!");
     158      ResultJobs.Add(jobDto);
     159    }
     160
     161    public void UpdateJobData(Job jobDto, JobData jobDataDto) {
     162      Console.WriteLine("Update JobData called!");
    158163      ResultJobDatas.Add(jobDataDto);
    159164      ResultJobs.Add(jobDto);
     
    174179      if (curJobIdx < jobs.Count) {
    175180        var job = jobs[curJobIdx];
    176         job.SlaveId = slaveId;
     181        // job.SlaveId = slaveId; // commented out because of change to StateLog
    177182        curJobIdx++;
    178183        return job;
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Tests/SlaveTest.cs

    r5404 r5511  
    7676    [TestMethod]
    7777    public void TestSingleJob() {
    78       Job testJob = new Job { Id = Guid.NewGuid(), JobState = JobState.Waiting, DateCreated = DateTime.Now, CoresNeeded = 1, MemoryNeeded = 0 };
     78      Job testJob = new Job { Id = Guid.NewGuid(), CoresNeeded = 1, MemoryNeeded = 0 };
     79      testJob.SetState(JobState.Waiting);
    7980      List<Job> jobList = new List<Job>();
    8081      jobList.Add(testJob);
     
    113114    [TestMethod]
    114115    public void TestShutdownSlaveWhileJobRunning() {
    115       Job testJob = new Job { Id = Guid.NewGuid(), JobState = JobState.Waiting, DateCreated = DateTime.Now, CoresNeeded = 1, MemoryNeeded = 0 };
     116      Job testJob = new Job { Id = Guid.NewGuid(), CoresNeeded = 1, MemoryNeeded = 0 };
     117      testJob.SetState(JobState.Waiting);
    116118      List<Job> jobList = new List<Job>();
    117119      jobList.Add(testJob);
     
    173175    [TestMethod]
    174176    public void TestTwoJobs() {
    175       Job testJob1 = new Job { Id = Guid.NewGuid(), JobState = JobState.Waiting, DateCreated = DateTime.Now, CoresNeeded = 1, MemoryNeeded = 0 };
    176       Job testJob2 = new Job { Id = Guid.NewGuid(), JobState = JobState.Waiting, DateCreated = DateTime.Now, CoresNeeded = 1, MemoryNeeded = 0 };
     177      Job testJob1 = new Job { Id = Guid.NewGuid(), CoresNeeded = 1, MemoryNeeded = 0 };
     178      testJob1.SetState(JobState.Waiting);
     179      Job testJob2 = new Job { Id = Guid.NewGuid(), CoresNeeded = 1, MemoryNeeded = 0 };
     180      testJob2.SetState(JobState.Waiting);
    177181      List<Job> jobList = new List<Job>();
    178182      jobList.Add(testJob1);
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs

    r5472 r5511  
    185185        engines[job.Id].Pause();
    186186        JobData sJob = engines[job.Id].GetFinishedJob();
    187         job.Exception = engines[job.Id].CurrentException;
     187        // job.Exception = engines[job.Id].CurrentException; // can there be an exception if a job is paused
    188188        job.ExecutionTime = engines[job.Id].ExecutionTime;
    189189
    190190        try {
    191191          ClientCom.LogMessage("Sending the paused job with id: " + job.Id);
    192           wcfService.UpdateJob(job, sJob);
     192          wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id);
    193193          SlaveStatusInfo.JobsProcessed++;    //TODO: count or not count, thats the question
    194194        }
     
    208208        engines[job.Id].Stop();
    209209        JobData sJob = engines[job.Id].GetFinishedJob();
    210         job.Exception = engines[job.Id].CurrentException;
     210        // job.Exception = engines[job.Id].CurrentException; // can there be an exception if a job is stopped regularly
    211211        job.ExecutionTime = engines[job.Id].ExecutionTime;
    212212
    213213        try {
    214214          ClientCom.LogMessage("Sending the stoppped job with id: " + job.Id);
    215           wcfService.UpdateJob(job, sJob);
     215          wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id);
    216216          SlaveStatusInfo.JobsProcessed++;    //TODO: count or not count, thats the question
    217217        }
     
    345345      } else {
    346346        Job job = Jobs[data.JobId];
    347         job.JobState = JobState.WaitingForChildJobs;
    348         wcfService.UpdateJob(job, data);
     347        job.SetState(JobState.Transferring);
     348        wcfService.UpdateJobData(job, data, ConfigManager.Instance.GetClientInfo().Id);
     349        job.SetState(JobState.Waiting); // todo: what if it was a ResumeOnChildJobsFinished job before? maybe look into StateLog
     350        wcfService.UpdateJob(job);
    349351      }
    350352      KillAppDomain(data.JobId);
     
    372374        cJob.ExecutionTime = engines[jobId].ExecutionTime;
    373375
    374         JobData sJob = engines[jobId].GetFinishedJob();
    375         cJob.Exception = engines[jobId].CurrentException;
    376         cJob.ExecutionTime = engines[jobId].ExecutionTime;
     376        JobData sJob = engines[jId].GetFinishedJob();
     377        // cJob.Exception = engines[jId].CurrentException; // can there be an exception if the job is sent normally. the exception should be entered in the statelog with the corresponding state (Failed)
     378        cJob.ExecutionTime = engines[jId].ExecutionTime;
    377379
    378380        try {
    379381          ClientCom.LogMessage("Sending the finished job with id: " + jobId);
    380           wcfService.UpdateJob(cJob, sJob);
     382          wcfService.UpdateJobData(cJob, sJob, ConfigManager.Instance.GetClientInfo().Id);
    381383          SlaveStatusInfo.JobsProcessed++;
    382384        }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Executor.cs

    r5469 r5511  
    128128
    129129      Job childJob = new Job();
    130       childJob.JobState = JobState.Offline;
     130      childJob.SetState(JobState.Offline);
    131131      childJob.CoresNeeded = 1;
    132132      childJob.MemoryNeeded = 0;
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/WcfService.cs

    r5458 r5511  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Clients.Common;
    25 using HeuristicLab.Clients.Hive.Slave.Properties;
    2625using HeuristicLab.Common;
    2726using HeuristicLab.Services.Hive.Common;
     
    141140    }
    142141
     142    public void UpdateJob(Job job) {
     143      using (Disposable<IHiveService> service = GetSlaveService()) {
     144        try {
     145          service.Obj.UpdateJob(job);
     146        }
     147        catch (Exception ex) {
     148          HandleNetworkError(ex);
     149        }
     150      }
     151    }
     152
    143153    /// <summary>
    144154    /// used on pause or if job finished to upload the job results
     
    146156    /// <param name="job"></param>
    147157    /// <param name="jobData"></param>   
    148     public void UpdateJob(Job job, JobData jobData) {
    149       using (Disposable<IHiveService> service = GetSlaveService()) {
    150         try {
    151           service.Obj.UpdateJob(job, jobData);
    152         }
    153         catch (Exception ex) {
    154           HandleNetworkError(ex);
    155         }
    156       }
    157     }
    158 
     158    public void UpdateJobData(Job job, JobData jobData, Guid slaveId) {
     159      using (Disposable<IHiveService> service = GetSlaveService()) {
     160        try {
     161          JobState before = job.State;
     162          job.SetState(JobState.Transferring, slaveId, "");
     163          service.Obj.UpdateJob(job);
     164
     165          service.Obj.UpdateJobData(job, jobData);
     166
     167          job.SetState(before, slaveId, "");
     168          service.Obj.UpdateJob(job);
     169        }
     170        catch (Exception ex) {
     171          HandleNetworkError(ex);
     172        }
     173      }
     174    }
     175   
    159176    public List<MessageContainer> SendHeartbeat(Heartbeat heartbeat) {
    160177      using (Disposable<IHiveService> service = GetSlaveService()) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/HiveJobView.cs

    r4905 r5511  
    127127      } else {
    128128        if (Content != null && Content.Job != null) {
    129           this.stateTextBox.Text = Content.Job.JobState.ToString();
     129          this.stateTextBox.Text = Content.Job.State.ToString();
    130130          this.executionTimeTextBox.Text = Content.Job.ExecutionTime.ToString();
    131           this.dateCalculatedText.Text = Content.Job.DateCalculated.ToString();
     131          //this.dateCalculatedText.Text = Content.Job.DateCalculated.ToString();
    132132          this.dateFinishedTextBox.Text = Content.Job.DateFinished.ToString();
    133           this.exceptionTextBox.Text = Content.Job.Exception;
     133          this.exceptionTextBox.Text = Content.Job.CurrentStateLog.Exception;
    134134        } else {
    135135          this.stateTextBox.Text = string.Empty;
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/HiveExperimentClient.cs

    r5458 r5511  
    2424using System.Linq;
    2525using System.Threading;
     26using HeuristicLab.Clients.Common;
     27using HeuristicLab.Clients.Hive.Jobs;
    2628using HeuristicLab.Common;
    2729using HeuristicLab.Core;
     30using HeuristicLab.Optimization;
     31using HeuristicLab.Services.Hive.Common;
     32using HeuristicLab.Services.Hive.Common.DataTransfer;
     33using HeuristicLab.Services.Hive.Common.ServiceContracts;
    2834using HeuristicLab.Tracing;
    29 using HeuristicLab.Services.Hive.Common;
    30 using HeuristicLab.Services.Hive.Common.ServiceContracts;
    31 using HeuristicLab.Services.Hive.Common.DataTransfer;
    32 using HeuristicLab.Clients.Hive.Jobs;
    33 using HeuristicLab.Clients.Common;
    34 using HeuristicLab.Optimization;
    3535
    3636namespace HeuristicLab.Clients.Hive {
     37  using System.Configuration;
     38  using System.IO;
     39  using HeuristicLab.PluginInfrastructure;
    3740  using DT = HeuristicLab.Services.Hive.Common.DataTransfer;
    38   using HeuristicLab.PluginInfrastructure;
    39   using System.IO;
    40   using System.Configuration;
    41   using System.Reflection;
    42   using HeuristicLab.PluginInfrastructure.Manager;
    4341
    4442  /// <summary>
     
    301299    private static Plugin UploadConfigurationFile(IHiveService service) {
    302300      string exeFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "HeuristicLab 3.3.exe");
    303       string configFileName = ConfigurationManager.OpenExeConfiguration(exeFilePath).FilePath;
     301      string configFileName = Path.GetFileName(ConfigurationManager.OpenExeConfiguration(exeFilePath).FilePath);
    304302
    305303      Plugin configPlugin = new Plugin() {
     
    331329      if (hiveJob.OptimizerJob.ComputeInParallel &&
    332330        (hiveJob.OptimizerJob.Optimizer is Optimization.Experiment || hiveJob.OptimizerJob.Optimizer is Optimization.BatchRun)) {
    333         hiveJob.Job.JobState = JobState.WaitingForChildJobs;
     331        hiveJob.Job.SetState(JobState.FinishOnChildJobsFinished);
    334332        hiveJob.OptimizerJob.CollectChildJobs = false; // don't collect child-jobs on slaves
    335333        jobData = hiveJob.GetAsJobData(true, out plugins);
     
    522520        if (hj != null) {
    523521          hj.UpdateFromLightweightJob(lightweightJob);
    524           if ((hj.Job.JobState == JobState.Aborted ||
    525                hj.Job.JobState == JobState.Failed ||
    526                hj.Job.JobState == JobState.Finished) &&
     522          if ((hj.Job.State == JobState.Aborted ||
     523               hj.Job.State == JobState.Failed ||
     524               hj.Job.State == JobState.Finished) &&
    527525              !hj.IsFinishedOptimizerDownloaded) {
    528526            LogMessage(hj.Job.Id, "Downloading optimizer for job");
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/HiveJobClient.cs

    r5404 r5511  
    2323using System.Collections.Generic;
    2424using System.Drawing;
    25 using System.IO;
    2625using System.Linq;
    2726using HeuristicLab.Clients.Hive.Jobs;
     
    3231using HeuristicLab.PluginInfrastructure;
    3332using HeuristicLab.Services.Hive.Common.DataTransfer;
    34 using HeuristicLab.PluginInfrastructure.Manager;
    3533
    3634namespace HeuristicLab.Clients.Hive {
     
    4543          return HeuristicLab.Common.Resources.VSImageLibrary.Event;
    4644        } else {
    47           if (job.JobState == JobState.Waiting) return HeuristicLab.Common.Resources.VSImageLibrary.ExecutablePrepared;
    48           else if (job.JobState == JobState.WaitingForChildJobs) return HeuristicLab.Common.Resources.VSImageLibrary.ExecutablePrepared;
    49           else if (job.JobState == JobState.Calculating) return HeuristicLab.Common.Resources.VSImageLibrary.ExecutableStarted;
    50           else if (job.JobState == JobState.Aborted) return HeuristicLab.Common.Resources.VSImageLibrary.ExecutableStopped;
    51           else if (job.JobState == JobState.Failed) return HeuristicLab.Common.Resources.VSImageLibrary.Error;
    52           else if (job.JobState == JobState.Finished) return HeuristicLab.Common.Resources.VSImageLibrary.ExecutableStopped;
     45          if (job.State == JobState.Waiting) return HeuristicLab.Common.Resources.VSImageLibrary.ExecutablePrepared;
     46          else if (job.State == JobState.FinishOnChildJobsFinished) return HeuristicLab.Common.Resources.VSImageLibrary.ExecutablePrepared;
     47          else if (job.State == JobState.Calculating) return HeuristicLab.Common.Resources.VSImageLibrary.ExecutableStarted;
     48          else if (job.State == JobState.Aborted) return HeuristicLab.Common.Resources.VSImageLibrary.ExecutableStopped;
     49          else if (job.State == JobState.Failed) return HeuristicLab.Common.Resources.VSImageLibrary.Error;
     50          else if (job.State == JobState.Finished) return HeuristicLab.Common.Resources.VSImageLibrary.ExecutableStopped;
    5351          else return HeuristicLab.Common.Resources.VSImageLibrary.Event;
    5452        }
     
    108106    public HiveJob() {
    109107      this.Job = new Job() {
    110         JobState = JobState.Offline,
    111         DateCreated = DateTime.Now,
    112108        CoresNeeded = 1,
    113109        MemoryNeeded = 0
    114110      };
     111      job.SetState(JobState.Offline);
    115112      this.childHiveJobs = new ItemList<HiveJob>();
    116113      syncJobsWithOptimizers = true;
     
    406403      if (lightweightJob != null) {
    407404        job.Id = lightweightJob.Id;
    408         job.DateCreated = lightweightJob.DateCreated;
    409         job.DateCalculated = lightweightJob.DateCalculated;
    410         job.DateFinished = lightweightJob.DateFinished;
    411         job.Exception = lightweightJob.Exception;
    412405        job.Id = lightweightJob.Id;
    413406        job.ExecutionTime = lightweightJob.ExecutionTime;
    414         job.JobState = lightweightJob.JobState;
     407        job.StateLog = new List<StateLog>(lightweightJob.StateLog);
    415408        // what about parentJob
    416409        OnJobStateChanged();
     
    488481    public event EventHandler JobStateChanged;
    489482    private void OnJobStateChanged() {
    490       LogMessage("JobStateChanged (State: " + this.Job.JobState + ", ExecutionTime: " + this.Job.ExecutionTime.ToString() + ")");
     483      LogMessage("JobStateChanged (State: " + this.Job.State + ", ExecutionTime: " + this.Job.ExecutionTime.ToString() + ")");
    491484      EventHandler handler = JobStateChanged;
    492485      if (handler != null) handler(this, EventArgs.Empty);
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/DataTransfer/HiveExperiment.cs

    r5458 r5511  
    2929  public class HiveExperiment : NamedHiveItem {
    3030    [DataMember]
    31     public Guid UserId { get; set; }
     31    public Guid OwnerUserId { get; set; }
    3232    [DataMember]
    3333    public Guid RootJobId { get; set; }
     
    3636    [DataMember]
    3737    public string ResourceNames { get; set; }
     38    [DataMember]
     39    public DateTime? LastAccessed { get; set; }
    3840
    3941    public HiveExperiment() { }
    4042    protected HiveExperiment(HiveExperiment original, Cloner cloner) : base(original, cloner) {
    4143      this.RootJobId = original.RootJobId;
    42       this.UserId = original.UserId;
     44      this.OwnerUserId = original.OwnerUserId;
    4345      this.DateCreated = original.DateCreated;
    4446      this.ResourceNames = original.ResourceNames;
     47      this.LastAccessed = original.LastAccessed;
    4548    }
    4649    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/DataTransfer/Job.cs

    r5405 r5511  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Linq;
    2524using System.Runtime.Serialization;
    2625using HeuristicLab.Common;
     
    3029  [Serializable]
    3130  public class Job : LightweightJob {
    32     [DataMember]
    33     public Guid UserId { get; set; }
    3431    [DataMember]
    3532    public int Priority { get; set; }
     
    4239    [DataMember]
    4340    public DateTime? LastHeartbeat { get; set; }
    44 
     41   
    4542    public Job() {
    4643      this.PluginsNeededIds = new List<Guid>();
    4744    }
    4845    protected Job(Job original, Cloner cloner) : base(original, cloner) {
    49       this.UserId = original.UserId;
    5046      this.Priority = original.Priority;
    5147      this.CoresNeeded = original.CoresNeeded;
     
    5955
    6056    public override string ToString() {
    61       return string.Format("State: {0}, SlaveId: {1}, DateCreated: {2}, DateCalculated: {3}, CoresNeeded: {4}, MemoryNeeded: {5}", JobState, SlaveId, DateCreated, DateCalculated, CoresNeeded, MemoryNeeded);
     57      return string.Format("State: {0}, SlaveId: {1}, DateCreated: {2}, DateCalculated: {3}, CoresNeeded: {4}, MemoryNeeded: {5}", State, CurrentStateLog.SlaveId, DateCreated, CoresNeeded, MemoryNeeded);
    6258    }
    6359
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/DataTransfer/JobState.cs

    r4649 r5511  
    3333    Waiting,
    3434
    35         /// <summary>
     35    /// <summary>
     36    /// The job is set to Finished when all child jobs are Finished.
     37    /// </summary>
     38    FinishOnChildJobsFinished,
     39
     40    /// <summary>
    3641    /// The job is paused and waits on the server to be sent back to a Slave when all of its child jobs are Finished.
    3742    /// </summary>
    38     WaitingForChildJobs,
     43    ResumeOnChildJobsFinished,
     44
     45    /// <summary>
     46    /// Job is beeing transferred
     47    /// </summary>
     48    Transferring,
    3949
    4050    /// <summary>
     
    7282    public static bool IsWaiting(this JobState jobState) {
    7383      return jobState == JobState.Waiting ||
    74         jobState == JobState.WaitingForChildJobs;
     84        jobState == JobState.FinishOnChildJobsFinished;
    7585    }
    7686
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/DataTransfer/LightweightJob.cs

    r5106 r5511  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2325using System.Runtime.Serialization;
    2426using HeuristicLab.Common;
     
    2931  public class LightweightJob : HiveItem {
    3032    [DataMember]
    31     public Guid? SlaveId { get; set; }
    32     [DataMember]
    33     public JobState JobState { get; set; }
    34     [DataMember]
    3533    public TimeSpan? ExecutionTime { get; set; }
    3634    [DataMember]
    37     public String Exception { get; set; }
     35    public Guid? ParentJobId { get; set; }
    3836    [DataMember]
    39     public DateTime DateCreated { get; set; }
     37    public List<StateLog> StateLog { get; set; }
    4038    [DataMember]
    41     public DateTime? DateCalculated { get; set; }
    42     [DataMember]
    43     public DateTime? DateFinished { get; set; }
    44     [DataMember]
    45     public Guid? ParentJobId { get; set; }
     39    public JobState State { get; set; }
     40
     41    public StateLog CurrentStateLog { get { return StateLog.Last(); } }
     42    public DateTime DateCreated { get { return StateLog.First().DateTime; } }
     43    public DateTime? DateFinished { get { return CurrentStateLog.State == JobState.Finished ? new DateTime?(CurrentStateLog.DateTime) : null; } }
    4644
    4745    public LightweightJob() {
    48       JobState = DataTransfer.JobState.Offline;
     46      StateLog = new List<DataTransfer.StateLog>();
    4947    }
     48
    5049    public LightweightJob(Job job) {
    51       this.SlaveId = job.SlaveId;
    52       this.JobState = job.JobState;
    5350      this.ExecutionTime = job.ExecutionTime;
    54       this.Exception = job.Exception;
    55       this.DateCreated = job.DateCreated;
    56       this.DateCalculated = job.DateCalculated;
    57       this.DateFinished = job.DateFinished;
    5851      this.ParentJobId = job.ParentJobId;
     52      this.StateLog = new List<StateLog>();
    5953    }
    60     protected LightweightJob(LightweightJob original, Cloner cloner) : base(original, cloner) {
    61       this.SlaveId = original.SlaveId;
    62       this.JobState = original.JobState;
     54    protected LightweightJob(LightweightJob original, Cloner cloner)
     55      : base(original, cloner) {
    6356      this.ExecutionTime = original.ExecutionTime;
    64       this.Exception = original.Exception;
    65       this.DateCreated = original.DateCreated;
    66       this.DateCalculated = original.DateCalculated;
    67       this.DateFinished = original.DateFinished;
    6857      this.ParentJobId = original.ParentJobId;
     58      this.StateLog = new List<StateLog>(original.StateLog);
    6959    }
    7060    public override IDeepCloneable Clone(Cloner cloner) {
    7161      return new LightweightJob(this, cloner);
    7262    }
     63
     64    public void SetState(JobState state) {
     65      this.State = state;
     66      this.StateLog.Add(new StateLog() { State = state, DateTime = DateTime.Now });
     67    }
     68
     69    public void SetState(JobState state, Guid userId) {
     70      this.State = state;
     71      this.StateLog.Add(new StateLog() { State = state, DateTime = DateTime.Now, UserId = userId });
     72    }
     73
     74    public void SetState(JobState state, Guid slaveId, string exception) {
     75      this.State = state;
     76      this.StateLog.Add(new StateLog() { State = state, DateTime = DateTime.Now, SlaveId = slaveId, Exception = exception });
     77    }
    7378  }
    7479}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/HeuristicLab.Services.Hive.Common-3.4.csproj

    r5402 r5511  
    9797    <None Include="HeuristicLabServicesHiveCommonPlugin.cs.frame" />
    9898    <Compile Include="DataTransfer\Appointment.cs" />
     99    <Compile Include="DataTransfer\HiveExperimentPermission.cs" />
     100    <Compile Include="DataTransfer\StateLog.cs" />
    99101    <Compile Include="DataTransfer\HeartBeat.cs" />
    100102    <Compile Include="DataTransfer\HiveExperiment.cs" />
    101103    <Compile Include="DataTransfer\HiveItem.cs" />
    102104    <Compile Include="DataTransfer\HiveItemBase.cs" />
     105    <Compile Include="DataTransfer\Permission.cs" />
    103106    <Compile Include="DataTransfer\PluginData.cs" />
    104107    <Compile Include="DataTransfer\Plugin.cs" />
     
    106109    <Compile Include="DataTransfer\LightweightJob.cs" />
    107110    <Compile Include="DataTransfer\JobState.cs" />
     111    <Compile Include="Logger.cs" />
    108112    <Compile Include="MessageContainer.cs" />
    109113    <Compile Include="DataTransfer\NamedHiveItem.cs" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/ServiceContracts/IHiveService.cs

    r5458 r5511  
    1212    #region Job Methods
    1313    [OperationContract]
    14     Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> slaveGroupIds);
     14    Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> resourceIds);
    1515
    1616    [OperationContract]
     
    3333
    3434    [OperationContract]
    35     void UpdateJob(Job jobDto, JobData jobDataDto);
     35    void UpdateJob(Job jobDto);
     36   
     37    [OperationContract]
     38    void UpdateJobData(Job jobDto, JobData jobDataDto);
    3639
    3740    [OperationContract]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Convert.cs

    r5458 r5511  
    3333        Id = source.JobId,
    3434        CoresNeeded = source.CoresNeeded,
    35         DateCalculated = source.DateCalculated,
    36         DateCreated = source.DateCreated,
    37         DateFinished = source.DateFinished,
    38         Exception = source.Exception,
    39         ExecutionTime = source.ExecutionTime,
     35        ExecutionTime = string.IsNullOrEmpty(source.ExecutionTime) ? TimeSpan.Zero : TimeSpan.Parse(source.ExecutionTime),
    4036        MemoryNeeded = source.MemoryNeeded,
    4137        ParentJobId = source.ParentJobId,
    4238        Priority = source.Priority,
    43         SlaveId = source.SlaveId,
    44         JobState = source.JobState,
    45         UserId = source.UserId,
    4639        PluginsNeededIds = source.RequiredPlugins.Select(x => x.PluginId).ToList(),
    47         LastHeartbeat = source.LastHeartbeat       
     40        LastHeartbeat = source.LastHeartbeat,
     41        State = source.State,
     42        StateLog = source.StateLogs.Select(x => Convert.ToDto(x)).OrderBy(x => x.DateTime).ToList()
    4843      };
    4944    }
     
    5752        target.JobId = source.Id;
    5853        target.CoresNeeded = source.CoresNeeded;
    59         target.DateCalculated = source.DateCalculated;
    60         target.DateCreated = source.DateCreated;
    61         target.DateFinished = source.DateFinished;
    62         target.Exception = source.Exception;
    63         target.ExecutionTime = source.ExecutionTime;
     54        target.ExecutionTime = source.ExecutionTime.ToString();
    6455        target.MemoryNeeded = source.MemoryNeeded;
    6556        target.ParentJobId = source.ParentJobId;
    6657        target.Priority = source.Priority;
    67         target.SlaveId = source.SlaveId;
    68         target.JobState = source.JobState;
    69         target.UserId = source.UserId;
    7058        target.LastHeartbeat = source.LastHeartbeat;
     59        target.State = source.State;
     60        if (target.StateLogs == null) target.StateLogs = new EntitySet<StateLog>();
     61        target.StateLogs.AddRange(source.StateLog.Select(x => Convert.ToEntity(x)).OrderBy(x => x.DateTime));
    7162        // RequiredPlugins are added by Dao
    7263      }
     
    9182    #endregion
    9283
     84    #region StateLog
     85    public static DT.StateLog ToDto(StateLog source) {
     86      if (source == null) return null;
     87      return new DT.StateLog { Id = source.StateLogId, DateTime = source.DateTime, Exception = source.Exception, JobId = source.JobId, SlaveId = source.SlaveId, State = source.State, UserId = source.UserId };
     88    }
     89    public static StateLog ToEntity(DT.StateLog source) {
     90      if (source == null) return null;
     91      var entity = new StateLog(); ToEntity(source, entity);
     92      return entity;
     93    }
     94    public static void ToEntity(DT.StateLog source, StateLog target) {
     95      if ((source != null) && (target != null)) {
     96        target.StateLogId = source.Id; target.DateTime = source.DateTime; target.Exception = source.Exception; target.JobId = source.JobId; target.SlaveId = source.SlaveId; target.State = source.State; target.UserId = source.UserId;
     97      }
     98    }
     99    #endregion
     100
    93101    #region HiveExperiment
    94102    public static DT.HiveExperiment ToDto(HiveExperiment source) {
    95103      if (source == null) return null;
    96       return new DT.HiveExperiment { Id = source.HiveExperimentId, Description = source.Description, Name = source.Name, RootJobId = source.RootJobId, UserId = source.UserId, DateCreated = source.DateCreated, ResourceNames = source.ResourceIds };
     104      return new DT.HiveExperiment { Id = source.HiveExperimentId, Description = source.Description, Name = source.Name, RootJobId = source.RootJobId, OwnerUserId = source.OwnerUserId, DateCreated = source.DateCreated, ResourceNames = source.ResourceIds, LastAccessed = source.LastAccessed };
    97105    }
    98106    public static HiveExperiment ToEntity(DT.HiveExperiment source) {
     
    103111    public static void ToEntity(DT.HiveExperiment source, HiveExperiment target) {
    104112      if ((source != null) && (target != null)) {
    105         target.HiveExperimentId = source.Id; target.Description = source.Description; target.Name = source.Name; target.RootJobId = source.RootJobId; target.UserId = source.UserId; target.DateCreated = source.DateCreated; target.ResourceIds = source.ResourceNames;
     113        target.HiveExperimentId = source.Id; target.Description = source.Description; target.Name = source.Name; target.RootJobId = source.RootJobId; target.OwnerUserId = source.OwnerUserId; target.DateCreated = source.DateCreated; target.ResourceIds = source.ResourceNames; target.LastAccessed = source.LastAccessed;
     114      }
     115    }
     116    #endregion
     117
     118    #region HiveExperimentPermission
     119    public static DT.HiveExperimentPermission ToDto(HiveExperimentPermission source) {
     120      if (source == null) return null;
     121      return new DT.HiveExperimentPermission { HiveExperimentId = source.HiveExperimentId, GrantedUserId = source.GrantedUserId, GrantedByUserId = source.GrantedByUserId, Permission = source.Permission };
     122    }
     123    public static HiveExperimentPermission ToEntity(DT.HiveExperimentPermission source) {
     124      if (source == null) return null;
     125      var entity = new HiveExperimentPermission(); ToEntity(source, entity);
     126      return entity;
     127    }
     128    public static void ToEntity(DT.HiveExperimentPermission source, HiveExperimentPermission target) {
     129      if ((source != null) && (target != null)) {
     130        target.HiveExperimentId = source.HiveExperimentId; target.GrantedUserId = source.GrantedUserId; target.GrantedByUserId = source.GrantedByUserId; target.Permission = source.Permission;
    106131      }
    107132    }
     
    145170    public static DT.Slave ToDto(Slave source) {
    146171      if (source == null) return null;
    147       return new DT.Slave { 
    148         Id = source.ResourceId, 
    149         ParentResourceId = source.ParentResourceId, 
     172      return new DT.Slave {
     173        Id = source.ResourceId,
     174        ParentResourceId = source.ParentResourceId,
    150175        Cores = source.Cores,
    151         CpuSpeed = source.CpuSpeed, 
    152         FreeCores = source.FreeCores, 
    153         FreeMemory = source.FreeMemory, 
    154         IsAllowedToCalculate = source.IsAllowedToCalculate, 
    155         Memory = source.Memory, 
    156         Name = source.Name, 
    157         SlaveState = source.SlaveState, 
    158         CpuArchitecture = source.CpuArchitecture, 
     176        CpuSpeed = source.CpuSpeed,
     177        FreeCores = source.FreeCores,
     178        FreeMemory = source.FreeMemory,
     179        IsAllowedToCalculate = source.IsAllowedToCalculate,
     180        Memory = source.Memory,
     181        Name = source.Name,
     182        SlaveState = source.SlaveState,
     183        CpuArchitecture = source.CpuArchitecture,
    159184        OperatingSystem = source.OperatingSystem,
    160185        LastHeartbeat = source.LastHeartbeat
     
    170195        target.ResourceId = source.Id;
    171196        target.ParentResourceId = source.ParentResourceId;
    172         target.Cores = source.Cores; 
     197        target.Cores = source.Cores;
    173198        target.CpuSpeed = source.CpuSpeed;
    174199        target.FreeCores = source.FreeCores;
    175         target.FreeMemory = source.FreeMemory; 
     200        target.FreeMemory = source.FreeMemory;
    176201        target.IsAllowedToCalculate = source.IsAllowedToCalculate;
    177202        target.Memory = source.Memory;
    178         target.Name = source.Name; 
    179         target.SlaveState = source.SlaveState; 
    180         target.CpuArchitecture = source.CpuArchitecture; 
     203        target.Name = source.Name;
     204        target.SlaveState = source.SlaveState;
     205        target.CpuArchitecture = source.CpuArchitecture;
    181206        target.OperatingSystem = source.OperatingSystem;
    182207        target.LastHeartbeat = source.LastHeartbeat;
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs

    r5404 r5511  
    8585      using (var db = CreateContext()) {
    8686        var query = from ar in db.AssignedResources
     87                    join sl in db.StateLogs on ar.JobId equals sl.JobId
    8788                    where resourceIds.Contains(ar.ResourceId)
    88                        && ar.Job.JobState == JobState.WaitingForChildJobs
     89                       && ar.Job.State == JobState.FinishOnChildJobsFinished
    8990                       && (from child in db.Jobs
    9091                           where child.ParentJobId == ar.Job.JobId
    91                            select child.JobState == JobState.Finished).All(x => x)
     92                           select child.State == JobState.Finished).All(x => x)
    9293                       && (from child in db.Jobs // avoid returning WaitForChildJobs jobs where no child-jobs exist (yet)
    9394                           where child.ParentJobId == ar.Job.JobId
     
    107108        var query = from ar in db.AssignedResources
    108109                    where resourceIds.Contains(ar.ResourceId)
    109                        && ar.Job.JobState == JobState.Waiting
     110                       && ar.Job.State == JobState.Waiting
    110111                       && ar.Job.CoresNeeded <= slave.FreeCores
    111112                       && ar.Job.MemoryNeeded <= slave.FreeMemory
     
    197198      }
    198199    }
     200    #endregion
     201
     202    #region HiveExperimentPermission Methods
     203
     204    public DT.HiveExperimentPermission GetHiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId) {
     205      using (var db = CreateContext()) {
     206        return Convert.ToDto(db.HiveExperimentPermissions.SingleOrDefault(x => x.HiveExperimentId == hiveExperimentId && x.GrantedUserId == grantedUserId));
     207      }
     208    }
     209
     210    public IEnumerable<DT.HiveExperimentPermission> GetHiveExperimentPermissions(Expression<Func<HiveExperimentPermission, bool>> predicate) {
     211      using (var db = CreateContext()) {
     212        return db.HiveExperimentPermissions.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     213      }
     214    }
     215
     216    public void AddHiveExperimentPermission(DT.HiveExperimentPermission dto) {
     217      using (var db = CreateContext()) {
     218        var entity = Convert.ToEntity(dto);
     219        db.HiveExperimentPermissions.InsertOnSubmit(entity);
     220        db.SubmitChanges();
     221      }
     222    }
     223
     224    public void UpdateHiveExperimentPermission(DT.HiveExperimentPermission dto) {
     225      using (var db = CreateContext()) {
     226        var entity = db.HiveExperimentPermissions.FirstOrDefault(x => x.HiveExperimentId == dto.HiveExperimentId && x.GrantedUserId == dto.GrantedUserId);
     227        if (entity == null) db.HiveExperimentPermissions.InsertOnSubmit(Convert.ToEntity(dto));
     228        else Convert.ToEntity(dto, entity);
     229        db.SubmitChanges();
     230      }
     231    }
     232
     233    public void DeleteHiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId) {
     234      using (var db = CreateContext()) {
     235        var entity = db.HiveExperimentPermissions.FirstOrDefault(x => x.HiveExperimentId == hiveExperimentId && x.GrantedUserId == grantedUserId);
     236        if (entity != null) db.HiveExperimentPermissions.DeleteOnSubmit(entity);
     237        db.SubmitChanges();
     238      }
     239    }
     240
    199241    #endregion
    200242
     
    440482
    441483    #region Authorization Methods
    442     public bool IsUserAuthorizedForJobs(Guid userId, params Guid[] jobIds) {
    443       using (var db = CreateContext()) {
    444         var userIds = from job in db.Jobs // this needs to be fast!
    445                       where jobIds.Contains(job.JobId)
    446                       select job.UserId;
    447         return userIds.All(x => x == userId);
    448       }
    449     }
     484    public Permission GetPermissionForJob(Guid jobId, Guid userId) {
     485      using (var db = CreateContext()) {
     486        return GetPermissionForExperiment(GetExperimentForJob(jobId), userId);
     487      }
     488    }
     489
     490    public Permission GetPermissionForExperiment(Guid experimentId, Guid userId) {
     491      using (var db = CreateContext()) {
     492        HiveExperimentPermission permission = db.HiveExperimentPermissions.SingleOrDefault(p => p.HiveExperimentId == experimentId && p.GrantedUserId == userId);
     493        return permission != null ? permission.Permission : Permission.NotAllowed;
     494      }
     495    }
     496
     497    public Guid GetExperimentForJob(Guid jobId) {
     498      using (var db = CreateContext()) {
     499        var job = db.Jobs.SingleOrDefault(j => j.JobId == jobId);
     500        if (job.ParentJobId.HasValue) {
     501          return GetExperimentForJob(job.ParentJobId.Value);
     502        } else {
     503          return db.HiveExperiments.SingleOrDefault(he => he.RootJobId == jobId).HiveExperimentId;
     504        }
     505      }
     506    }
     507
    450508    #endregion
    451509  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.dbml

    r5405 r5511  
    3939      <Association Name="Resource_Resource" Member="ChildResources" ThisKey="ResourceId" OtherKey="ParentResourceId" Type="Resource" />
    4040      <Association Name="Resource_UptimeCalendar" Member="UptimeCalendars" ThisKey="ResourceId" OtherKey="ResourceId" Type="UptimeCalendar" />
     41      <Association Name="Resource_StateLog" Member="StateLogs" ThisKey="ResourceId" OtherKey="SlaveId" Type="StateLog" />
    4142      <Association Name="Resource_Resource" Member="ParentResource" ThisKey="ParentResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" />
    4243      <Type Name="Slave" InheritanceCode="Slave" IsInheritanceDefault="true">
     
    5253        <Column Name="OperatingSystem" Type="System.String" DbType="VarChar(MAX)" CanBeNull="false" UpdateCheck="Never" />
    5354        <Column Name="LastHeartbeat" Type="System.DateTime" DbType="DateTime" CanBeNull="true" />
    54         <Association Name="Slave_Job" Member="Jobs" ThisKey="ResourceId" OtherKey="SlaveId" Type="Job" />
    5555      </Type>
    5656      <Type Name="SlaveGroup" InheritanceCode="GROUP" />
     
    6161      <Column Name="JobId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
    6262      <Column Name="ParentJobId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" />
    63       <Column Name="JobState" Type="global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState" DbType="VarChar(15)" CanBeNull="false" />
    64       <Column Name="ResourceId" Member="SlaveId" Storage="_ResourceId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" />
    65       <Column Name="ExecutionTime" Type="System.TimeSpan" DbType="Time" CanBeNull="true" />
    66       <Column Name="Exception" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" />
    67       <Column Name="DateCreated" Type="System.DateTime" DbType="DateTime" CanBeNull="false" />
    68       <Column Name="DateCalculated" Type="System.DateTime" DbType="DateTime" CanBeNull="true" />
    69       <Column Name="DateFinished" Type="System.DateTime" DbType="DateTime" CanBeNull="true" />
     63      <Column Name="ExecutionTime" Type="System.String" DbType="VarChar(30)" CanBeNull="true" />
    7064      <Column Name="Priority" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
    71       <Column Name="ProjectId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" />
    72       <Column Name="UserId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="false" />
    7365      <Column Name="CoresNeeded" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
    7466      <Column Name="MemoryNeeded" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
    7567      <Column Name="LastHeartbeat" Type="System.DateTime" DbType="DateTime" CanBeNull="true" />
     68      <Column Name="JobState" Member="State" Type="global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState" DbType="VarChar(30)" CanBeNull="false" />
    7669      <Association Name="Job_AssignedResource" Member="AssignedResources" ThisKey="JobId" OtherKey="JobId" Type="AssignedResource" />
    7770      <Association Name="Job_RequiredPlugin" Member="RequiredPlugins" ThisKey="JobId" OtherKey="JobId" Type="RequiredPlugin" />
    7871      <Association Name="Job_Job" Member="ChildJobs" Storage="_Jobs" ThisKey="JobId" OtherKey="ParentJobId" Type="Job" />
    7972      <Association Name="Job_JobData" Member="JobData" ThisKey="JobId" OtherKey="JobId" Type="JobData" Cardinality="One" />
     73      <Association Name="Job_StateLog" Member="StateLogs" ThisKey="JobId" OtherKey="JobId" Type="StateLog" />
    8074      <Association Name="Job_Job" Member="ParentJob" Storage="_Job1" ThisKey="ParentJobId" OtherKey="JobId" Type="Job" IsForeignKey="true" />
    81       <Association Name="Slave_Job" Member="Slave" ThisKey="SlaveId" OtherKey="ResourceId" Type="Slave" IsForeignKey="true" DeleteRule="SET NULL" />
    8275    </Type>
    8376  </Table>
     
    10093      <Column Name="Description" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" />
    10194      <Column Name="ResourceIds" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" />
    102       <Column Name="UserId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="false" />
     95      <Column Name="OwnerUserId" Storage="_UserId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="false" />
    10396      <Column Name="RootJobId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="false" />
    10497      <Column Name="DateCreated" Type="System.DateTime" DbType="DateTime" CanBeNull="false" />
     98      <Column Name="LastAccessed" Type="System.DateTime" DbType="DateTime" CanBeNull="true" />
     99      <Column Name="IsHiveEngine" Type="System.Boolean" DbType="Bit" CanBeNull="false" />
     100      <Association Name="HiveExperiment_HiveExperimentPermission" Member="HiveExperimentPermissions" ThisKey="HiveExperimentId" OtherKey="HiveExperimentId" Type="HiveExperimentPermission" />
    105101      <Association Name="Job_HiveExperiment" Member="RootJob" Storage="_Job" ThisKey="RootJobId" OtherKey="JobId" Type="Job" IsForeignKey="true" DeleteRule="CASCADE" />
    106102    </Type>
    107103  </Table>
    108   <Table Name="" Member="JobDatas">
     104  <Table Name="dbo.JobData" Member="JobDatas">
    109105    <Type Name="JobData">
    110106      <Column Name="JobId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
     
    114110    </Type>
    115111  </Table>
    116   <Table Name="" Member="PluginDatas">
     112  <Table Name="dbo.PluginData" Member="PluginDatas">
    117113    <Type Name="PluginData">
    118114      <Column Name="PluginDataId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
     
    123119    </Type>
    124120  </Table>
     121  <Table Name="dbo.StateLog" Member="StateLogs">
     122    <Type Name="StateLog">
     123      <Column Name="StateLogId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
     124      <Column Name="State" Type="global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState" DbType="VarChar(30) NOT NULL" CanBeNull="false" />
     125      <Column Name="DateTime" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
     126      <Column Name="JobId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" CanBeNull="false" />
     127      <Column Name="UserId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" />
     128      <Column Name="SlaveId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" />
     129      <Column Name="Exception" Type="System.String" DbType="VarChar(MAX)" CanBeNull="false" />
     130      <Association Name="Job_StateLog" Member="Job" ThisKey="JobId" OtherKey="JobId" Type="Job" IsForeignKey="true" />
     131      <Association Name="Resource_StateLog" Member="Resource" ThisKey="SlaveId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" />
     132    </Type>
     133  </Table>
     134  <Table Name="dbo.HiveExperimentPermission" Member="HiveExperimentPermissions">
     135    <Type Name="HiveExperimentPermission">
     136      <Column Name="HiveExperimentId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
     137      <Column Name="GrantedUserId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
     138      <Column Name="GrantedByUserId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" CanBeNull="false" />
     139      <Column Name="Permission" Type="global::HeuristicLab.Services.Hive.Common.DataTransfer.Permission" DbType="VarChar(15) NOT NULL" CanBeNull="false" />
     140      <Association Name="HiveExperiment_HiveExperimentPermission" Member="HiveExperiment" ThisKey="HiveExperimentId" OtherKey="HiveExperimentId" Type="HiveExperiment" IsForeignKey="true" />
     141    </Type>
     142  </Table>
    125143</Database>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.dbml.layout

    r5405 r5511  
    33  <DataContextMoniker Name="/HiveDataContext" />
    44  <nestedChildShapes>
    5     <classShape Id="a929c9dc-69f4-4488-ba1c-a2342bf81d89" absoluteBounds="8.875, 3.75, 2, 1.3862939453124987">
     5    <classShape Id="a929c9dc-69f4-4488-ba1c-a2342bf81d89" absoluteBounds="8.875, 3.875, 2, 1.3862939453124987">
    66      <DataClassMoniker Name="/HiveDataContext/AssignedResource" />
    77      <nestedChildShapes>
    8         <elementListCompartment Id="8b005775-f0ee-41b0-ae10-6d1151003708" absoluteBounds="8.89, 4.2100000000000009, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     8        <elementListCompartment Id="8b005775-f0ee-41b0-ae10-6d1151003708" absoluteBounds="8.89, 4.3350000000000009, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    99      </nestedChildShapes>
    1010    </classShape>
    11     <classShape Id="7d998e56-4fba-41ca-a1a8-1dcdb9068edf" absoluteBounds="9, 5.5, 2, 1.9631982421874996">
     11    <classShape Id="7d998e56-4fba-41ca-a1a8-1dcdb9068edf" absoluteBounds="8.875, 5.5, 2, 1.9631982421874996">
    1212      <DataClassMoniker Name="/HiveDataContext/Plugin" />
    1313      <nestedChildShapes>
    14         <elementListCompartment Id="ec4ba325-6dff-4418-baad-59af81ae2024" absoluteBounds="9.015, 5.9600000000000009, 1.9700000000000002, 1.4031982421875" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     14        <elementListCompartment Id="ec4ba325-6dff-4418-baad-59af81ae2024" absoluteBounds="8.89, 5.9600000000000009, 1.9700000000000002, 1.4031982421875" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    1515      </nestedChildShapes>
    1616    </classShape>
     
    2727      </nestedChildShapes>
    2828    </classShape>
    29     <classShape Id="695bfc39-59f3-4e60-8644-f847964bf62c" absoluteBounds="6.5, 1, 2, 3.6939111328124996">
     29    <classShape Id="695bfc39-59f3-4e60-8644-f847964bf62c" absoluteBounds="6.5, 1, 2, 2.3478011067708335">
    3030      <DataClassMoniker Name="/HiveDataContext/Job" />
    3131      <nestedChildShapes>
    32         <elementListCompartment Id="a6a30e11-03d1-4869-82e6-b733f4ef9974" absoluteBounds="6.5150000000000006, 1.46, 1.9700000000000002, 3.1339111328125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     32        <elementListCompartment Id="a6a30e11-03d1-4869-82e6-b733f4ef9974" absoluteBounds="6.5150000000000006, 1.46, 1.9700000000000002, 1.7878011067708333" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    3333      </nestedChildShapes>
    3434    </classShape>
     
    3939      </nestedChildShapes>
    4040    </classShape>
    41     <classShape Id="e6f840cc-2968-4be1-b234-eef624ccacbb" absoluteBounds="4.125, 2.625, 2, 2.1554996744791666">
     41    <classShape Id="e6f840cc-2968-4be1-b234-eef624ccacbb" absoluteBounds="4.125, 2.625, 2, 2.5401025390624996">
    4242      <DataClassMoniker Name="/HiveDataContext/HiveExperiment" />
    4343      <nestedChildShapes>
    44         <elementListCompartment Id="0c65d4e1-256a-4a91-9a57-392f25e4de7f" absoluteBounds="4.1400000000000006, 3.0850000000000009, 1.9700000000000002, 1.5954996744791665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     44        <elementListCompartment Id="0c65d4e1-256a-4a91-9a57-392f25e4de7f" absoluteBounds="4.1400000000000006, 3.0850000000000009, 1.9700000000000002, 1.9801025390625" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    4545      </nestedChildShapes>
    4646    </classShape>
     
    6969      </nodes>
    7070    </inheritanceConnector>
    71     <associationConnector edgePoints="[(11.9843735 : 2.57859537760417); (11.9843735 : 4.44314697265625); (10.875 : 4.44314697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     71    <associationConnector edgePoints="[(11.9843735 : 2.57859537760417); (11.9843735 : 4.56814697265625); (10.875 : 4.56814697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    7272      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_AssignedResource" />
    7373      <nodes>
     
    7676      </nodes>
    7777    </associationConnector>
    78     <associationConnector edgePoints="[(8.5 : 4.22195556640625); (8.875 : 4.22195556640625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     78    <associationConnector edgePoints="[(8.5 : 3.34780110677083); (8.875 : 3.875)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    7979      <AssociationMoniker Name="/HiveDataContext/Job/Job_AssignedResource" />
    8080      <nodes>
     
    8383      </nodes>
    8484    </associationConnector>
    85     <associationConnector edgePoints="[(7.0898076923077 : 4.6939111328125); (7.0898076923077 : 5.5)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     85    <associationConnector edgePoints="[(7.4687475 : 3.34780110677083); (7.4687475 : 5.5)]" fixedFrom="Algorithm" fixedTo="Algorithm">
    8686      <AssociationMoniker Name="/HiveDataContext/Job/Job_RequiredPlugin" />
    8787      <nodes>
     
    9797      </nodes>
    9898    </associationConnector>
    99     <associationConnector edgePoints="[(8.875 : 2.33735270182292); (8.5 : 2.33735270182292)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    100       <AssociationMoniker Name="/HiveDataContext/Slave/Slave_Job" />
    101       <nodes>
    102         <classShapeMoniker Id="26f4edfa-91dd-4941-a058-359f89e567a8" />
    103         <classShapeMoniker Id="695bfc39-59f3-4e60-8644-f847964bf62c" />
    104       </nodes>
    105     </associationConnector>
    10699    <associationConnector edgePoints="[(12.781252 : 2.57859537760417); (12.781252 : 3.54212367513021); (13.5 : 3.54212367513021)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    107100      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_UptimeCalendar" />
     
    111104      </nodes>
    112105    </associationConnector>
    113     <associationConnector edgePoints="[(6.5 : 3.65945556640625); (6.125 : 3.65945556640625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     106    <associationConnector edgePoints="[(6.5 : 2.98640055338542); (6.125 : 2.98640055338542)]" fixedFrom="Algorithm" fixedTo="Algorithm">
    114107      <AssociationMoniker Name="/HiveDataContext/Job/Job_HiveExperiment" />
    115108      <nodes>
     
    124117      </nestedChildShapes>
    125118    </classShape>
    126     <classShape Id="ad25bd0f-80e8-4a06-abd8-190eb678eec7" absoluteBounds="11.625, 5.5, 2, 1.5785953776041666">
     119    <classShape Id="ad25bd0f-80e8-4a06-abd8-190eb678eec7" absoluteBounds="11.25, 5.5, 2, 1.5785953776041666">
    127120      <DataClassMoniker Name="/HiveDataContext/PluginData" />
    128121      <nestedChildShapes>
    129         <elementListCompartment Id="acddb513-7de6-4bb4-8335-d6982fb2ef35" absoluteBounds="11.64, 5.9600000000000009, 1.9700000000000002, 1.0185953776041665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     122        <elementListCompartment Id="acddb513-7de6-4bb4-8335-d6982fb2ef35" absoluteBounds="11.265, 5.9600000000000009, 1.9700000000000002, 1.0185953776041665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    130123      </nestedChildShapes>
    131124    </classShape>
    132     <associationConnector edgePoints="[(11 : 6.28929768880208); (11.625 : 6.28929768880208)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     125    <associationConnector edgePoints="[(10.875 : 6.28929768880208); (11.25 : 6.28929768880208)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    133126      <AssociationMoniker Name="/HiveDataContext/Plugin/Plugin_PluginData" />
    134127      <nodes>
     
    137130      </nodes>
    138131    </associationConnector>
    139     <associationConnector edgePoints="[(6.5 : 1.69314697265625); (6.125 : 1.69314697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     132    <associationConnector edgePoints="[(6.5 : 1.69314697265625); (6.125 : 1.69314697265625)]" fixedFrom="Algorithm" fixedTo="Algorithm">
    140133      <AssociationMoniker Name="/HiveDataContext/Job/Job_JobData" />
    141134      <nodes>
     
    144137      </nodes>
    145138    </associationConnector>
    146     <associationConnector edgePoints="[(9 : 6.19314697265625); (8.5 : 6.19314697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     139    <associationConnector edgePoints="[(8.875 : 6.19314697265625); (8.5 : 6.19314697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    147140      <AssociationMoniker Name="/HiveDataContext/Plugin/Plugin_RequiredPlugin" />
    148141      <nodes>
     
    158151      </nodes>
    159152    </associationConnector>
     153    <classShape Id="00352397-340e-449a-8e23-6ddd216e8617" absoluteBounds="1.75, 1, 2, 2.1554996744791666">
     154      <DataClassMoniker Name="/HiveDataContext/StateLog" />
     155      <nestedChildShapes>
     156        <elementListCompartment Id="9a003897-deef-4bb5-b180-4c4bcdb7fadc" absoluteBounds="1.765, 1.46, 1.9700000000000002, 1.5954996744791665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     157      </nestedChildShapes>
     158    </classShape>
     159    <classShape Id="4d800dc9-1b18-469f-b02c-d4554757c5e1" absoluteBounds="1.75, 3.625, 2, 1.5785953776041666">
     160      <DataClassMoniker Name="/HiveDataContext/HiveExperimentPermission" />
     161      <nestedChildShapes>
     162        <elementListCompartment Id="dedd97d3-a9a2-45a2-9b95-d7366fb65a7f" absoluteBounds="1.765, 4.085, 1.9700000000000002, 1.0185953776041665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     163      </nestedChildShapes>
     164    </classShape>
     165    <associationConnector edgePoints="[(6.5 : 2.50564697265625); (3.75 : 2.50564697265625)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     166      <AssociationMoniker Name="/HiveDataContext/Job/Job_StateLog" />
     167      <nodes>
     168        <classShapeMoniker Id="695bfc39-59f3-4e60-8644-f847964bf62c" />
     169        <classShapeMoniker Id="00352397-340e-449a-8e23-6ddd216e8617" />
     170      </nodes>
     171    </associationConnector>
     172    <associationConnector edgePoints="[(11.25 : 1.78929768880208); (10.9375 : 1.78929768880208); (10.9375 : 0.6875); (2.75 : 0.6875); (2.75 : 1)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     173      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_StateLog" />
     174      <nodes>
     175        <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" />
     176        <classShapeMoniker Id="00352397-340e-449a-8e23-6ddd216e8617" />
     177      </nodes>
     178    </associationConnector>
     179    <associationConnector edgePoints="[(4.125 : 4.39505126953125); (3.75 : 4.39505126953125)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     180      <AssociationMoniker Name="/HiveDataContext/HiveExperiment/HiveExperiment_HiveExperimentPermission" />
     181      <nodes>
     182        <classShapeMoniker Id="e6f840cc-2968-4be1-b234-eef624ccacbb" />
     183        <classShapeMoniker Id="4d800dc9-1b18-469f-b02c-d4554757c5e1" />
     184      </nodes>
     185    </associationConnector>
    160186  </nestedChildShapes>
    161187</ordesignerObjectsDiagram>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.designer.cs

    r5405 r5511  
    5858    partial void UpdatePluginData(PluginData instance);
    5959    partial void DeletePluginData(PluginData instance);
     60    partial void InsertStateLog(StateLog instance);
     61    partial void UpdateStateLog(StateLog instance);
     62    partial void DeleteStateLog(StateLog instance);
     63    partial void InsertHiveExperimentPermission(HiveExperimentPermission instance);
     64    partial void UpdateHiveExperimentPermission(HiveExperimentPermission instance);
     65    partial void DeleteHiveExperimentPermission(HiveExperimentPermission instance);
    6066    #endregion
    6167   
     
    153159      {
    154160        return this.GetTable<PluginData>();
     161      }
     162    }
     163   
     164    public System.Data.Linq.Table<StateLog> StateLogs
     165    {
     166      get
     167      {
     168        return this.GetTable<StateLog>();
     169      }
     170    }
     171   
     172    public System.Data.Linq.Table<HiveExperimentPermission> HiveExperimentPermissions
     173    {
     174      get
     175      {
     176        return this.GetTable<HiveExperimentPermission>();
    155177      }
    156178    }
     
    788810    private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
    789811   
    790     protected System.Guid _ResourceId;
     812    private System.Guid _ResourceId;
    791813   
    792814    private string _Name;
     
    801823   
    802824    private EntitySet<UptimeCalendar> _UptimeCalendars;
     825   
     826    private EntitySet<StateLog> _StateLogs;
    803827   
    804828    private EntityRef<Resource> _ParentResource;
     
    823847      this._ChildResources = new EntitySet<Resource>(new Action<Resource>(this.attach_ChildResources), new Action<Resource>(this.detach_ChildResources));
    824848      this._UptimeCalendars = new EntitySet<UptimeCalendar>(new Action<UptimeCalendar>(this.attach_UptimeCalendars), new Action<UptimeCalendar>(this.detach_UptimeCalendars));
     849      this._StateLogs = new EntitySet<StateLog>(new Action<StateLog>(this.attach_StateLogs), new Action<StateLog>(this.detach_StateLogs));
    825850      this._ParentResource = default(EntityRef<Resource>);
    826851      OnCreated();
     
    950975    }
    951976   
     977    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_StateLog", Storage="_StateLogs", ThisKey="ResourceId", OtherKey="SlaveId")]
     978    public EntitySet<StateLog> StateLogs
     979    {
     980      get
     981      {
     982        return this._StateLogs;
     983      }
     984      set
     985      {
     986        this._StateLogs.Assign(value);
     987      }
     988    }
     989   
    952990    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_Resource", Storage="_ParentResource", ThisKey="ParentResourceId", OtherKey="ResourceId", IsForeignKey=true)]
    953991    public Resource ParentResource
     
    10351073   
    10361074    private void detach_UptimeCalendars(UptimeCalendar entity)
     1075    {
     1076      this.SendPropertyChanging();
     1077      entity.Resource = null;
     1078    }
     1079   
     1080    private void attach_StateLogs(StateLog entity)
     1081    {
     1082      this.SendPropertyChanging();
     1083      entity.Resource = this;
     1084    }
     1085   
     1086    private void detach_StateLogs(StateLog entity)
    10371087    {
    10381088      this.SendPropertyChanging();
     
    10651115   
    10661116    private System.Nullable<System.DateTime> _LastHeartbeat;
    1067    
    1068     private EntitySet<Job> _Jobs;
    10691117   
    10701118    #region Extensibility Method Definitions
     
    10981146    public Slave()
    10991147    {
    1100       this._Jobs = new EntitySet<Job>(new Action<Job>(this.attach_Jobs), new Action<Job>(this.detach_Jobs));
    11011148      OnCreated();
    11021149    }
     
    13201367        }
    13211368      }
    1322     }
    1323    
    1324     [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Slave_Job", Storage="_Jobs", ThisKey="ResourceId", OtherKey="SlaveId")]
    1325     public EntitySet<Job> Jobs
    1326     {
    1327       get
    1328       {
    1329         return this._Jobs;
    1330       }
    1331       set
    1332       {
    1333         this._Jobs.Assign(value);
    1334       }
    1335     }
    1336    
    1337     private void attach_Jobs(Job entity)
    1338     {
    1339       this.SendPropertyChanging();
    1340       entity.Slave = this;
    1341     }
    1342    
    1343     private void detach_Jobs(Job entity)
    1344     {
    1345       this.SendPropertyChanging();
    1346       entity.Slave = null;
    13471369    }
    13481370  }
     
    13731395    private System.Nullable<System.Guid> _ParentJobId;
    13741396   
    1375     private global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState _JobState;
    1376    
    1377     private System.Nullable<System.Guid> _ResourceId;
    1378    
    1379     private System.Nullable<System.TimeSpan> _ExecutionTime;
    1380    
    1381     private string _Exception;
    1382    
    1383     private System.DateTime _DateCreated;
    1384    
    1385     private System.Nullable<System.DateTime> _DateCalculated;
    1386    
    1387     private System.Nullable<System.DateTime> _DateFinished;
     1397    private string _ExecutionTime;
    13881398   
    13891399    private int _Priority;
    13901400   
    1391     private System.Nullable<System.Guid> _ProjectId;
    1392    
    1393     private System.Guid _UserId;
    1394    
    13951401    private int _CoresNeeded;
    13961402   
     
    13991405    private System.Nullable<System.DateTime> _LastHeartbeat;
    14001406   
     1407    private global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState _State;
     1408   
    14011409    private EntitySet<AssignedResource> _AssignedResources;
    14021410   
     
    14071415    private EntityRef<JobData> _JobData;
    14081416   
     1417    private EntitySet<StateLog> _StateLogs;
     1418   
    14091419    private EntityRef<Job> _Job1;
    1410    
    1411     private EntityRef<Slave> _Slave;
    14121420   
    14131421    #region Extensibility Method Definitions
     
    14191427    partial void OnParentJobIdChanging(System.Nullable<System.Guid> value);
    14201428    partial void OnParentJobIdChanged();
    1421     partial void OnJobStateChanging(global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState value);
    1422     partial void OnJobStateChanged();
    1423     partial void OnSlaveIdChanging(System.Nullable<System.Guid> value);
    1424     partial void OnSlaveIdChanged();
    1425     partial void OnExecutionTimeChanging(System.Nullable<System.TimeSpan> value);
     1429    partial void OnExecutionTimeChanging(string value);
    14261430    partial void OnExecutionTimeChanged();
    1427     partial void OnExceptionChanging(string value);
    1428     partial void OnExceptionChanged();
    1429     partial void OnDateCreatedChanging(System.DateTime value);
    1430     partial void OnDateCreatedChanged();
    1431     partial void OnDateCalculatedChanging(System.Nullable<System.DateTime> value);
    1432     partial void OnDateCalculatedChanged();
    1433     partial void OnDateFinishedChanging(System.Nullable<System.DateTime> value);
    1434     partial void OnDateFinishedChanged();
    14351431    partial void OnPriorityChanging(int value);
    14361432    partial void OnPriorityChanged();
    1437     partial void OnProjectIdChanging(System.Nullable<System.Guid> value);
    1438     partial void OnProjectIdChanged();
    1439     partial void OnUserIdChanging(System.Guid value);
    1440     partial void OnUserIdChanged();
    14411433    partial void OnCoresNeededChanging(int value);
    14421434    partial void OnCoresNeededChanged();
     
    14451437    partial void OnLastHeartbeatChanging(System.Nullable<System.DateTime> value);
    14461438    partial void OnLastHeartbeatChanged();
     1439    partial void OnStateChanging(global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState value);
     1440    partial void OnStateChanged();
    14471441    #endregion
    14481442   
     
    14531447      this._Jobs = new EntitySet<Job>(new Action<Job>(this.attach_Jobs), new Action<Job>(this.detach_Jobs));
    14541448      this._JobData = default(EntityRef<JobData>);
     1449      this._StateLogs = new EntitySet<StateLog>(new Action<StateLog>(this.attach_StateLogs), new Action<StateLog>(this.detach_StateLogs));
    14551450      this._Job1 = default(EntityRef<Job>);
    1456       this._Slave = default(EntityRef<Slave>);
    14571451      OnCreated();
    14581452    }
     
    15021496    }
    15031497   
    1504     [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_JobState", DbType="VarChar(15)", CanBeNull=false)]
    1505     public global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState JobState
    1506     {
    1507       get
    1508       {
    1509         return this._JobState;
    1510       }
    1511       set
    1512       {
    1513         if ((this._JobState != value))
    1514         {
    1515           this.OnJobStateChanging(value);
    1516           this.SendPropertyChanging();
    1517           this._JobState = value;
    1518           this.SendPropertyChanged("JobState");
    1519           this.OnJobStateChanged();
    1520         }
    1521       }
    1522     }
    1523    
    1524     [global::System.Data.Linq.Mapping.ColumnAttribute(Name="ResourceId", Storage="_ResourceId", DbType="UniqueIdentifier")]
    1525     public System.Nullable<System.Guid> SlaveId
    1526     {
    1527       get
    1528       {
    1529         return this._ResourceId;
    1530       }
    1531       set
    1532       {
    1533         if ((this._ResourceId != value))
    1534         {
    1535           this.OnSlaveIdChanging(value);
    1536           this.SendPropertyChanging();
    1537           this._ResourceId = value;
    1538           this.SendPropertyChanged("SlaveId");
    1539           this.OnSlaveIdChanged();
    1540         }
    1541       }
    1542     }
    1543    
    1544     [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ExecutionTime", DbType="Time")]
    1545     public System.Nullable<System.TimeSpan> ExecutionTime
     1498    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ExecutionTime", DbType="VarChar(30)")]
     1499    public string ExecutionTime
    15461500    {
    15471501      get
     
    15621516    }
    15631517   
    1564     [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Exception", DbType="VarChar(MAX)")]
    1565     public string Exception
    1566     {
    1567       get
    1568       {
    1569         return this._Exception;
    1570       }
    1571       set
    1572       {
    1573         if ((this._Exception != value))
    1574         {
    1575           this.OnExceptionChanging(value);
    1576           this.SendPropertyChanging();
    1577           this._Exception = value;
    1578           this.SendPropertyChanged("Exception");
    1579           this.OnExceptionChanged();
    1580         }
    1581       }
    1582     }
    1583    
    1584     [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_DateCreated", DbType="DateTime")]
    1585     public System.DateTime DateCreated
    1586     {
    1587       get
    1588       {
    1589         return this._DateCreated;
    1590       }
    1591       set
    1592       {
    1593         if ((this._DateCreated != value))
    1594         {
    1595           this.OnDateCreatedChanging(value);
    1596           this.SendPropertyChanging();
    1597           this._DateCreated = value;
    1598           this.SendPropertyChanged("DateCreated");
    1599           this.OnDateCreatedChanged();
    1600         }
    1601       }
    1602     }
    1603    
    1604     [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_DateCalculated", DbType="DateTime")]
    1605     public System.Nullable<System.DateTime> DateCalculated
    1606     {
    1607       get
    1608       {
    1609         return this._DateCalculated;
    1610       }
    1611       set
    1612       {
    1613         if ((this._DateCalculated != value))
    1614         {
    1615           this.OnDateCalculatedChanging(value);
    1616           this.SendPropertyChanging();
    1617           this._DateCalculated = value;
    1618           this.SendPropertyChanged("DateCalculated");
    1619           this.OnDateCalculatedChanged();
    1620         }
    1621       }
    1622     }
    1623    
    1624     [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_DateFinished", DbType="DateTime")]
    1625     public System.Nullable<System.DateTime> DateFinished
    1626     {
    1627       get
    1628       {
    1629         return this._DateFinished;
    1630       }
    1631       set
    1632       {
    1633         if ((this._DateFinished != value))
    1634         {
    1635           this.OnDateFinishedChanging(value);
    1636           this.SendPropertyChanging();
    1637           this._DateFinished = value;
    1638           this.SendPropertyChanged("DateFinished");
    1639           this.OnDateFinishedChanged();
    1640         }
    1641       }
    1642     }
    1643    
    16441518    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Priority", DbType="Int NOT NULL")]
    16451519    public int Priority
     
    16621536    }
    16631537   
    1664     [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ProjectId", DbType="UniqueIdentifier")]
    1665     public System.Nullable<System.Guid> ProjectId
    1666     {
    1667       get
    1668       {
    1669         return this._ProjectId;
    1670       }
    1671       set
    1672       {
    1673         if ((this._ProjectId != value))
    1674         {
    1675           this.OnProjectIdChanging(value);
    1676           this.SendPropertyChanging();
    1677           this._ProjectId = value;
    1678           this.SendPropertyChanged("ProjectId");
    1679           this.OnProjectIdChanged();
    1680         }
    1681       }
    1682     }
    1683    
    1684     [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="UniqueIdentifier")]
    1685     public System.Guid UserId
    1686     {
    1687       get
    1688       {
    1689         return this._UserId;
    1690       }
    1691       set
    1692       {
    1693         if ((this._UserId != value))
    1694         {
    1695           this.OnUserIdChanging(value);
    1696           this.SendPropertyChanging();
    1697           this._UserId = value;
    1698           this.SendPropertyChanged("UserId");
    1699           this.OnUserIdChanged();
    1700         }
    1701       }
    1702     }
    1703    
    17041538    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CoresNeeded", DbType="Int NOT NULL")]
    17051539    public int CoresNeeded
     
    17621596    }
    17631597   
     1598    [global::System.Data.Linq.Mapping.ColumnAttribute(Name="JobState", Storage="_State", DbType="VarChar(30)", CanBeNull=false)]
     1599    public global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState State
     1600    {
     1601      get
     1602      {
     1603        return this._State;
     1604      }
     1605      set
     1606      {
     1607        if ((this._State != value))
     1608        {
     1609          this.OnStateChanging(value);
     1610          this.SendPropertyChanging();
     1611          this._State = value;
     1612          this.SendPropertyChanged("State");
     1613          this.OnStateChanged();
     1614        }
     1615      }
     1616    }
     1617   
    17641618    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedResource", Storage="_AssignedResources", ThisKey="JobId", OtherKey="JobId")]
    17651619    public EntitySet<AssignedResource> AssignedResources
     
    18301684    }
    18311685   
     1686    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_StateLog", Storage="_StateLogs", ThisKey="JobId", OtherKey="JobId")]
     1687    public EntitySet<StateLog> StateLogs
     1688    {
     1689      get
     1690      {
     1691        return this._StateLogs;
     1692      }
     1693      set
     1694      {
     1695        this._StateLogs.Assign(value);
     1696      }
     1697    }
     1698   
    18321699    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_Job", Storage="_Job1", ThisKey="ParentJobId", OtherKey="JobId", IsForeignKey=true)]
    18331700    public Job ParentJob
     
    18641731    }
    18651732   
    1866     [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Slave_Job", Storage="_Slave", ThisKey="SlaveId", OtherKey="ResourceId", IsForeignKey=true, DeleteRule="SET NULL")]
    1867     public Slave Slave
    1868     {
    1869       get
    1870       {
    1871         return this._Slave.Entity;
    1872       }
    1873       set
    1874       {
    1875         Slave previousValue = this._Slave.Entity;
    1876         if (((previousValue != value)
    1877               || (this._Slave.HasLoadedOrAssignedValue == false)))
    1878         {
    1879           this.SendPropertyChanging();
    1880           if ((previousValue != null))
    1881           {
    1882             this._Slave.Entity = null;
    1883             previousValue.Jobs.Remove(this);
    1884           }
    1885           this._Slave.Entity = value;
    1886           if ((value != null))
    1887           {
    1888             value.Jobs.Add(this);
    1889             this._ResourceId = value.ResourceId;
    1890           }
    1891           else
    1892           {
    1893             this._ResourceId = default(Nullable<System.Guid>);
    1894           }
    1895           this.SendPropertyChanged("Slave");
    1896         }
    1897       }
    1898     }
    1899    
    19001733    public event PropertyChangingEventHandler PropertyChanging;
    19011734   
     
    19521785      this.SendPropertyChanging();
    19531786      entity.ParentJob = null;
     1787    }
     1788   
     1789    private void attach_StateLogs(StateLog entity)
     1790    {
     1791      this.SendPropertyChanging();
     1792      entity.Job = this;
     1793    }
     1794   
     1795    private void detach_StateLogs(StateLog entity)
     1796    {
     1797      this.SendPropertyChanging();
     1798      entity.Job = null;
    19541799    }
    19551800  }
     
    22222067    private System.DateTime _DateCreated;
    22232068   
     2069    private System.Nullable<System.DateTime> _LastAccessed;
     2070   
     2071    private bool _IsHiveEngine;
     2072   
     2073    private EntitySet<HiveExperimentPermission> _HiveExperimentPermissions;
     2074   
    22242075    private EntityRef<Job> _Job;
    22252076   
     
    22362087    partial void OnResourceIdsChanging(string value);
    22372088    partial void OnResourceIdsChanged();
    2238     partial void OnUserIdChanging(System.Guid value);
    2239     partial void OnUserIdChanged();
     2089    partial void OnOwnerUserIdChanging(System.Guid value);
     2090    partial void OnOwnerUserIdChanged();
    22402091    partial void OnRootJobIdChanging(System.Guid value);
    22412092    partial void OnRootJobIdChanged();
    22422093    partial void OnDateCreatedChanging(System.DateTime value);
    22432094    partial void OnDateCreatedChanged();
     2095    partial void OnLastAccessedChanging(System.Nullable<System.DateTime> value);
     2096    partial void OnLastAccessedChanged();
     2097    partial void OnIsHiveEngineChanging(bool value);
     2098    partial void OnIsHiveEngineChanged();
    22442099    #endregion
    22452100   
    22462101    public HiveExperiment()
    22472102    {
     2103      this._HiveExperimentPermissions = new EntitySet<HiveExperimentPermission>(new Action<HiveExperimentPermission>(this.attach_HiveExperimentPermissions), new Action<HiveExperimentPermission>(this.detach_HiveExperimentPermissions));
    22482104      this._Job = default(EntityRef<Job>);
    22492105      OnCreated();
     
    23312187   
    23322188    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="UniqueIdentifier")]
    2333     public System.Guid UserId
     2189    public System.Guid OwnerUserId
    23342190    {
    23352191      get
     
    23412197        if ((this._UserId != value))
    23422198        {
    2343           this.OnUserIdChanging(value);
     2199          this.OnOwnerUserIdChanging(value);
    23442200          this.SendPropertyChanging();
    23452201          this._UserId = value;
    2346           this.SendPropertyChanged("UserId");
    2347           this.OnUserIdChanged();
     2202          this.SendPropertyChanged("OwnerUserId");
     2203          this.OnOwnerUserIdChanged();
    23482204        }
    23492205      }
     
    23942250    }
    23952251   
     2252    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_LastAccessed", DbType="DateTime")]
     2253    public System.Nullable<System.DateTime> LastAccessed
     2254    {
     2255      get
     2256      {
     2257        return this._LastAccessed;
     2258      }
     2259      set
     2260      {
     2261        if ((this._LastAccessed != value))
     2262        {
     2263          this.OnLastAccessedChanging(value);
     2264          this.SendPropertyChanging();
     2265          this._LastAccessed = value;
     2266          this.SendPropertyChanged("LastAccessed");
     2267          this.OnLastAccessedChanged();
     2268        }
     2269      }
     2270    }
     2271   
     2272    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IsHiveEngine", DbType="Bit")]
     2273    public bool IsHiveEngine
     2274    {
     2275      get
     2276      {
     2277        return this._IsHiveEngine;
     2278      }
     2279      set
     2280      {
     2281        if ((this._IsHiveEngine != value))
     2282        {
     2283          this.OnIsHiveEngineChanging(value);
     2284          this.SendPropertyChanging();
     2285          this._IsHiveEngine = value;
     2286          this.SendPropertyChanged("IsHiveEngine");
     2287          this.OnIsHiveEngineChanged();
     2288        }
     2289      }
     2290    }
     2291   
     2292    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="HiveExperiment_HiveExperimentPermission", Storage="_HiveExperimentPermissions", ThisKey="HiveExperimentId", OtherKey="HiveExperimentId")]
     2293    public EntitySet<HiveExperimentPermission> HiveExperimentPermissions
     2294    {
     2295      get
     2296      {
     2297        return this._HiveExperimentPermissions;
     2298      }
     2299      set
     2300      {
     2301        this._HiveExperimentPermissions.Assign(value);
     2302      }
     2303    }
     2304   
    23962305    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_HiveExperiment", Storage="_Job", ThisKey="RootJobId", OtherKey="JobId", IsForeignKey=true, DeleteRule="CASCADE")]
    23972306    public Job RootJob
     
    24312340      }
    24322341    }
     2342   
     2343    private void attach_HiveExperimentPermissions(HiveExperimentPermission entity)
     2344    {
     2345      this.SendPropertyChanging();
     2346      entity.HiveExperiment = this;
     2347    }
     2348   
     2349    private void detach_HiveExperimentPermissions(HiveExperimentPermission entity)
     2350    {
     2351      this.SendPropertyChanging();
     2352      entity.HiveExperiment = null;
     2353    }
    24332354  }
    24342355 
    2435   [global::System.Data.Linq.Mapping.TableAttribute(Name="")]
     2356  [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.JobData")]
    24362357  public partial class JobData : INotifyPropertyChanging, INotifyPropertyChanged
    24372358  {
     
    25842505  }
    25852506 
    2586   [global::System.Data.Linq.Mapping.TableAttribute(Name="")]
     2507  [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.PluginData")]
    25872508  public partial class PluginData : INotifyPropertyChanging, INotifyPropertyChanged
    25882509  {
     
    27582679    }
    27592680  }
     2681 
     2682  [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.StateLog")]
     2683  public partial class StateLog : INotifyPropertyChanging, INotifyPropertyChanged
     2684  {
     2685   
     2686    private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
     2687   
     2688    private System.Guid _StateLogId;
     2689   
     2690    private global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState _State;
     2691   
     2692    private System.DateTime _DateTime;
     2693   
     2694    private System.Guid _JobId;
     2695   
     2696    private System.Nullable<System.Guid> _UserId;
     2697   
     2698    private System.Nullable<System.Guid> _SlaveId;
     2699   
     2700    private string _Exception;
     2701   
     2702    private EntityRef<Job> _Job;
     2703   
     2704    private EntityRef<Resource> _Resource;
     2705   
     2706    #region Extensibility Method Definitions
     2707    partial void OnLoaded();
     2708    partial void OnValidate(System.Data.Linq.ChangeAction action);
     2709    partial void OnCreated();
     2710    partial void OnStateLogIdChanging(System.Guid value);
     2711    partial void OnStateLogIdChanged();
     2712    partial void OnStateChanging(global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState value);
     2713    partial void OnStateChanged();
     2714    partial void OnDateTimeChanging(System.DateTime value);
     2715    partial void OnDateTimeChanged();
     2716    partial void OnJobIdChanging(System.Guid value);
     2717    partial void OnJobIdChanged();
     2718    partial void OnUserIdChanging(System.Nullable<System.Guid> value);
     2719    partial void OnUserIdChanged();
     2720    partial void OnSlaveIdChanging(System.Nullable<System.Guid> value);
     2721    partial void OnSlaveIdChanged();
     2722    partial void OnExceptionChanging(string value);
     2723    partial void OnExceptionChanged();
     2724    #endregion
     2725   
     2726    public StateLog()
     2727    {
     2728      this._Job = default(EntityRef<Job>);
     2729      this._Resource = default(EntityRef<Resource>);
     2730      OnCreated();
     2731    }
     2732   
     2733    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_StateLogId", AutoSync=AutoSync.OnInsert, DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true, IsDbGenerated=true)]
     2734    public System.Guid StateLogId
     2735    {
     2736      get
     2737      {
     2738        return this._StateLogId;
     2739      }
     2740      set
     2741      {
     2742        if ((this._StateLogId != value))
     2743        {
     2744          this.OnStateLogIdChanging(value);
     2745          this.SendPropertyChanging();
     2746          this._StateLogId = value;
     2747          this.SendPropertyChanged("StateLogId");
     2748          this.OnStateLogIdChanged();
     2749        }
     2750      }
     2751    }
     2752   
     2753    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_State", DbType="VarChar(30) NOT NULL", CanBeNull=false)]
     2754    public global::HeuristicLab.Services.Hive.Common.DataTransfer.JobState State
     2755    {
     2756      get
     2757      {
     2758        return this._State;
     2759      }
     2760      set
     2761      {
     2762        if ((this._State != value))
     2763        {
     2764          this.OnStateChanging(value);
     2765          this.SendPropertyChanging();
     2766          this._State = value;
     2767          this.SendPropertyChanged("State");
     2768          this.OnStateChanged();
     2769        }
     2770      }
     2771    }
     2772   
     2773    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_DateTime", DbType="DateTime NOT NULL")]
     2774    public System.DateTime DateTime
     2775    {
     2776      get
     2777      {
     2778        return this._DateTime;
     2779      }
     2780      set
     2781      {
     2782        if ((this._DateTime != value))
     2783        {
     2784          this.OnDateTimeChanging(value);
     2785          this.SendPropertyChanging();
     2786          this._DateTime = value;
     2787          this.SendPropertyChanged("DateTime");
     2788          this.OnDateTimeChanged();
     2789        }
     2790      }
     2791    }
     2792   
     2793    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_JobId", DbType="UniqueIdentifier NOT NULL")]
     2794    public System.Guid JobId
     2795    {
     2796      get
     2797      {
     2798        return this._JobId;
     2799      }
     2800      set
     2801      {
     2802        if ((this._JobId != value))
     2803        {
     2804          if (this._Job.HasLoadedOrAssignedValue)
     2805          {
     2806            throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
     2807          }
     2808          this.OnJobIdChanging(value);
     2809          this.SendPropertyChanging();
     2810          this._JobId = value;
     2811          this.SendPropertyChanged("JobId");
     2812          this.OnJobIdChanged();
     2813        }
     2814      }
     2815    }
     2816   
     2817    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="UniqueIdentifier")]
     2818    public System.Nullable<System.Guid> UserId
     2819    {
     2820      get
     2821      {
     2822        return this._UserId;
     2823      }
     2824      set
     2825      {
     2826        if ((this._UserId != value))
     2827        {
     2828          this.OnUserIdChanging(value);
     2829          this.SendPropertyChanging();
     2830          this._UserId = value;
     2831          this.SendPropertyChanged("UserId");
     2832          this.OnUserIdChanged();
     2833        }
     2834      }
     2835    }
     2836   
     2837    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_SlaveId", DbType="UniqueIdentifier")]
     2838    public System.Nullable<System.Guid> SlaveId
     2839    {
     2840      get
     2841      {
     2842        return this._SlaveId;
     2843      }
     2844      set
     2845      {
     2846        if ((this._SlaveId != value))
     2847        {
     2848          if (this._Resource.HasLoadedOrAssignedValue)
     2849          {
     2850            throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
     2851          }
     2852          this.OnSlaveIdChanging(value);
     2853          this.SendPropertyChanging();
     2854          this._SlaveId = value;
     2855          this.SendPropertyChanged("SlaveId");
     2856          this.OnSlaveIdChanged();
     2857        }
     2858      }
     2859    }
     2860   
     2861    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Exception", DbType="VarChar(MAX)", CanBeNull=false)]
     2862    public string Exception
     2863    {
     2864      get
     2865      {
     2866        return this._Exception;
     2867      }
     2868      set
     2869      {
     2870        if ((this._Exception != value))
     2871        {
     2872          this.OnExceptionChanging(value);
     2873          this.SendPropertyChanging();
     2874          this._Exception = value;
     2875          this.SendPropertyChanged("Exception");
     2876          this.OnExceptionChanged();
     2877        }
     2878      }
     2879    }
     2880   
     2881    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_StateLog", Storage="_Job", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true)]
     2882    public Job Job
     2883    {
     2884      get
     2885      {
     2886        return this._Job.Entity;
     2887      }
     2888      set
     2889      {
     2890        Job previousValue = this._Job.Entity;
     2891        if (((previousValue != value)
     2892              || (this._Job.HasLoadedOrAssignedValue == false)))
     2893        {
     2894          this.SendPropertyChanging();
     2895          if ((previousValue != null))
     2896          {
     2897            this._Job.Entity = null;
     2898            previousValue.StateLogs.Remove(this);
     2899          }
     2900          this._Job.Entity = value;
     2901          if ((value != null))
     2902          {
     2903            value.StateLogs.Add(this);
     2904            this._JobId = value.JobId;
     2905          }
     2906          else
     2907          {
     2908            this._JobId = default(System.Guid);
     2909          }
     2910          this.SendPropertyChanged("Job");
     2911        }
     2912      }
     2913    }
     2914   
     2915    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_StateLog", Storage="_Resource", ThisKey="SlaveId", OtherKey="ResourceId", IsForeignKey=true)]
     2916    public Resource Resource
     2917    {
     2918      get
     2919      {
     2920        return this._Resource.Entity;
     2921      }
     2922      set
     2923      {
     2924        Resource previousValue = this._Resource.Entity;
     2925        if (((previousValue != value)
     2926              || (this._Resource.HasLoadedOrAssignedValue == false)))
     2927        {
     2928          this.SendPropertyChanging();
     2929          if ((previousValue != null))
     2930          {
     2931            this._Resource.Entity = null;
     2932            previousValue.StateLogs.Remove(this);
     2933          }
     2934          this._Resource.Entity = value;
     2935          if ((value != null))
     2936          {
     2937            value.StateLogs.Add(this);
     2938            this._SlaveId = value.ResourceId;
     2939          }
     2940          else
     2941          {
     2942            this._SlaveId = default(Nullable<System.Guid>);
     2943          }
     2944          this.SendPropertyChanged("Resource");
     2945        }
     2946      }
     2947    }
     2948   
     2949    public event PropertyChangingEventHandler PropertyChanging;
     2950   
     2951    public event PropertyChangedEventHandler PropertyChanged;
     2952   
     2953    protected virtual void SendPropertyChanging()
     2954    {
     2955      if ((this.PropertyChanging != null))
     2956      {
     2957        this.PropertyChanging(this, emptyChangingEventArgs);
     2958      }
     2959    }
     2960   
     2961    protected virtual void SendPropertyChanged(String propertyName)
     2962    {
     2963      if ((this.PropertyChanged != null))
     2964      {
     2965        this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     2966      }
     2967    }
     2968  }
     2969 
     2970  [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.HiveExperimentPermission")]
     2971  public partial class HiveExperimentPermission : INotifyPropertyChanging, INotifyPropertyChanged
     2972  {
     2973   
     2974    private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
     2975   
     2976    private System.Guid _HiveExperimentId;
     2977   
     2978    private System.Guid _GrantedUserId;
     2979   
     2980    private System.Guid _GrantedByUserId;
     2981   
     2982    private global::HeuristicLab.Services.Hive.Common.DataTransfer.Permission _Permission;
     2983   
     2984    private EntityRef<HiveExperiment> _HiveExperiment;
     2985   
     2986    #region Extensibility Method Definitions
     2987    partial void OnLoaded();
     2988    partial void OnValidate(System.Data.Linq.ChangeAction action);
     2989    partial void OnCreated();
     2990    partial void OnHiveExperimentIdChanging(System.Guid value);
     2991    partial void OnHiveExperimentIdChanged();
     2992    partial void OnGrantedUserIdChanging(System.Guid value);
     2993    partial void OnGrantedUserIdChanged();
     2994    partial void OnGrantedByUserIdChanging(System.Guid value);
     2995    partial void OnGrantedByUserIdChanged();
     2996    partial void OnPermissionChanging(global::HeuristicLab.Services.Hive.Common.DataTransfer.Permission value);
     2997    partial void OnPermissionChanged();
     2998    #endregion
     2999   
     3000    public HiveExperimentPermission()
     3001    {
     3002      this._HiveExperiment = default(EntityRef<HiveExperiment>);
     3003      OnCreated();
     3004    }
     3005   
     3006    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_HiveExperimentId", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true)]
     3007    public System.Guid HiveExperimentId
     3008    {
     3009      get
     3010      {
     3011        return this._HiveExperimentId;
     3012      }
     3013      set
     3014      {
     3015        if ((this._HiveExperimentId != value))
     3016        {
     3017          if (this._HiveExperiment.HasLoadedOrAssignedValue)
     3018          {
     3019            throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
     3020          }
     3021          this.OnHiveExperimentIdChanging(value);
     3022          this.SendPropertyChanging();
     3023          this._HiveExperimentId = value;
     3024          this.SendPropertyChanged("HiveExperimentId");
     3025          this.OnHiveExperimentIdChanged();
     3026        }
     3027      }
     3028    }
     3029   
     3030    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_GrantedUserId", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true)]
     3031    public System.Guid GrantedUserId
     3032    {
     3033      get
     3034      {
     3035        return this._GrantedUserId;
     3036      }
     3037      set
     3038      {
     3039        if ((this._GrantedUserId != value))
     3040        {
     3041          this.OnGrantedUserIdChanging(value);
     3042          this.SendPropertyChanging();
     3043          this._GrantedUserId = value;
     3044          this.SendPropertyChanged("GrantedUserId");
     3045          this.OnGrantedUserIdChanged();
     3046        }
     3047      }
     3048    }
     3049   
     3050    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_GrantedByUserId", DbType="UniqueIdentifier NOT NULL")]
     3051    public System.Guid GrantedByUserId
     3052    {
     3053      get
     3054      {
     3055        return this._GrantedByUserId;
     3056      }
     3057      set
     3058      {
     3059        if ((this._GrantedByUserId != value))
     3060        {
     3061          this.OnGrantedByUserIdChanging(value);
     3062          this.SendPropertyChanging();
     3063          this._GrantedByUserId = value;
     3064          this.SendPropertyChanged("GrantedByUserId");
     3065          this.OnGrantedByUserIdChanged();
     3066        }
     3067      }
     3068    }
     3069   
     3070    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Permission", DbType="VarChar(15) NOT NULL", CanBeNull=false)]
     3071    public global::HeuristicLab.Services.Hive.Common.DataTransfer.Permission Permission
     3072    {
     3073      get
     3074      {
     3075        return this._Permission;
     3076      }
     3077      set
     3078      {
     3079        if ((this._Permission != value))
     3080        {
     3081          this.OnPermissionChanging(value);
     3082          this.SendPropertyChanging();
     3083          this._Permission = value;
     3084          this.SendPropertyChanged("Permission");
     3085          this.OnPermissionChanged();
     3086        }
     3087      }
     3088    }
     3089   
     3090    [global::System.Data.Linq.Mapping.AssociationAttribute(Name="HiveExperiment_HiveExperimentPermission", Storage="_HiveExperiment", ThisKey="HiveExperimentId", OtherKey="HiveExperimentId", IsForeignKey=true)]
     3091    public HiveExperiment HiveExperiment
     3092    {
     3093      get
     3094      {
     3095        return this._HiveExperiment.Entity;
     3096      }
     3097      set
     3098      {
     3099        HiveExperiment previousValue = this._HiveExperiment.Entity;
     3100        if (((previousValue != value)
     3101              || (this._HiveExperiment.HasLoadedOrAssignedValue == false)))
     3102        {
     3103          this.SendPropertyChanging();
     3104          if ((previousValue != null))
     3105          {
     3106            this._HiveExperiment.Entity = null;
     3107            previousValue.HiveExperimentPermissions.Remove(this);
     3108          }
     3109          this._HiveExperiment.Entity = value;
     3110          if ((value != null))
     3111          {
     3112            value.HiveExperimentPermissions.Add(this);
     3113            this._HiveExperimentId = value.HiveExperimentId;
     3114          }
     3115          else
     3116          {
     3117            this._HiveExperimentId = default(System.Guid);
     3118          }
     3119          this.SendPropertyChanged("HiveExperiment");
     3120        }
     3121      }
     3122    }
     3123   
     3124    public event PropertyChangingEventHandler PropertyChanging;
     3125   
     3126    public event PropertyChangedEventHandler PropertyChanged;
     3127   
     3128    protected virtual void SendPropertyChanging()
     3129    {
     3130      if ((this.PropertyChanging != null))
     3131      {
     3132        this.PropertyChanging(this, emptyChangingEventArgs);
     3133      }
     3134    }
     3135   
     3136    protected virtual void SendPropertyChanged(String propertyName)
     3137    {
     3138      if ((this.PropertyChanged != null))
     3139      {
     3140        this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     3141      }
     3142    }
     3143  }
    27603144}
    27613145#pragma warning restore 1591
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Interfaces/IHiveDao.cs

    r5404 r5511  
    11using System;
    22using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    53using System.Linq.Expressions;
    64
    75namespace HeuristicLab.Services.Hive.DataAccess {
     6  using HeuristicLab.Services.Hive.Common.DataTransfer;
    87  using DT = HeuristicLab.Services.Hive.Common.DataTransfer;
    98
     
    3231    void UpdateHiveExperiment(DT.HiveExperiment dto);
    3332    void DeleteHiveExperiment(Guid id);
     33    #endregion
     34
     35    #region HiveExperimentPermission Methods
     36    DT.HiveExperimentPermission GetHiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId);
     37    IEnumerable<DT.HiveExperimentPermission> GetHiveExperimentPermissions(Expression<Func<HiveExperimentPermission, bool>> predicate);
     38    void AddHiveExperimentPermission(DT.HiveExperimentPermission dto);
     39    void UpdateHiveExperimentPermission(DT.HiveExperimentPermission dto);
     40    void DeleteHiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId);
    3441    #endregion
    3542
     
    8087
    8188    #region Authorization Methods
    82     bool IsUserAuthorizedForJobs(Guid userId, params Guid[] jobIds);
     89    Permission GetPermissionForJob(Guid jobId, Guid userId);
     90    Permission GetPermissionForExperiment(Guid experimentId, Guid userId);
     91    Guid GetExperimentForJob(Guid jobId);
    8392    #endregion
    8493  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Tools/CreateHiveDatabaseApplication.cs

    r5106 r5511  
    2828  class CreateHiveDatabaseApplication : ApplicationBase {
    2929
    30     public override void Run() {
     30    public override void Run() { 
    3131      using (var db = HiveDao.CreateContext()) {
    3232        if (db.DatabaseExists())
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Tools/prepareHiveDatabase.sql

    r5404 r5511  
    4040ALTER TABLE dbo.Job ALTER COLUMN JobId ADD ROWGUIDCOL;
    4141ALTER TABLE dbo.Job WITH NOCHECK ADD CONSTRAINT [DF_Job_JobId] DEFAULT (newid()) FOR JobId;
     42GO
    4243
    43 --ALTER TABLE [dbo].[Job]  DROP  CONSTRAINT [Slave_Job]
    44 --ALTER TABLE [dbo].[Job]  WITH CHECK ADD  CONSTRAINT [Slave_Job] FOREIGN KEY([ResourceId])
    45 --REFERENCES [dbo].[Resource] ([ResourceId])
    46 --ON UPDATE CASCADE
    47 --ON DELETE SET NULL
    48 --GO
     44ALTER TABLE [dbo].[StateLog]  DROP  CONSTRAINT [Job_StateLog]
     45ALTER TABLE [dbo].[StateLog]  WITH CHECK ADD CONSTRAINT [Job_StateLog] FOREIGN KEY([JobId])
     46REFERENCES [dbo].[Job] ([JobId])
     47ON UPDATE CASCADE
     48ON DELETE CASCADE
     49GO
    4950
    5051ALTER TABLE dbo.Plugin ALTER COLUMN PluginId ADD ROWGUIDCOL;
     
    7980ALTER TABLE dbo.HiveExperiment ALTER COLUMN HiveExperimentId ADD ROWGUIDCOL;
    8081ALTER TABLE dbo.HiveExperiment WITH NOCHECK ADD CONSTRAINT [DF_HiveExperiment_HiveExperimentId] DEFAULT (newid()) FOR HiveExperimentId;
     82
     83ALTER TABLE dbo.StateLog ALTER COLUMN StateLogId ADD ROWGUIDCOL;
     84ALTER TABLE dbo.StateLog WITH NOCHECK ADD CONSTRAINT [DF_StateLog_StateLogId] DEFAULT (newid()) FOR StateLogId;
     85
     86ALTER TABLE [dbo].[HiveExperimentPermission]  DROP  CONSTRAINT [HiveExperiment_HiveExperimentPermission]
     87ALTER TABLE [dbo].[HiveExperimentPermission]  WITH CHECK ADD CONSTRAINT [HiveExperiment_HiveExperimentPermission] FOREIGN KEY([HiveExperimentId])
     88REFERENCES [dbo].[HiveExperiment] ([HiveExperimentId])
     89ON UPDATE CASCADE
     90ON DELETE CASCADE
     91GO
    8192
    8293/* create indices */
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/DaoTests.cs

    r5405 r5511  
    11using System;
    2 using System.Text;
    3 using System.Collections.Generic;
    42using System.Linq;
    5 using Microsoft.VisualStudio.TestTools.UnitTesting;
    63using HeuristicLab.Services.Hive.Common.DataTransfer;
    74using HeuristicLab.Services.Hive.Common.ServiceContracts;
    8 using HeuristicLab.Clients.Hive.Slave.Tests;
    9 using HeuristicLab.Clients.Hive;
    105using HeuristicLab.Services.Hive.DataAccess;
     6using Microsoft.VisualStudio.TestTools.UnitTesting;
    117
    128namespace HeuristicLab.Services.Hive.Tests {
    13   using DA = HeuristicLab.Services.Hive.DataAccess;
    149  using DT = HeuristicLab.Services.Hive.Common.DataTransfer;
    1510
     
    3227     
    3328      DT.Job job1 = new DT.Job();
    34       job1.DateCreated = DateTime.Now;
     29      job1.SetState(JobState.Offline, Guid.NewGuid());
    3530
    3631      DT.Plugin plugin1 = new DT.Plugin();
     
    5752      Assert.AreEqual(job1.Id, job1loaded.Id);
    5853      Assert.AreEqual(job1.CoresNeeded, job1loaded.CoresNeeded);
    59       Assert.AreEqual(null, job1loaded.DateCalculated);
    6054      Assert.AreEqual(job1.DateCreated.ToString(), job1loaded.DateCreated.ToString());
    6155      Assert.AreEqual(null, job1loaded.DateFinished);
    6256      Assert.IsTrue(job1.PluginsNeededIds.SequenceEqual(job1loaded.PluginsNeededIds));
    63      
     57      Assert.AreEqual(job1.StateLog.Count, job1loaded.StateLog.Count);
     58      for (int i = 0; i < job1.StateLog.Count; i++) {
     59        Assert.AreEqual(job1.Id, job1loaded.StateLog[i].JobId);
     60        Assert.AreEqual(job1.StateLog[i].State, job1loaded.StateLog[i].State);
     61        Assert.AreEqual(job1.StateLog[i].SlaveId, job1loaded.StateLog[i].SlaveId);
     62        Assert.AreEqual(job1.StateLog[i].UserId, job1loaded.StateLog[i].UserId);
     63        Assert.AreEqual(job1.StateLog[i].Exception, job1loaded.StateLog[i].Exception);
     64        Assert.IsTrue(Math.Abs((job1.StateLog[i].DateTime - job1loaded.StateLog[i].DateTime).TotalSeconds) < 1);
     65      }
     66
    6467      dao.DeleteJob(job1.Id);
    6568
     
    9699      dao.DeleteSlave(slave.Id);
    97100      dao.DeleteSlaveGroup(slaveGroup.Id);
    98     }
    99 
    100     [TestMethod]
    101     public void TestJobDaoWaiting() {
    102       IHiveDao dao = ServiceLocator.Instance.HiveDao;
    103 
    104       DT.Job job = new DT.Job();
    105       job.DateCreated = DateTime.Now;
    106       job.JobState = JobState.Waiting;
    107       job.Id = dao.AddJob(job);
    108 
    109       // todo
    110101    }
    111102
     
    152143    }
    153144
     145    [TestMethod]
     146    public void TestHiveExperimentDao() {
     147      IHiveDao dao = ServiceLocator.Instance.HiveDao;
     148
     149      DT.HiveExperiment he = new DT.HiveExperiment();
     150
     151      DT.Job job = new DT.Job();
     152      job.SetState(JobState.Offline, Guid.NewGuid());
     153      job.Id = dao.AddJob(job);
     154
     155      he.RootJobId = job.Id;
     156      he.DateCreated = DateTime.Now;
     157      he.Name = "TestExperiment";
     158      he.OwnerUserId = Guid.NewGuid();
     159      he.ResourceNames = "HEAL";
     160
     161      he.Id = dao.AddHiveExperiment(he);
     162
     163      DT.HiveExperimentPermission perm = new DT.HiveExperimentPermission();
     164      perm.HiveExperimentId = he.Id;
     165      perm.GrantedByUserId = he.OwnerUserId;
     166      perm.GrantedUserId = Guid.NewGuid();
     167      perm.Permission = Permission.Write;
     168      dao.AddHiveExperimentPermission(perm);
     169
     170      DT.HiveExperiment heLoaded = dao.GetHiveExperiment(he.Id);
     171      Assert.AreEqual(he.Id, heLoaded.Id);
     172      Assert.AreEqual(he.Name, heLoaded.Name);
     173      Assert.AreEqual(he.ResourceNames, heLoaded.ResourceNames);
     174      Assert.AreEqual(he.RootJobId, heLoaded.RootJobId);
     175      //Assert.AreEqual(he.LastAccessed, heLoaded.LastAccessed);
     176      //Assert.AreEqual(he.DateCreated, heLoaded.DateCreated);
     177     
     178      DT.Job jobLoaded = dao.GetJob(he.RootJobId);
     179      Assert.AreEqual(job.Id, jobLoaded.Id);
     180      Assert.AreEqual(job.State, jobLoaded.State);
     181
     182      DT.HiveExperimentPermission permLoaded = dao.GetHiveExperimentPermission(he.Id, perm.GrantedUserId);
     183      Assert.AreEqual(perm.HiveExperimentId, permLoaded.HiveExperimentId);
     184      Assert.AreEqual(perm.GrantedUserId, permLoaded.GrantedUserId);
     185      Assert.AreEqual(perm.GrantedByUserId, permLoaded.GrantedByUserId);
     186      Assert.AreEqual(perm.Permission, permLoaded.Permission);
     187
     188      dao.DeleteHiveExperiment(he.Id);
     189      Assert.AreEqual(null, dao.GetHiveExperiment(he.Id));
     190      Assert.AreEqual(null, dao.GetJob(he.RootJobId));
     191      Assert.AreEqual(null, dao.GetHiveExperimentPermission(perm.HiveExperimentId, perm.GrantedUserId));
     192
     193    }
    154194  }
    155195}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/ServiceTests.cs

    r5404 r5511  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using System.Threading;
    2526using HeuristicLab.Clients.Hive;
    2627using HeuristicLab.Clients.Hive.Slave.Tests;
     28using HeuristicLab.Hive;
     29using HeuristicLab.Services.Hive.Common;
    2730using HeuristicLab.Services.Hive.Common.DataTransfer;
    2831using HeuristicLab.Services.Hive.Common.ServiceContracts;
    2932using Microsoft.VisualStudio.TestTools.UnitTesting;
    30 using System.Threading;
    31 using HeuristicLab.Hive;
    32 using HeuristicLab.Services.Hive.Common;
    3333
    3434namespace HeuristicLab.Services.Hive.Tests {
    3535
     36  using System.Diagnostics;
    3637  using DT = HeuristicLab.Services.Hive.Common.DataTransfer;
    37   using System.Diagnostics;
    3838
    3939  [TestClass]
     
    5454      var service = GetLocalService();
    5555
     56      // create hive experiment
    5657      DT.HiveExperiment experiment = new DT.HiveExperiment() {
    5758        Name = "TestExperiment",
     
    5960      };
    6061
     62      // create job
    6163      DT.Job job = new DT.Job() {
    6264        CoresNeeded = 1,
     
    6466        Priority = 0
    6567      };
     68      job.SetState(JobState.Offline);
    6669
    6770      DT.JobData jobData = new DT.JobData() {
    68         Data = PersistenceUtil.Serialize(new MockJob(500, true))
     71        //Data = PersistenceUtil.Serialize(new MockJob(500, true))
     72        Data = new byte[10000000]
    6973      };
    7074
     75      // create plugin
    7176      DT.Plugin plugin1 = new DT.Plugin();
    7277      plugin1.Name = "Tests.MyPlugin";
     
    7782
    7883      DT.PluginData pluginData1 = new DT.PluginData();
    79       pluginData1.PluginId = plugin1.Id;
    8084      pluginData1.FileName = "Tests.MyPlugin-1.0.dll";
    8185      pluginData1.Data = new byte[] { 0, 1, 2, 3, 4, 5 };
    8286
     87      plugin1.Id = service.AddPlugin(plugin1, new List<PluginData> { pluginData1 });
     88      pluginData1.PluginId = plugin1.Id;
     89
     90      // add plugin
    8391      job.PluginsNeededIds.Add(plugin1.Id);
    8492
    85       job.Id = service.AddJob(job, jobData, null);
     93      // create slave
     94      DT.Slave slave = new Slave();
     95      slave.Id = Guid.NewGuid();
     96      slave.Name = "TestSlave";
     97      slave.Memory = 1024;
     98      slave.Cores = 4;
     99      slave.CpuSpeed = 2800;
     100      slave.OperatingSystem = "Windows 3.11";
     101      slave.CpuArchitecture = CpuArchitecture.x64;
     102
     103      // add slave
     104      service.AddSlave(slave);
     105
     106      // add job
     107      job.Id = service.AddJob(job, jobData, new List<Guid> { slave.Id });
    86108      experiment.RootJobId = job.Id;
    87109
     110      // add hive experiment
     111      experiment.Id = service.AddHiveExperiment(experiment);
     112
     113      // test job
    88114      DT.Job jobLoaded = service.GetJob(job.Id);
    89115      Assert.AreEqual(job.Id, jobLoaded.Id);
     
    91117      Assert.AreEqual(job.MemoryNeeded, jobLoaded.MemoryNeeded);
    92118      Assert.AreEqual(job.Priority, jobLoaded.Priority);
    93       Assert.AreEqual(JobState.Waiting, jobLoaded.JobState);
    94       Assert.AreEqual(ServiceLocator.Instance.AuthorizationManager.UserId, job.UserId);
     119      Assert.AreEqual(JobState.Waiting, jobLoaded.State);
    95120      Assert.IsTrue(job.PluginsNeededIds.SequenceEqual(jobLoaded.PluginsNeededIds));
    96 
     121     
    97122      DT.JobData jobDataLoaded = service.GetJobData(job.Id);
    98123      Assert.AreEqual(job.Id, jobDataLoaded.JobId);
    99124      Assert.IsTrue(jobData.Data.SequenceEqual(jobDataLoaded.Data));
    100125
    101       experiment.Id = service.AddHiveExperiment(experiment);
    102 
     126      // test hive experiment
    103127      DT.HiveExperiment experimentLoaded = service.GetHiveExperiment(experiment.Id);
    104128      Assert.AreEqual(experiment.Id, experimentLoaded.Id);
     
    107131      Assert.AreEqual(experiment.RootJobId, experimentLoaded.RootJobId);
    108132
     133      // test assigned ressources
     134      var actions = service.Heartbeat(new Heartbeat() { SlaveId = slave.Id, AssignJob = true, FreeCores = 4, FreeMemory = 1024, JobProgress = new Dictionary<Guid,TimeSpan>() });
     135      Assert.AreEqual(1, actions.Count);
     136      Assert.AreEqual(MessageContainer.MessageType.CalculateJob, actions[0].Message);
     137      Assert.AreEqual(job.Id, actions[0].JobId);
     138
     139      jobLoaded = service.GetJob(job.Id);
     140      Assert.AreEqual(JobState.Transferring, jobLoaded.State);
     141
     142      // send progress
     143      var progress = new Dictionary<Guid, TimeSpan>();
     144      progress.Add(job.Id, new TimeSpan(1, 5, 10, 20, 30));
     145      actions = service.Heartbeat(new Heartbeat() { SlaveId = slave.Id, AssignJob = true, FreeCores = 3, FreeMemory = 1024, JobProgress = progress });
     146      Assert.AreEqual(0, actions.Count);
     147
     148      // the job should be in state 'Calculating' now
     149      jobLoaded = service.GetJob(job.Id);
     150      Assert.AreEqual(JobState.Calculating, jobLoaded.State);
     151      Assert.AreEqual(new TimeSpan(1, 5, 10, 20, 30), jobLoaded.ExecutionTime.Value);
     152
     153      // delete
    109154      service.DeleteHiveExperiment(experiment.Id);
    110155      Assert.AreEqual(null, service.GetHiveExperiment(experiment.Id));
    111156      Assert.AreEqual(null, service.GetJob(job.Id));
    112157      Assert.AreEqual(null, service.GetJobData(job.Id));
     158
     159      // send another heartbeat with the deleted job; the server should command the abortion of the job
     160      actions = service.Heartbeat(new Heartbeat() { SlaveId = slave.Id, AssignJob = true, FreeCores = 3, FreeMemory = 1024, JobProgress = progress });
     161      Assert.AreEqual(1, actions.Count);
     162      Assert.AreEqual(MessageContainer.MessageType.AbortJob, actions[0].Message);
     163      Assert.AreEqual(job.Id, actions[0].JobId);
     164
     165      // delete slave
     166      service.DeleteSlave(slave.Id);
    113167    }
    114168
     
    185239        Thread.Sleep(500);
    186240        lightweightJobs = service.GetLightweightJobs(jobs.Select(x => x.Id));
    187       } while (!lightweightJobs.All(x => x.JobState == JobState.Finished));
     241      } while (!lightweightJobs.All(x => x.State == JobState.Finished));
    188242
    189243      // delete slaves
     
    239293            IJob deserializedJob = PersistenceUtil.Deserialize<IJob>(jobData.Data);
    240294            deserializedJob.Start();
    241             job.JobState = JobState.Finished;
    242             jobs.Where(x => x.Id == job.Id).Single().JobState = JobState.Finished;
     295            job.SetState(JobState.Finished);
     296            jobs.Where(x => x.Id == job.Id).Single().SetState(JobState.Finished);
    243297            jobData.Data = PersistenceUtil.Serialize(deserializedJob);
    244             service.UpdateJob(job, jobData);
     298            service.UpdateJobData(job, jobData);
    245299            Debug.WriteLine("finished calculating");
    246300          }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Web/Hive-3.4/App_Code/HiveServerModule.cs

    r5405 r5511  
    2828using HeuristicLab.Services.Hive;
    2929using HeuristicLab.Tracing;
     30using HeuristicLab.Services.Hive.Common;
    3031
    3132namespace HeuristicLab.Hive.Server.Core.IISModules {
    3233  public class HiveServerModule : IHttpModule {
    33    
    3434    private static IHiveService hiveService;
    3535    private static ILifecycleManager lifecycleManager;
    3636
    3737    public void Init(HttpApplication context) {
    38       if (lifecycleManager == null)
     38      if (lifecycleManager == null) {
    3939        lifecycleManager = new LifecycleManager();
    40       lifecycleManager.Start();
     40        lifecycleManager.Start();
     41        LogFactory.GetLogger(this.GetType().Name).Log("Init(): LifecycleManager started");
     42      }
    4143    }
    4244
    4345    public void Dispose() {
    4446      lifecycleManager.Stop();
     47      lifecycleManager = null;
     48      LogFactory.GetLogger(this.GetType().Name).Log("Init(): LifecycleManager stopped");
    4549    }
    4650  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/AuthorizationManager.cs

    r5264 r5511  
    2121
    2222using System;
    23 using System.Linq;
    2423using System.Security;
    2524using System.Web.Security;
     
    3534    }
    3635
    37     public void AuthorizeJobs(params Guid[] jobIds) {
    38       if (!IsAuthorizedForJobs(jobIds)) {
    39         throw new SecurityException("User '" + Identity.UserName + "' is not authorized to access job (Id: " + string.Join(", ", jobIds.Select(x => x.ToString()).ToArray()) + ")");
    40       }
    41     }
     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    //}
    4241
    43     private bool IsAuthorizedForJobs(params Guid[] jobIds) {
    44       return ServiceLocator.Instance.HiveDao.IsUserAuthorizedForJobs(UserId, jobIds);
    45     }
     42    //private bool IsAuthorizedForJobs(params Guid[] jobIds) {
     43    //  return ServiceLocator.Instance.HiveDao.IsUserAuthorizedForJobs(UserId, jobIds);
     44    //}
    4645
    4746    public void Authorize(Guid userId) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeartbeatManager.cs

    r5405 r5511  
    22using System.Collections.Generic;
    33using System.Linq;
    4 using System.Text;
    54using HeuristicLab.Services.Hive.Common;
    65using HeuristicLab.Services.Hive.Common.DataTransfer;
     
    5453
    5554    private void AssignJob(Slave slave, Job job) {
    56       job.SlaveId = slave.Id;
    57       job.JobState = JobState.Calculating; // Todo: Maybe use State = Transferring (?)
    58       job.DateCalculated = DateTime.Now; // Todo: use statelog instead
     55      job.SetState(JobState.Transferring, slave.Id, "");
    5956      dao.UpdateJob(job);
    6057      dao.UpdateSlave(slave);
     
    7976          Logger.Error("Job does not exist in DB: " + jobProgress.Key);
    8077        } else {
    81           if (curJob.SlaveId == Guid.Empty || curJob.SlaveId != heartbeat.SlaveId) {
     78          if (curJob.CurrentStateLog.SlaveId == Guid.Empty || curJob.CurrentStateLog.SlaveId != heartbeat.SlaveId) {
    8279            // assigned slave does not match heartbeat
    8380            actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));
     
    8885            curJob.LastHeartbeat = DateTime.Now;
    8986
    90             if (curJob.JobState == JobState.Aborted) {
     87            if (curJob.State == JobState.Aborted) {
    9188              // a request to abort the job has been set
    9289              actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));
     90            } else if (curJob.State != JobState.Calculating) {
     91              // jobstate was 'Transferring' before, now calculating
     92              curJob.SetState(JobState.Calculating, heartbeat.SlaveId, "");
    9393            }
    9494            dao.UpdateJob(curJob);
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs

    r5458 r5511  
    3333    //[PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    3434    //[PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    35     public Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> slaveGroupIds) {
    36       using (trans.OpenTransaction()) {
    37         job.UserId = auth.UserId;
    38         job.DateCreated = DateTime.Now;
    39         job.JobState = JobState.Waiting;
     35    public Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> resourceIds) {
     36      using (trans.OpenTransaction()) {
     37        job.SetState(JobState.Waiting, auth.UserId);
    4038        job.Id = dao.AddJob(job);
    4139        jobData.JobId = job.Id;
    4240        jobData.LastUpdate = DateTime.Now;
    43         if (slaveGroupIds != null) {
    44           foreach (Guid slaveGroupId in slaveGroupIds) {
     41        if (resourceIds != null) {
     42          foreach (Guid slaveGroupId in resourceIds) {
    4543            dao.AssignJobToResource(job.Id, slaveGroupId);
    4644          }
     
    8078    }
    8179
    82     public void UpdateJob(Job job, JobData jobData) {
     80    public void UpdateJob(Job job) {
     81      using (trans.OpenTransaction()) {
     82        dao.UpdateJob(job);
     83      }
     84    }
     85
     86    public void UpdateJobData(Job job, JobData jobData) {
    8387      using (trans.OpenTransaction()) {
    8488        jobData.LastUpdate = DateTime.Now;
     
    122126
    123127    public HiveExperiment GetHiveExperiment(Guid id) {
    124       return dao.GetHiveExperiments(x => x.UserId == auth.UserId && x.HiveExperimentId == id).FirstOrDefault();
     128      return dao.GetHiveExperiments(x =>
     129             x.HiveExperimentId == id
     130          && (x.OwnerUserId == auth.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == auth.UserId) > 0)
     131          ).FirstOrDefault();
    125132    }
    126133
    127134    public IEnumerable<HiveExperiment> GetHiveExperiments() {
    128       return dao.GetHiveExperiments(x => x.UserId == auth.UserId);
     135      return dao.GetHiveExperiments(x => x.OwnerUserId == auth.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == auth.UserId) > 0);
    129136    }
    130137
    131138    public Guid AddHiveExperiment(HiveExperiment hiveExperimentDto) {
    132139      using (trans.OpenTransaction()) {
    133         hiveExperimentDto.UserId = auth.UserId;
     140        hiveExperimentDto.OwnerUserId = auth.UserId;
    134141        hiveExperimentDto.DateCreated = DateTime.Now;
    135142        return dao.AddHiveExperiment(hiveExperimentDto);
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Interfaces/IAuthorizationManager.cs

    r5043 r5511  
    3333    /// </summary>
    3434    /// <exception cref="SecurityException">thrown when access denied</exception>
    35     void AuthorizeJobs(params Guid[] jobId);
     35    //void AuthorizeJobs(params Guid[] jobId);
    3636
    3737    /// <summary>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/LifecycleManager.cs

    r5405 r5511  
    11using System;
    2 using System.Collections.Generic;
    32using System.Linq;
    4 using System.Text;
    5 using System.Transactions;
     3using HeuristicLab.Core;
    64using HeuristicLab.Services.Hive.Common;
    75using HeuristicLab.Services.Hive.Common.DataTransfer;
    8 using HeuristicLab.Tracing;
    9 using HeuristicLab.Core;
    106
    117namespace HeuristicLab.Services.Hive {
     
    2723
    2824    // Windows-Forms timer is single threaded, so callbacks will be synchron
    29     System.Windows.Forms.Timer timer;
     25    private System.Windows.Forms.Timer timer;
    3026
    3127    public ExecutionState ExecutionState {
     
    4036    public void Start() {
    4137      if (ExecutionState == Core.ExecutionState.Stopped) {
    42         this.timer.Interval = (int)new TimeSpan(0, 0, 10).TotalMilliseconds;
     38        this.timer.Interval = (int)new TimeSpan(0, 0, 30).TotalMilliseconds;
    4339        this.timer.Start();
    4440      }
     
    7167
    7268    private void AbortJobs(Guid slaveId) {
    73       var jobs = dao.GetJobs(x => x.Slave.ResourceId == slaveId);
     69      var jobs = dao.GetJobs(x => x.StateLogs.Last().SlaveId == slaveId);
    7470      foreach (var j in jobs) {
    75         j.JobState = JobState.Waiting;
     71        j.StateLog.Add(new StateLog() {
     72          UserId = auth.UserId,
     73          State = JobState.Waiting,
     74          JobId = j.Id,
     75          DateTime = DateTime.Now,
     76          Exception = "Slave timed out"
     77        });
    7678        dao.UpdateJob(j);
    7779      }
Note: See TracChangeset for help on using the changeset viewer.