Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6419


Ignore:
Timestamp:
06/16/11 00:06:54 (13 years ago)
Author:
cneumuel
Message:

#1233

  • created events when statelog changed
  • fixed memory leak in hiveengine
  • extended timeout for long running transactions and database contexts (when jobdata is stored)
  • replaced random guids in database with sequential guids for performance reasons
  • minor fixes and cleanups
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
2 added
23 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentView.Designer.cs

    r6381 r6419  
    2121
    2222using HeuristicLab.Clients.Hive.Views.ExperimentManager;
     23using HeuristicLab.MainForm.WindowsForms;
    2324namespace HeuristicLab.Clients.Hive.ExperimentManager.Views {
    2425  partial class RefreshableHiveExperimentView {
     
    6667      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    6768      this.refreshButton = new System.Windows.Forms.Button();
     69      this.isPrivilegedCheckBox = new System.Windows.Forms.CheckBox();
    6870      this.refreshAutomaticallyCheckBox = new System.Windows.Forms.CheckBox();
    6971      this.infoGroupBox = new System.Windows.Forms.GroupBox();
     
    7476      this.calculatingLabel = new System.Windows.Forms.Label();
    7577      this.jobsLabel = new System.Windows.Forms.Label();
    76       this.isPrivilegedCheckBox = new System.Windows.Forms.CheckBox();
     78      this.stateTabPage = new System.Windows.Forms.TabPage();
     79      this.stateLogViewHost = new ViewHost();
    7780      this.tabControl.SuspendLayout();
    7881      this.jobsTabPage.SuspendLayout();
    7982      this.logTabPage.SuspendLayout();
    8083      this.infoGroupBox.SuspendLayout();
     84      this.stateTabPage.SuspendLayout();
    8185      this.SuspendLayout();
    8286      //
     
    8791                  | System.Windows.Forms.AnchorStyles.Right)));
    8892      this.tabControl.Controls.Add(this.jobsTabPage);
     93      this.tabControl.Controls.Add(this.stateTabPage);
    8994      this.tabControl.Controls.Add(this.logTabPage);
    9095      this.tabControl.Location = new System.Drawing.Point(0, 78);
     
    126131      this.logTabPage.Location = new System.Drawing.Point(4, 22);
    127132      this.logTabPage.Name = "logTabPage";
    128       this.logTabPage.Size = new System.Drawing.Size(813, 494);
     133      this.logTabPage.Size = new System.Drawing.Size(709, 426);
    129134      this.logTabPage.TabIndex = 3;
    130135      this.logTabPage.Text = "Log";
     
    271276      this.refreshButton.UseVisualStyleBackColor = true;
    272277      this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);
     278      //
     279      // isPrivilegedCheckBox
     280      //
     281      this.isPrivilegedCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     282      this.isPrivilegedCheckBox.AutoSize = true;
     283      this.isPrivilegedCheckBox.Location = new System.Drawing.Point(383, 55);
     284      this.isPrivilegedCheckBox.Name = "isPrivilegedCheckBox";
     285      this.isPrivilegedCheckBox.Size = new System.Drawing.Size(80, 17);
     286      this.isPrivilegedCheckBox.TabIndex = 26;
     287      this.isPrivilegedCheckBox.Text = "IsPrivileged";
     288      this.toolTip.SetToolTip(this.isPrivilegedCheckBox, "If checked, the job will be executed in a privileged sandbox on the slave.");
     289      this.isPrivilegedCheckBox.UseVisualStyleBackColor = true;
     290      this.isPrivilegedCheckBox.CheckedChanged += new System.EventHandler(this.isPrivilegedCheckBox_CheckedChanged);
    273291      //
    274292      // refreshAutomaticallyCheckBox
     
    353371      this.jobsLabel.Text = "Jobs:";
    354372      //
    355       // isPrivilegedCheckBox
    356       //
    357       this.isPrivilegedCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    358       this.isPrivilegedCheckBox.AutoSize = true;
    359       this.isPrivilegedCheckBox.Location = new System.Drawing.Point(383, 55);
    360       this.isPrivilegedCheckBox.Name = "isPrivilegedCheckBox";
    361       this.isPrivilegedCheckBox.Size = new System.Drawing.Size(80, 17);
    362       this.isPrivilegedCheckBox.TabIndex = 26;
    363       this.isPrivilegedCheckBox.Text = "IsPrivileged";
    364       this.toolTip.SetToolTip(this.isPrivilegedCheckBox, "If checked, the job will be executed in a privileged sandbox on the slave.");
    365       this.isPrivilegedCheckBox.UseVisualStyleBackColor = true;
    366       this.isPrivilegedCheckBox.CheckedChanged += new System.EventHandler(this.isPrivilegedCheckBox_CheckedChanged);
     373      // stateTabPage
     374      //
     375      this.stateTabPage.Controls.Add(this.stateLogViewHost);
     376      this.stateTabPage.Location = new System.Drawing.Point(4, 22);
     377      this.stateTabPage.Name = "stateTabPage";
     378      this.stateTabPage.Size = new System.Drawing.Size(709, 426);
     379      this.stateTabPage.TabIndex = 6;
     380      this.stateTabPage.Text = "State";
     381      this.stateTabPage.UseVisualStyleBackColor = true;
     382      //
     383      // stateLogViewHost
     384      //
     385      this.stateLogViewHost.Caption = "StateLog View";
     386      this.stateLogViewHost.Content = null;
     387      this.stateLogViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
     388      this.stateLogViewHost.Location = new System.Drawing.Point(0, 0);
     389      this.stateLogViewHost.Name = "stateLogViewHost";
     390      this.stateLogViewHost.ReadOnly = false;
     391      this.stateLogViewHost.Size = new System.Drawing.Size(709, 426);
     392      this.stateLogViewHost.TabIndex = 0;
    367393      //
    368394      // RefreshableHiveExperimentView
     
    393419      this.infoGroupBox.ResumeLayout(false);
    394420      this.infoGroupBox.PerformLayout();
     421      this.stateTabPage.ResumeLayout(false);
    395422      this.ResumeLayout(false);
    396423      this.PerformLayout();
     
    426453    private System.Windows.Forms.Label jobsLabel;
    427454    private System.Windows.Forms.CheckBox isPrivilegedCheckBox;
     455    private System.Windows.Forms.TabPage stateTabPage;
     456    private ViewHost stateLogViewHost;
    428457
    429458  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentView.cs

    r6381 r6419  
    6161      Content.JobStatisticsChanged += new EventHandler(Content_JobStatisticsChanged);
    6262      Content.ExceptionOccured += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured);
     63      Content.StateLogListChanged += new EventHandler(Content_StateLogListChanged);
    6364    }
    6465
     
    6970      Content.JobStatisticsChanged -= new EventHandler(Content_JobStatisticsChanged);
    7071      Content.ExceptionOccured -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured);
     72      Content.StateLogListChanged -= new EventHandler(Content_StateLogListChanged);
    7173      base.DeregisterContentEvents();
    7274    }
     
    105107        isPrivilegedCheckBox.Checked = false;
    106108        logView.Content = null;
    107         refreshAutomaticallyCheckBox.Checked = false;       
     109        refreshAutomaticallyCheckBox.Checked = false;
    108110        logView.Content = null;
    109111      } else {
     
    120122      Content_HiveJobChanged(this, EventArgs.Empty);
    121123      Content_IsProgressingChanged(this, EventArgs.Empty);
     124      Content_StateLogListChanged(this, EventArgs.Empty);
    122125      SetEnabledStateOfControls();
    123126    }
     
    260263        // show error dialog only if Controllable (otherwise it should continue trying without an error dialog (e.g. HiveEngine))
    261264        ErrorHandling.ShowErrorDialog(this, e.Value);
     265      }
     266    }
     267    private void Content_StateLogListChanged(object sender, EventArgs e) {
     268      if (InvokeRequired)
     269        Invoke(new EventHandler(Content_StateLogListChanged), sender, e);
     270      else {
     271        UpdateStateLogList();
     272      }
     273    }
     274
     275    private void UpdateStateLogList() {
     276      if (Content != null && this.Content.HiveExperiment != null) {
     277        stateLogViewHost.Content = this.Content.HiveExperiment.StateLogList;
     278      } else {
     279        stateLogViewHost.Content = null;
    262280      }
    263281    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Executor.cs

    r6381 r6419  
    3131  /// </summary>
    3232  public class Executor : MarshalByRefObject, IDisposable {
    33     public Guid JobId { get; set; }
    34     private IJob Job { get; set; }
    35     public int CoresNeeded { get; set; }
    36     public int MemoryNeeded { get; set; }
    3733    private bool wasJobAborted = false;
    3834    private Semaphore pauseStopSem = new Semaphore(0, 1);
    3935    private Semaphore startJobSem = new Semaphore(0, 1);
    40     //make pause or stop wait until start is finished
    41     private Semaphore jobStartedSem = new Semaphore(0, 1);
     36    private Semaphore jobStartedSem = new Semaphore(0, 1); // make pause or stop wait until start is finished
    4237    private ExecutorQueue executorQueue;
    43     public ExecutorQueue ExecutorCommandQueue {
    44       get {
    45         return executorQueue;
    46       }
    47     }
     38    private bool jobDataInvalid = false; // if true, the jobdata is not sent when the job is failed
     39    private IJob job;
     40    private DateTime creationTime;
     41
     42    public Guid JobId { get; set; }
     43    public int CoresNeeded { get; set; }
     44    public int MemoryNeeded { get; set; }
    4845    public bool IsStopping { get; set; }
    4946    public bool IsPausing { get; set; }
    50     private DateTime CreationTime { get; set; }
     47
    5148    private Exception currentException;
    5249    public String CurrentException {
     
    6057    }
    6158
     59    public ExecutorQueue ExecutorCommandQueue {
     60      get { return executorQueue; }
     61    }
     62
    6263    private ExecutionState ExecutionState {
    63       get {
    64         return Job != null ? Job.ExecutionState : HeuristicLab.Core.ExecutionState.Stopped;
    65       }
     64      get { return job != null ? job.ExecutionState : HeuristicLab.Core.ExecutionState.Stopped; }
    6665    }
    6766
    6867    public TimeSpan ExecutionTime {
    69       get {
    70         return Job != null ? Job.ExecutionTime : new TimeSpan(0, 0, 0);
    71       }
     68      get { return job != null ? job.ExecutionTime : new TimeSpan(0, 0, 0); }
    7269    }
    7370
     
    8077    public void Start(byte[] serializedJob) {
    8178      try {
    82         CreationTime = DateTime.Now;
    83         Job = PersistenceUtil.Deserialize<IJob>(serializedJob);
     79        creationTime = DateTime.Now;
     80        job = PersistenceUtil.Deserialize<IJob>(serializedJob);
    8481
    8582        RegisterJobEvents();
    8683
    87         Job.Start();
    88         if (!jobStartedSem.WaitOne(TimeSpan.FromSeconds(15))) {
     84        job.Start();
     85        if (!jobStartedSem.WaitOne(TimeSpan.FromSeconds(25))) {
     86          jobDataInvalid = true;
    8987          throw new TimeoutException("Timeout when starting the job. JobStarted event was not fired.");
    9088        }
     
    10199      // wait until job is started. if this does not happen, the Job is null an we give up
    102100      jobStartedSem.WaitOne(TimeSpan.FromSeconds(15));
    103       if (Job == null) {
     101      if (job == null) {
    104102        currentException = new Exception("Pausing job " + this.JobId + ": Job is null");
    105103        return;
    106104      }
    107105
    108       if (Job.ExecutionState == ExecutionState.Started) {
     106      if (job.ExecutionState == ExecutionState.Started) {
    109107        try {
    110           Job.Pause();
     108          job.Pause();
    111109          //we need to block the pause...
    112110          pauseStopSem.WaitOne();
     
    122120      // wait until job is started. if this does not happen, the Job is null an we give up
    123121      jobStartedSem.WaitOne(TimeSpan.FromSeconds(15));
    124       if (Job == null) {
     122      if (job == null) {
    125123        currentException = new Exception("Stopping job " + this.JobId + ": Job is null");
    126124      }
     
    129127      if ((ExecutionState == ExecutionState.Started) || (ExecutionState == ExecutionState.Paused)) {
    130128        try {
    131           Job.Stop();
     129          job.Stop();
    132130          pauseStopSem.WaitOne();
    133131        }
     
    139137
    140138    private void RegisterJobEvents() {
    141       Job.JobStopped += new EventHandler(Job_JobStopped);
    142       Job.JobFailed += new EventHandler(Job_JobFailed);
    143       Job.JobPaused += new EventHandler(Job_JobPaused);
    144       Job.JobStarted += new EventHandler(Job_JobStarted);
     139      job.JobStopped += new EventHandler(Job_JobStopped);
     140      job.JobFailed += new EventHandler(Job_JobFailed);
     141      job.JobPaused += new EventHandler(Job_JobPaused);
     142      job.JobStarted += new EventHandler(Job_JobStarted);
    145143    }
    146144
    147145    private void DeregisterJobEvents() {
    148       Job.JobStopped -= new EventHandler(Job_JobStopped);
    149       Job.JobFailed -= new EventHandler(Job_JobFailed);
    150       Job.JobPaused -= new EventHandler(Job_JobPaused);
    151       Job.JobStarted -= new EventHandler(Job_JobStarted);
     146      job.JobStopped -= new EventHandler(Job_JobStopped);
     147      job.JobFailed -= new EventHandler(Job_JobFailed);
     148      job.JobPaused -= new EventHandler(Job_JobPaused);
     149      job.JobStarted -= new EventHandler(Job_JobStarted);
    152150    }
    153151
     
    182180
    183181    public JobData GetJobData() {
    184       if (Job.ExecutionState == ExecutionState.Started) {
     182      if (jobDataInvalid) return null;
     183
     184      if (job.ExecutionState == ExecutionState.Started) {
    185185        throw new InvalidStateException("Job is still running");
    186186      } else {
    187187        JobData jobData = new JobData();
    188         if (Job == null) {
     188        if (job == null) {
    189189          //send empty job and save exception
    190190          jobData.Data = PersistenceUtil.Serialize(new JobData());
     
    193193          }
    194194        } else {
    195           jobData.Data = PersistenceUtil.Serialize(Job);
     195          jobData.Data = PersistenceUtil.Serialize(job);
    196196        }
    197197        jobData.JobId = JobId;
     
    201201
    202202    public void Dispose() {
    203       if (Job != null)
     203      if (job != null)
    204204        DeregisterJobEvents();
    205       Job = null;
     205      job = null;
    206206    }
    207207  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/WcfService.cs

    r6381 r6419  
    105105        service.UpdateJob(job);
    106106        job = service.UpdateJobState(job.Id, JobState.Transferring, slaveId, null, null);
    107         service.UpdateJobData(job, jobData);
     107        HiveClient.TryAndRepeat(() => {
     108          service.UpdateJobData(job, jobData);
     109        }, 3, "Could not upload jobdata.");
    108110        service.UpdateJobState(job.Id, state, slaveId, null, exception);
    109111      });
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/HeuristicLab.Clients.Hive.Views-3.4.csproj

    r6381 r6419  
    149149      <DependentUpon>HiveJobView.cs</DependentUpon>
    150150    </Compile>
    151     <Compile Include="StateLog\StateLogListList.cs" />
    152151    <Compile Include="TreeView\NewExperimentTreeNodeAction.cs" />
    153152    <Compile Include="TreeView\DeleteJobTreeNodeAction.cs" />
     
    182181      <DependentUpon>StateLogGanttChartView.cs</DependentUpon>
    183182    </Compile>
    184     <Compile Include="StateLog\StateLogList.cs" />
    185183    <Compile Include="StateLog\StateLogListView.cs">
    186184      <SubType>UserControl</SubType>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/HiveJobs/HiveJobView.cs

    r6373 r6419  
    2121
    2222using System;
    23 using System.Linq;
    2423using System.Windows.Forms;
    2524using HeuristicLab.Core.Views;
     
    4948      Content.JobChanged += new EventHandler(Content_JobChanged);
    5049      Content.JobStateChanged += new EventHandler(Content_JobStateChanged);
     50      Content.StateLogChanged += new EventHandler(Content_StateLogChanged);
    5151    }
    5252
     
    5555      Content.JobChanged -= new EventHandler(Content_JobChanged);
    5656      Content.JobStateChanged -= new EventHandler(Content_JobStateChanged);
     57      Content.StateLogChanged -= new EventHandler(Content_StateLogChanged);
    5758      base.DeregisterContentEvents();
    5859    }
     
    129130          this.exceptionTextBox.Text = Content.Job.CurrentStateLog != null ? Content.Job.CurrentStateLog.Exception : string.Empty;
    130131          this.lastUpdatedTextBox.Text = Content.Job.LastJobDataUpdate.ToString();
    131           if (Content.ItemJob.ComputeInParallel) {
    132             this.stateLogViewHost.Content = new StateLogListList(
    133                 this.Content.ChildHiveJobs.Select(child => new StateLogList(child.Job.StateLog)
    134               ));
    135           } else {
    136             this.stateLogViewHost.Content = new StateLogList(Content.Job.StateLog);
    137           }
    138132        } else {
    139133          this.stateTextBox.Text = string.Empty;
     
    143137          this.dateFinishedTextBox.Text = string.Empty;
    144138          this.exceptionTextBox.Text = string.Empty;
    145           this.stateLogViewHost.Content = null;
    146139          this.lastUpdatedTextBox.Text = string.Empty;
    147140        }
     141        Content_StateLogChanged(this, EventArgs.Empty);
    148142        SetEnabledStateOfControls();
    149143      }
     
    155149      } else {
    156150        computeInParallelCheckBox.Checked = Content.ItemJob.ComputeInParallel;
     151      }
     152    }
     153
     154    protected virtual void Content_StateLogChanged(object sender, EventArgs e) {
     155      if (Content != null) {
     156        if (Content.ItemJob.ComputeInParallel) {
     157          this.stateLogViewHost.Content = Content.ChildStateLogList;
     158        } else {
     159          this.stateLogViewHost.Content = Content.StateLog;
     160        }
     161      } else {
     162        this.stateLogViewHost.Content = null;
    157163      }
    158164    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HeuristicLab.Clients.Hive-3.4.csproj

    r6373 r6419  
    115115    <Compile Include="Jobs\ItemJob.cs" />
    116116    <Compile Include="RefreshableHiveExperiment.cs" />
     117    <Compile Include="StateLogList.cs" />
     118    <Compile Include="StateLogListList.cs" />
    117119    <Compile Include="ThreadSafeLog.cs" />
    118120    <None Include="app_f005pc.config" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HiveClient.cs

    r6407 r6419  
    297297          hiveJob.Job.Id = service.AddJob(hiveJob.Job, jobData, groups.ToList());
    298298        }
    299       }, -1, "Failed to add job");
     299      }, -1, "Failed to add job", log);
    300300
    301301      foreach (HiveJob child in hiveJob.ChildHiveJobs) {
     
    391391    /// If repetitions is -1, it is repeated infinitely.
    392392    /// </summary>
    393     public static void TryAndRepeat(Action action, int repetitions, string errorMessage) {
     393    public static void TryAndRepeat(Action action, int repetitions, string errorMessage, ILog log = null) {
    394394      while (true) {
    395395        try { action(); return; }
    396396        catch (Exception e) {
    397           if (repetitions == 0)
    398             throw new HiveException(errorMessage, e);
     397          if (repetitions == 0) throw new HiveException(errorMessage, e);
     398          if (log != null) log.LogMessage(string.Format("{0}: {1} - will try again!", errorMessage, e.ToString()));
    399399          repetitions--;
    400400        }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HiveJobs/EngineHiveJob.cs

    r6381 r6419  
    7171      return jobData;
    7272    }
     73
     74    public override void ClearData() {
     75      base.ClearData();
     76      this.ItemJob.InitialOperation = null;
     77    }
    7378  }
    7479}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HiveJobs/HiveJob.cs

    r6381 r6419  
    123123    protected bool syncJobsWithOptimizers = true;
    124124
     125    public StateLogList StateLog {
     126      get { return new StateLogList(this.job.StateLog); }
     127    }
     128
     129    public StateLogListList ChildStateLogList {
     130      get { return new StateLogListList(this.childHiveJobs.Select(x => x.StateLog)); }
     131    }
     132
    125133    #region Constructors and Cloning
    126134    public HiveJob() {
     
    234242        OnToStringChanged();
    235243        OnItemImageChanged();
     244        OnStateLogChanged();
    236245      }
    237246    }
     
    255264    }
    256265
    257     #region Events
     266    #region Event Handler
    258267    public event EventHandler JobChanged;
    259268    private void OnJobChanged() {
     
    278287    private void OnIsFinishedJobDownloadedChanged() {
    279288      var handler = IsFinishedJobDownloadedChanged;
     289      if (handler != null) handler(this, EventArgs.Empty);
     290    }
     291
     292    public event EventHandler StateLogChanged;
     293    private void OnStateLogChanged() {
     294      var handler = StateLogChanged;
    280295      if (handler != null) handler(this, EventArgs.Empty);
    281296    }
     
    371386    public event CollectionItemsChangedEventHandler<IItemTree<HiveJob>> CollectionReset;
    372387    private void OnCollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<HiveJob>> e) {
     388      foreach (var item in e.Items) {
     389        item.Value.StateLogChanged -= new EventHandler(ChildHiveJob_StateLogChanged);
     390      }
    373391      var handler = CollectionReset;
    374392      if (handler != null) handler(this, ToCollectionItemsChangedEventArgs(e));
     
    377395    public event CollectionItemsChangedEventHandler<IItemTree<HiveJob>> ItemsAdded;
    378396    private void OnItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<HiveJob>> e) {
     397      foreach (var item in e.Items) {
     398        item.Value.StateLogChanged += new EventHandler(ChildHiveJob_StateLogChanged);
     399      }
    379400      var handler = ItemsAdded;
    380401      if (handler != null) handler(this, ToCollectionItemsChangedEventArgs(e));
     
    383404    public event CollectionItemsChangedEventHandler<IItemTree<HiveJob>> ItemsRemoved;
    384405    private void OnItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<HiveJob>> e) {
     406      foreach (var item in e.Items) {
     407        item.Value.StateLogChanged -= new EventHandler(ChildHiveJob_StateLogChanged);
     408      }
    385409      var handler = ItemsRemoved;
    386410      if (handler != null) handler(this, ToCollectionItemsChangedEventArgs(e));
     
    389413    private static CollectionItemsChangedEventArgs<IItemTree<HiveJob>> ToCollectionItemsChangedEventArgs(CollectionItemsChangedEventArgs<IndexedItem<HiveJob>> e) {
    390414      return new CollectionItemsChangedEventArgs<IItemTree<HiveJob>>(e.Items.Select(x => x.Value), e.OldItems == null ? null : e.OldItems.Select(x => x.Value));
     415    }
     416
     417    private void ChildHiveJob_StateLogChanged(object sender, EventArgs e) {
     418      OnStateLogChanged();
    391419    }
    392420    #endregion
     
    443471    /// Delete ItemJob
    444472    /// </summary>
    445     public void ClearData() {
     473    public virtual void ClearData() {
    446474      this.ItemJob.Item = null;
    447475    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/Jobs/EngineJob.cs

    r6200 r6419  
    11using System;
    2 using System.Collections.Generic;
    32using System.Drawing;
    43using HeuristicLab.Common;
    54using HeuristicLab.Core;
    6 using HeuristicLab.Hive;
    75using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    86
     
    6563    public override void Stop() {
    6664      Item.Stop();
    67     }
    68    
    69     public override void Resume(IEnumerable<IJob> childJobs) {
    70       throw new NotImplementedException();
    7165    }
    7266
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/Jobs/ItemJob.cs

    r6381 r6419  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.Drawing;
    2524using HeuristicLab.Common;
     
    113112    public abstract void Stop();
    114113
    115     public abstract void Resume(IEnumerable<IJob> childJobs);
    116 
    117114    public event EventHandler JobStarted;
    118115    protected virtual void OnJobStarted() {
     
    139136    }
    140137
    141     public event EventHandler<EventArgs<IJob>> NewChildJob;
    142     protected virtual void OnNewChildJob(IJob job) {
    143       EventHandler<EventArgs<IJob>> handler = NewChildJob;
    144       if (handler != null) handler(this, new EventArgs<IJob>(job));
    145     }
    146 
    147     public event EventHandler WaitForChildJobs;
    148     protected virtual void OnWaitForChildJobs() {
    149       EventHandler handler = WaitForChildJobs;
    150       if (handler != null) handler(this, EventArgs.Empty);
    151     }
    152 
    153     public event EventHandler DeleteChildJobs;
    154     protected virtual void OnDeleteChildJobs() {
    155       EventHandler handler = DeleteChildJobs;
    156       if (handler != null) handler(this, EventArgs.Empty);
    157     }
    158 
    159138    public event EventHandler ComputeInParallelChanged;
    160139    protected virtual void OnComputeInParallelChanged() {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/Jobs/OptimizerJob.cs

    r6381 r6419  
    113113    public override void Stop() {
    114114      Item.Stop();
    115     }
    116 
    117     public override void Resume(IEnumerable<IJob> childJobs) {
    118       OnJobStopped();
    119115    }
    120116    #endregion
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/RefreshableHiveExperiment.cs

    r6381 r6419  
    8888    }
    8989    private static object logLocker = new object();
    90    
    9190
    9291    #region Constructors and Cloning
     
    220219      UpdateTotalExecutionTime();
    221220      UpdateStatistics();
     221      OnStateLogListChanged();
    222222    }
    223223
     
    269269    #endregion
    270270
     271    #region HiveExperiment Events
    271272    private void RegisterHiveExperimentEvents() {
    272273      hiveExperiment.HiveJobsChanged += new EventHandler(hiveExperiment_HiveJobsChanged);
     
    296297      }
    297298    }
    298 
    299     #region Events
     299    #endregion
     300
     301    #region Event Handler
    300302    public event EventHandler RefreshAutomaticallyChanged;
    301303    private void OnRefreshAutomaticallyChanged() {
     
    358360      if (handler != null) handler(this, new EventArgs<Exception>(exception));
    359361    }
     362
     363    public event EventHandler StateLogListChanged;
     364    private void OnStateLogListChanged() {
     365      var handler = StateLogListChanged;
     366      if (handler != null) handler(this, EventArgs.Empty);
     367    }
    360368    #endregion
    361369
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveExperiment.cs

    r6381 r6419  
    2424using System.ComponentModel;
    2525using System.Linq;
     26using HeuristicLab.Collections;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
     
    6869      set {
    6970        if (hiveJobs != value) {
     71          if (hiveJobs != null) DeregisterHiveJobsEvents();
    7072          hiveJobs = value;
     73          if (hiveJobs != null) RegisterHiveJobsEvents();
    7174          OnHiveJobsChanged();
    7275        }
     
    8992      get { return progress; }
    9093      set { this.progress = value; }
     94    }
     95
     96    public StateLogListList StateLogList {
     97      get { return new StateLogListList(this.GetAllHiveJobs().Select(x => x.StateLog)); }
    9198    }
    9299
     
    147154      if (handler != null) handler(this, EventArgs.Empty);
    148155    }
     156
     157    public event EventHandler<CollectionItemsChangedEventArgs<HiveJob>> HiveJobsAdded;
     158    private void OnHiveJobsAdded(CollectionItemsChangedEventArgs<HiveJob> e) {
     159      var handler = HiveJobsAdded;
     160      if (handler != null) handler(this, e);
     161    }
     162
     163    public event EventHandler<CollectionItemsChangedEventArgs<HiveJob>> HiveJobsRemoved;
     164    private void OnHiveJobsRemoved(CollectionItemsChangedEventArgs<HiveJob> e) {
     165      var handler = HiveJobsRemoved;
     166      if (handler != null) handler(this, e);
     167    }
     168
     169    public event EventHandler<CollectionItemsChangedEventArgs<HiveJob>> HiveJobsReset;
     170    private void OnHiveJobsReset(CollectionItemsChangedEventArgs<HiveJob> e) {
     171      var handler = HiveJobsReset;
     172      if (handler != null) handler(this, e);
     173    }
     174
     175    public event EventHandler StateLogListChanged;
     176    private void OnStateLogListChanged() {
     177      var handler = StateLogListChanged;
     178      if (handler != null) handler(this, EventArgs.Empty);
     179    }
     180    #endregion
     181
     182    #region HiveJobs Events
     183    private void RegisterHiveJobsEvents() {
     184      this.hiveJobs.ItemsAdded += new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_ItemsAdded);
     185      this.hiveJobs.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_ItemsRemoved);
     186      this.hiveJobs.CollectionReset += new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_CollectionReset);
     187    }
     188
     189    private void DeregisterHiveJobsEvents() {
     190      this.hiveJobs.ItemsAdded -= new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_ItemsAdded);
     191      this.hiveJobs.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_ItemsRemoved);
     192      this.hiveJobs.CollectionReset -= new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_CollectionReset);
     193    }
     194
     195    private void hiveJobs_CollectionReset(object sender, CollectionItemsChangedEventArgs<HiveJob> e) {
     196      foreach (var item in e.Items) {
     197        item.StateLogChanged -= new EventHandler(item_StateLogChanged);
     198      }
     199      OnHiveJobsReset(e);
     200    }
     201
     202    private void hiveJobs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<HiveJob> e) {
     203      foreach (var item in e.Items) {
     204        item.StateLogChanged -= new EventHandler(item_StateLogChanged);
     205      }
     206      OnHiveJobsRemoved(e);
     207    }
     208
     209    private void hiveJobs_ItemsAdded(object sender, CollectionItemsChangedEventArgs<HiveJob> e) {
     210      foreach (var item in e.Items) {
     211        item.StateLogChanged += new EventHandler(item_StateLogChanged);
     212      }
     213      OnHiveJobsAdded(e);
     214    }
     215   
     216    private void item_StateLogChanged(object sender, EventArgs e) {
     217      OnStateLogListChanged();
     218    }
    149219    #endregion
    150220
     
    171241
    172242    public IEnumerable<HiveJob> GetAllHiveJobs() {
     243      if (hiveJobs == null) return Enumerable.Empty<HiveJob>();
     244
    173245      var jobs = new List<HiveJob>();
    174246      foreach (HiveJob job in HiveJobs) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Views/3.4/HiveEngineView.Designer.cs

    r6381 r6419  
    6464      this.resourceIdsTextBox.TabIndex = 4;
    6565      this.resourceIdsTextBox.Text = "HEAL";
    66       this.resourceIdsTextBox.TextChanged += new System.EventHandler(this.resourceIdsTextBox_TextChanged);
     66      this.resourceIdsTextBox.Validated += new System.EventHandler(this.resourceIdsTextBox_Validated);
    6767      //
    6868      // priorityLabel
     
    8282      this.priorityTextBox.TabIndex = 6;
    8383      this.priorityTextBox.Text = "0";
    84       this.priorityTextBox.TextChanged += new System.EventHandler(this.priorityTextBox_TextChanged);
     84      this.priorityTextBox.Validated += new System.EventHandler(this.priorityTextBox_Validated);
    8585      //
    8686      // label1
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine.Views/3.4/HiveEngineView.cs

    r6381 r6419  
    105105   
    106106    #region Event Handlers (child controls)
    107     private void resourceIdsTextBox_TextChanged(object sender, EventArgs e) {
     107    private void resourceIdsTextBox_Validated(object sender, EventArgs e) {
    108108      Content.ResourceNames = resourceIdsTextBox.Text;
    109109    }
    110110
    111     private void priorityTextBox_TextChanged(object sender, EventArgs e) {
     111    private void priorityTextBox_Validated(object sender, EventArgs e) {
    112112      Content.Priority = int.Parse(priorityTextBox.Text);
    113113    }
     
    121121    }
    122122    #endregion
     123
     124
    123125  }
    124126}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HiveEngine.cs

    r6381 r6419  
    196196          //} else if (coll.Parallel) {
    197197          if (coll.Parallel) {
    198             // clone the parent scope here and reuse it for each operation. otherwise for each job the whole scope-tree first needs to be copied and then cleaned, which causes a lot of work for the Garbage Collector
    199             IScope parentScopeClone = (IScope)((IAtomicOperation)coll.First()).Scope.Parent.Clone();
    200             parentScopeClone.SubScopes.Clear();
    201             parentScopeClone.ClearParentScopes();
    202 
    203             EngineJob[] jobs = new EngineJob[coll.Count];
    204             for (int i = 0; i < coll.Count; i++) {
    205               jobs[i] = new EngineJob(coll[i], new SequentialEngine.SequentialEngine());
     198            try {
     199              // clone the parent scope here and reuse it for each operation. otherwise for each job the whole scope-tree first needs to be copied and then cleaned, which causes a lot of work for the Garbage Collector
     200              IScope parentScopeClone = (IScope)((IAtomicOperation)coll.First()).Scope.Parent.Clone();
     201              parentScopeClone.SubScopes.Clear();
     202              parentScopeClone.ClearParentScopes();
     203
     204              EngineJob[] jobs = new EngineJob[coll.Count];
     205              for (int i = 0; i < coll.Count; i++) {
     206                jobs[i] = new EngineJob(coll[i], new SequentialEngine.SequentialEngine());
     207              }
     208
     209              var experiment = CreateHiveExperiment();
     210              IScope[] scopes = ExecuteOnHive(experiment, jobs, parentScopeClone, cancellationToken);
     211
     212              for (int i = 0; i < coll.Count; i++) {
     213                if (coll[i] is IAtomicOperation) {
     214                  ExchangeScope(scopes[i], ((IAtomicOperation)coll[i]).Scope);
     215                } else if (coll[i] is OperationCollection) {
     216                  // todo ??
     217                }
     218              }
    206219            }
    207 
    208             var experiment = CreateHiveExperiment();
    209             IScope[] scopes = ExecuteOnHive(experiment, jobs, parentScopeClone, cancellationToken);
    210             DisposeHiveExperiment(experiment);
    211 
    212             for (int i = 0; i < coll.Count; i++) {
    213               if (coll[i] is IAtomicOperation) {
    214                 ExchangeScope(scopes[i], ((IAtomicOperation)coll[i]).Scope);
    215               } else if (coll[i] is OperationCollection) {
    216                 // todo ??
    217               }
     220            catch {
     221              executionStack.Push(coll); throw;
    218222            }
    219223          } else {
     
    305309
    306310        var failedJobs = hiveExperiment.HiveJobs.Where(x => x.Job.State == JobState.Failed);
    307         if(failedJobs.Count() > 0) {
     311        if (failedJobs.Count() > 0) {
    308312          throw new HiveEngineException("Job failed: " + failedJobs.First().Job.StateLog.Last().Exception);
    309313        }
     
    318322      }
    319323      catch (OperationCanceledException e) {
    320         lock (locker) {
    321           DeleteHiveExperiment(hiveExperiment.Id);
    322         }
    323324        throw e;
    324325      }
    325326      catch (Exception e) {
    326         lock (locker) {
    327           DeleteHiveExperiment(hiveExperiment.Id);
    328         }
    329327        LogException(e);
    330328        throw e;
     329      }
     330      finally {
     331        DisposeHiveExperiment(refreshableHiveExperiment);
    331332      }
    332333    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/ApplicationConstants.cs

    r6372 r6419  
    2626    public static TimeSpan SlaveHeartbeatTimeout = TimeSpan.FromMinutes(1);
    2727
    28     public static TimeSpan CalculatingJobHeartbeatTimeout = TimeSpan.FromMinutes(1);
     28    public static TimeSpan CalculatingJobHeartbeatTimeout = TimeSpan.FromMinutes(5.5);
    2929
    30     public static TimeSpan TransferringJobHeartbeatTimeout = TimeSpan.FromMinutes(5);
     30    public static TimeSpan TransferringJobHeartbeatTimeout = TimeSpan.FromMinutes(5.5);
     31
     32    /// <summary>
     33    /// Timeout for long running database command (storing or loading jobData)
     34    /// </summary>
     35    public static TimeSpan LongRunningDatabaseCommandTimeout = TimeSpan.FromMinutes(5);
    3136
    3237    /// <summary>
    3338    /// Interval in which the HL.HiveExperiment will poll results from server
    3439    /// </summary>
    35     public static TimeSpan ResultPollingInterval = TimeSpan.FromSeconds(5);
    36 
    37     /// <summary>
    38     /// Maximum number of jobs that the server should send/receive simultaniously
    39     /// </summary>
    40     public static int MaxJobTransferCount = 6;
     40    public static TimeSpan ResultPollingInterval = TimeSpan.FromSeconds(10);
    4141  }
    4242}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs

    r6369 r6419  
    2424using System.Linq;
    2525using System.Linq.Expressions;
     26using HeuristicLab.Services.Hive.Common;
     27using HeuristicLab.Services.Hive.Common.DataTransfer;
     28using HeuristicLab.Services.Hive.DataAccess.Properties;
     29using DT = HeuristicLab.Services.Hive.Common.DataTransfer;
    2630
    2731namespace HeuristicLab.Services.Hive.DataAccess {
    28   using HeuristicLab.Services.Hive.Common.DataTransfer;
    29   using HeuristicLab.Services.Hive.DataAccess.Properties;
    30   using DT = HeuristicLab.Services.Hive.Common.DataTransfer;
    31 
    3232  public class HiveDao : IHiveDao {
    33     public static HiveDataContext CreateContext() {
    34       return new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString);
     33    public static HiveDataContext CreateContext(bool longRunning = false) {
     34      var context = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString);
     35      if (longRunning) context.CommandTimeout = (int)ApplicationConstants.LongRunningDatabaseCommandTimeout.TotalSeconds;     
     36      return context;
    3537    }
    3638
     
    7173          if (db.RequiredPlugins.Count(p => p.PluginId == pluginId) == 0) {
    7274            db.RequiredPlugins.InsertOnSubmit(new RequiredPlugin() { JobId = entity.JobId, PluginId = pluginId });
    73           }         
     75          }
    7476        }
    7577        db.SubmitChanges();
     
    153155    #region JobData Methods
    154156    public DT.JobData GetJobData(Guid id) {
    155       using (var db = CreateContext()) {
     157      using (var db = CreateContext(true)) {
    156158        return Convert.ToDto(db.JobDatas.SingleOrDefault(x => x.JobId == id));
    157159      }
     
    159161
    160162    public IEnumerable<DT.JobData> GetJobDatas(Expression<Func<JobData, bool>> predicate) {
    161       using (var db = CreateContext()) {
     163      using (var db = CreateContext(true)) {
    162164        return db.JobDatas.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
    163165      }
     
    165167
    166168    public Guid AddJobData(DT.JobData dto) {
    167       using (var db = CreateContext()) {
     169      using (var db = CreateContext(true)) {
    168170        var entity = Convert.ToEntity(dto);
    169171        db.JobDatas.InsertOnSubmit(entity);
     
    174176
    175177    public void UpdateJobData(DT.JobData dto) {
    176       using (var db = CreateContext()) {
     178      using (var db = CreateContext(true)) {
    177179        var entity = db.JobDatas.FirstOrDefault(x => x.JobId == dto.JobId);
    178180        if (entity == null) db.JobDatas.InsertOnSubmit(Convert.ToEntity(dto));
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Tools/prepareHiveDatabase.sql

    r6267 r6419  
    2525
    2626ALTER TABLE dbo.AssignedResources ALTER COLUMN AssignedRessourcesId ADD ROWGUIDCOL;
    27 ALTER TABLE dbo.AssignedResources WITH NOCHECK ADD CONSTRAINT [DF_AssignedResources_AssignedRessourcesId] DEFAULT (newid()) FOR AssignedRessourcesId;
     27ALTER TABLE dbo.AssignedResources WITH NOCHECK ADD CONSTRAINT [DF_AssignedResources_AssignedRessourcesId] DEFAULT (NEWSEQUENTIALID()) FOR AssignedRessourcesId;
    2828ALTER TABLE [dbo].[AssignedResources]  DROP  CONSTRAINT [Job_AssignedResource]
    2929ALTER TABLE [dbo].[AssignedResources]  WITH CHECK ADD  CONSTRAINT [Job_AssignedResource] FOREIGN KEY([JobId])
     
    4040
    4141ALTER TABLE dbo.Job ALTER COLUMN JobId ADD ROWGUIDCOL;
    42 ALTER TABLE dbo.Job WITH NOCHECK ADD CONSTRAINT [DF_Job_JobId] DEFAULT (newid()) FOR JobId;
     42ALTER TABLE dbo.Job WITH NOCHECK ADD CONSTRAINT [DF_Job_JobId] DEFAULT (NEWSEQUENTIALID()) FOR JobId;
    4343GO
    4444
     
    5757
    5858ALTER TABLE dbo.Plugin ALTER COLUMN PluginId ADD ROWGUIDCOL;
    59 ALTER TABLE dbo.Plugin WITH NOCHECK ADD CONSTRAINT [DF_Plugin_PluginId] DEFAULT (newid()) FOR PluginId;
     59ALTER TABLE dbo.Plugin WITH NOCHECK ADD CONSTRAINT [DF_Plugin_PluginId] DEFAULT (NEWSEQUENTIALID()) FOR PluginId;
    6060
    6161ALTER TABLE dbo.PluginData ALTER COLUMN PluginDataId ADD ROWGUIDCOL;
    62 ALTER TABLE dbo.PluginData WITH NOCHECK ADD CONSTRAINT [DF_PluginData_PluginDataId] DEFAULT (newid()) FOR PluginDataId;
     62ALTER TABLE dbo.PluginData WITH NOCHECK ADD CONSTRAINT [DF_PluginData_PluginDataId] DEFAULT (NEWSEQUENTIALID()) FOR PluginDataId;
    6363
    6464ALTER TABLE [dbo].[PluginData]  DROP  CONSTRAINT [Plugin_PluginData]
     
    7070
    7171ALTER TABLE dbo.RequiredPlugins ALTER COLUMN RequiredPluginId ADD ROWGUIDCOL;
    72 ALTER TABLE dbo.RequiredPlugins WITH NOCHECK ADD CONSTRAINT [DF_RequiredPlugins_RequiredPluginId] DEFAULT (newid()) FOR RequiredPluginId;
     72ALTER TABLE dbo.RequiredPlugins WITH NOCHECK ADD CONSTRAINT [DF_RequiredPlugins_RequiredPluginId] DEFAULT (NEWSEQUENTIALID()) FOR RequiredPluginId;
    7373
    7474ALTER TABLE [dbo].[RequiredPlugins]  DROP  CONSTRAINT [Job_RequiredPlugin]
     
    8787
    8888ALTER TABLE dbo.Resource ALTER COLUMN ResourceId ADD ROWGUIDCOL;
    89 ALTER TABLE dbo.Resource WITH NOCHECK ADD CONSTRAINT [DF_Resource_ResourceId] DEFAULT (newid()) FOR ResourceId;
     89ALTER TABLE dbo.Resource WITH NOCHECK ADD CONSTRAINT [DF_Resource_ResourceId] DEFAULT (NEWSEQUENTIALID()) FOR ResourceId;
    9090
    9191ALTER TABLE dbo.UptimeCalendar ALTER COLUMN UptimeCalendarId ADD ROWGUIDCOL;
    92 ALTER TABLE dbo.UptimeCalendar WITH NOCHECK ADD CONSTRAINT [DF_UptimeCalendar_UptimeCalendarId] DEFAULT (newid()) FOR UptimeCalendarId;
     92ALTER TABLE dbo.UptimeCalendar WITH NOCHECK ADD CONSTRAINT [DF_UptimeCalendar_UptimeCalendarId] DEFAULT (NEWSEQUENTIALID()) FOR UptimeCalendarId;
    9393
    9494ALTER TABLE dbo.HiveExperiment ALTER COLUMN HiveExperimentId ADD ROWGUIDCOL;
    95 ALTER TABLE dbo.HiveExperiment WITH NOCHECK ADD CONSTRAINT [DF_HiveExperiment_HiveExperimentId] DEFAULT (newid()) FOR HiveExperimentId;
     95ALTER TABLE dbo.HiveExperiment WITH NOCHECK ADD CONSTRAINT [DF_HiveExperiment_HiveExperimentId] DEFAULT (NEWSEQUENTIALID()) FOR HiveExperimentId;
    9696
    9797ALTER TABLE dbo.StateLog ALTER COLUMN StateLogId ADD ROWGUIDCOL;
    98 ALTER TABLE dbo.StateLog WITH NOCHECK ADD CONSTRAINT [DF_StateLog_StateLogId] DEFAULT (newid()) FOR StateLogId;
     98ALTER TABLE dbo.StateLog WITH NOCHECK ADD CONSTRAINT [DF_StateLog_StateLogId] DEFAULT (NEWSEQUENTIALID()) FOR StateLogId;
    9999
    100100ALTER TABLE [dbo].[HiveExperimentPermission]  DROP  CONSTRAINT [HiveExperiment_HiveExperimentPermission]
     
    106106
    107107ALTER TABLE [dbo].[Statistics] ALTER COLUMN StatisticsId ADD ROWGUIDCOL;
    108 ALTER TABLE [dbo].[Statistics] WITH NOCHECK ADD CONSTRAINT [DF_Statistics_StatisticsId] DEFAULT (newid()) FOR StatisticsId;
     108ALTER TABLE [dbo].[Statistics] WITH NOCHECK ADD CONSTRAINT [DF_Statistics_StatisticsId] DEFAULT (NEWSEQUENTIALID()) FOR StatisticsId;
    109109GO
    110110
    111111ALTER TABLE [dbo].[DeletedJobStatistics] ALTER COLUMN DeletedJobStatisticsId ADD ROWGUIDCOL;
    112 ALTER TABLE [dbo].[DeletedJobStatistics] WITH NOCHECK ADD CONSTRAINT [DF_DeletedJobStatistics_DeletedJobStatisticsId] DEFAULT (newid()) FOR DeletedJobStatisticsId;
     112ALTER TABLE [dbo].[DeletedJobStatistics] WITH NOCHECK ADD CONSTRAINT [DF_DeletedJobStatistics_DeletedJobStatisticsId] DEFAULT (NEWSEQUENTIALID()) FOR DeletedJobStatisticsId;
    113113GO
    114114
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/TransactionManager.cs

    r6367 r6419  
    2222using System;
    2323using System.Transactions;
     24using HeuristicLab.Services.Hive.Common;
    2425
    2526namespace HeuristicLab.Services.Hive.DataAccess {
    2627  public class TransactionManager {
    27     public void UseTransaction(Action call, bool serializable = false) {
    28       TransactionScope transaction = serializable ? CreateSerializableTransaction() : CreateTransaction();
     28    public void UseTransaction(Action call, bool serializable = false, bool longRunning = false) {
     29      TransactionScope transaction = CreateTransaction(serializable, longRunning);
    2930      try {
    3031        call();
     
    3637    }
    3738
    38     public T UseTransaction<T>(Func<T> call, bool serializable = false) {
    39       TransactionScope transaction = serializable ? CreateSerializableTransaction() : CreateTransaction();
     39    public T UseTransaction<T>(Func<T> call, bool serializable = false, bool longRunning = false) {
     40      TransactionScope transaction = CreateTransaction(serializable, longRunning);
    4041      try {
    4142        T result = call();
     
    4748      }
    4849    }
     50   
     51    private static TransactionScope CreateTransaction(bool serializable, bool longRunning) {
     52      var options = new TransactionOptions();
     53      if (serializable)
     54        options.IsolationLevel = IsolationLevel.Serializable;
     55      else
     56        options.IsolationLevel = IsolationLevel.ReadUncommitted;
    4957
    50     private static TransactionScope CreateTransaction() {
    51       return new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted });
    52     }
    53     private static TransactionScope CreateSerializableTransaction() {
    54       return new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.Serializable });
     58      if (longRunning)
     59        options.Timeout = ApplicationConstants.LongRunningDatabaseCommandTimeout;
     60     
     61      return new TransactionScope(TransactionScopeOption.Required, options);
    5562    }
    5663  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs

    r6407 r6419  
    4747        dao.UpdateJobState(job.Id, JobState.Waiting, null, author.UserId, null);
    4848        return jobData.JobId;
    49       });
     49      }, false, true);
    5050    }
    5151
     
    5555        job.ParentJobId = parentJobId;
    5656        return AddJob(job, jobData, dao.GetAssignedResources(parentJobId).Select(x => x.Id));
    57       });
     57      }, false, true);
    5858    }
    5959
     
    9797    public void UpdateJobData(Job job, JobData jobData) {
    9898      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    99       trans.UseTransaction(() => {
     99      //trans.UseTransaction(() => { // cneumuel: try without transaction
    100100        jobData.LastUpdate = DateTime.Now;
    101101        dao.UpdateJob(job);
    102102        dao.UpdateJobData(jobData);
    103       });
     103      //}, false, true);
    104104    }
    105105
Note: See TracChangeset for help on using the changeset viewer.