Changeset 6743


Ignore:
Timestamp:
09/12/11 18:04:25 (8 years ago)
Author:
ascheibe
Message:

#1233

  • fixed a bug in the Slave UI
  • finished renaming Webservice and Dao methods to be consistent with Job/Task naming
  • some cosmetic changes and project dependencies cleanups
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
55 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Common/UpdateControl.cs

    r6734 r6743  
    4040      if (imgBoxProgress.InvokeRequired) {
    4141        imgBoxProgress.Invoke(new MethodInvoker(() => imgBoxProgress.Visible = false));
     42        btnRefresh.Invoke(new MethodInvoker(() => btnRefresh.Enabled = true));
    4243      } else {
    4344        imgBoxProgress.Visible = false;
     45        btnRefresh.Enabled = true;
    4446      }
    4547    }
     
    4951        if (imgBoxProgress.InvokeRequired) {
    5052          imgBoxProgress.Invoke(new MethodInvoker(() => imgBoxProgress.Visible = true));
     53          btnRefresh.Invoke(new MethodInvoker(() => btnRefresh.Enabled = false));
    5154        } else {
    5255          imgBoxProgress.Visible = true;
     56          btnRefresh.Enabled = false;
    5357        }
    5458
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.3/Views/RefreshableHiveExperimentView.cs

    r6725 r6743  
    9393
    9494    private void RegisterHiveJobEvents() {
    95       Content.HiveJobs.ItemsAdded += new CollectionItemsChangedEventHandler<HiveTask>(HiveJobs_ItemsAdded_Removed_Reset);
    96       Content.HiveJobs.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveTask>(HiveJobs_ItemsAdded_Removed_Reset);
    97       Content.HiveJobs.CollectionReset += new CollectionItemsChangedEventHandler<HiveTask>(HiveJobs_ItemsAdded_Removed_Reset);
     95      Content.HiveTasks.ItemsAdded += new CollectionItemsChangedEventHandler<HiveTask>(HiveJobs_ItemsAdded_Removed_Reset);
     96      Content.HiveTasks.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveTask>(HiveJobs_ItemsAdded_Removed_Reset);
     97      Content.HiveTasks.CollectionReset += new CollectionItemsChangedEventHandler<HiveTask>(HiveJobs_ItemsAdded_Removed_Reset);
    9898    }
    9999    private void DeregisterHiveJobEvents() {
    100       Content.HiveJobs.ItemsAdded -= new CollectionItemsChangedEventHandler<HiveTask>(HiveJobs_ItemsAdded_Removed_Reset);
    101       Content.HiveJobs.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveTask>(HiveJobs_ItemsAdded_Removed_Reset);
    102       Content.HiveJobs.CollectionReset -= new CollectionItemsChangedEventHandler<HiveTask>(HiveJobs_ItemsAdded_Removed_Reset);
     100      Content.HiveTasks.ItemsAdded -= new CollectionItemsChangedEventHandler<HiveTask>(HiveJobs_ItemsAdded_Removed_Reset);
     101      Content.HiveTasks.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveTask>(HiveJobs_ItemsAdded_Removed_Reset);
     102      Content.HiveTasks.CollectionReset -= new CollectionItemsChangedEventHandler<HiveTask>(HiveJobs_ItemsAdded_Removed_Reset);
    103103    }
    104104
     
    140140      if (Content != null) {
    141141        bool alreadyUploaded = Content.Id != Guid.Empty;
    142         bool jobsLoaded = Content.HiveJobs != null && Content.HiveJobs.All(x => x.Task.Id != Guid.Empty);
     142        bool jobsLoaded = Content.HiveTasks != null && Content.HiveTasks.All(x => x.Task.Id != Guid.Empty);
    143143
    144144        this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
     
    229229        Invoke(new EventHandler(Content_HiveJobChanged), sender, e);
    230230      else {
    231         if (Content != null && Content.HiveJobs != null) {
    232           jobsTreeView.Content = Content.HiveJobs;
     231        if (Content != null && Content.HiveTasks != null) {
     232          jobsTreeView.Content = Content.HiveTasks;
    233233          RegisterHiveJobEvents();
    234234        } else {
     
    297297    #region Control events
    298298    private void startButton_Click(object sender, EventArgs e) {
    299       HiveClient.StartExperiment((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken());
     299      HiveClient.StartJob((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken());
    300300    }
    301301    private void pauseButton_Click(object sender, EventArgs e) {
    302       HiveClient.PauseExperiment(Content);
     302      HiveClient.PauseJob(Content);
    303303    }
    304304    private void stopButton_Click(object sender, EventArgs e) {
    305       HiveClient.StopExperiment(Content);
     305      HiveClient.StopJob(Content);
    306306    }
    307307    private void resetButton_Click(object sender, EventArgs e) { }
     
    326326
    327327    private void refreshButton_Click(object sender, EventArgs e) {
    328       var invoker = new Action<RefreshableJob>(HiveClient.LoadExperiment);
     328      var invoker = new Action<RefreshableJob>(HiveClient.LoadJob);
    329329      invoker.BeginInvoke(Content, (ar) => {
    330330        try {
     
    338338
    339339    private void refreshPermissionsButton_Click(object sender, EventArgs e) {
    340       hiveExperimentPermissionListView.Content = HiveClient.GetHiveExperimentPermissions(this.Content.Job.Id);
     340      hiveExperimentPermissionListView.Content = HiveClient.GetJobPermissions(this.Content.Job.Id);
    341341    }
    342342
     
    349349        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
    350350      } else {
    351         startButton.Enabled = Content.IsControllable && Content.HiveJobs != null && Content.HiveJobs.Count > 0 && Content.ExecutionState == ExecutionState.Prepared;
     351        startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 && Content.ExecutionState == ExecutionState.Prepared;
    352352        pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started;
    353353        stopButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started;
     
    406406        var optimizer = obj as IOptimizer;
    407407        if (optimizer != null) {
    408           Content.HiveJobs.Add(new OptimizerHiveTask(e.Effect.HasFlag(DragDropEffects.Copy) ? (IOptimizer)optimizer.Clone() : optimizer));
     408          Content.HiveTasks.Add(new OptimizerHiveTask(e.Effect.HasFlag(DragDropEffects.Copy) ? (IOptimizer)optimizer.Clone() : optimizer));
    409409        }
    410410      }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.App/3.3/HiveSlaveApplication.cs

    r6730 r6743  
    3434      coreThread.Start();
    3535
    36       SlaveItem item = new SlaveItem();
    3736      MainWindow window = new MainWindow();
    38       window.SetContent(item);
     37      window.Content = new SlaveItem();
    3938      Application.Run(window);
    4039
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.App/3.3/MainWindow.cs

    r6734 r6743  
    4040    }
    4141
    42     public void SetContent(SlaveItem item) {
    43       slaveMainView.Content = item;
     42    public SlaveItem Content {
     43      get { return slaveMainView.Content; }
     44      set {
     45        slaveMainView.Content = value;
     46      }
    4447    }
    4548
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/JobsView.cs

    r6734 r6743  
    5959    #region Event Handlers
    6060    void Content_SlaveStatusChanged(object sender, Common.EventArgs<StatusCommons> e) {
    61       lstJobs.Items.Clear();
    62       foreach (TaskStatus job in e.Value.Jobs) {
    63         ListViewItem item = new ListViewItem();
    64         item.Text = job.TaskId.ToString();
    65         item.SubItems.Add(job.ExecutionTime.ToString());
    66         lstJobs.Items.Add(item);
     61      if (InvokeRequired) {
     62        Action<object, Common.EventArgs<StatusCommons>> action = new Action<object, Common.EventArgs<StatusCommons>>(Content_SlaveStatusChanged);
     63        Invoke(action, sender, e);
     64      } else {
     65        lstJobs.Items.Clear();
     66        foreach (TaskStatus job in e.Value.Jobs) {
     67          ListViewItem item = new ListViewItem();
     68          item.Text = job.TaskId.ToString();
     69          item.SubItems.Add(job.ExecutionTime.ToString());
     70          lstJobs.Items.Add(item);
     71        }
     72        lstJobs.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
    6773      }
    68       lstJobs.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
    6974    }
    7075    #endregion
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/LogView.cs

    r6734 r6743  
    6969    #region Event Handlers
    7070    void Content_SlaveMessageLogged(object sender, EventArgs<string> e) {
    71       txtLog.AppendText(e.Value + Environment.NewLine);
     71      if (txtLog.InvokeRequired) {
     72        txtLog.Invoke(new Action<string>(txtLog.AppendText), e.Value + Environment.NewLine);
     73      } else {
     74        txtLog.AppendText(e.Value + Environment.NewLine);
     75      }
    7276    }
    7377
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/SlaveCmdsWithKill.cs

    r6734 r6743  
    6565    #region Register Content Events
    6666    protected override void DeregisterContentEvents() {
    67 
    68 
    6967      base.DeregisterContentEvents();
    7068    }
     
    173171    protected override void SetEnabledStateOfControls() {
    174172      base.SetEnabledStateOfControls();
    175       //do nothing at the moment, we have nothing editable
    176173    }
    177174
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/SlaveItem.cs

    r6725 r6743  
    6565
    6666    void pipeFactory_Opened(object sender, EventArgs e) {
    67       OnMessageLogged("Connection to Slave core established");
     67      OnMessageLogged("Connection to Slave core opened");
    6868      OnCoreConnectionChanged(CoreConnection.Connected);
    6969    }
     
    188188      var handler = SlaveDisplayStateChanged;
    189189      if (handler != null) handler(this, new EventArgs<SlaveDisplayStat>(stat));
    190 
    191190    }
    192191
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/SlaveMainViewBase.cs

    r6734 r6743  
    7676      if (Content != null) {
    7777        Content.UserVisibleMessageFired += new System.EventHandler<Common.EventArgs<string>>(Content_UserVisibleMessageFired);
    78         ((SlaveItem)base.Content).Open();
    7978        Task.Factory.StartNew(Connector);
    8079      }
     
    106105
    107106    private void Connector() {
     107      ((SlaveItem)base.Content).Open();
    108108      bool connected = false;
    109109      while (!connected) {
    110         this.Invoke(new Func<bool>(() => connected = ((SlaveItem)base.Content).ReconnectToSlaveCore()));
     110        connected = ((SlaveItem)base.Content).ReconnectToSlaveCore();
    111111
    112112        if (!connected) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/SlaveMainViewTray.cs

    r6734 r6743  
    2222using System.Windows.Forms;
    2323using HeuristicLab.MainForm;
    24 
    2524
    2625namespace HeuristicLab.Clients.Hive.SlaveCore.Views {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/SlaveStats.cs

    r6734 r6743  
    3535    private SlaveDisplayStat lastSlaveDisplayStat;
    3636
    37 
    3837    public new SlaveItem Content {
    3938      get { return (SlaveItem)base.Content; }
     
    5655      Content.SlaveStatusChanged -= new System.EventHandler<EventArgs<StatusCommons>>(Content_SlaveStatusChanged);
    5756      Content.SlaveDisplayStateChanged -= new EventHandler<EventArgs<SlaveDisplayStat>>(Content_SlaveDisplayStateChanged);
    58       Content.CoreConnectionChanged -= new EventHandler<EventArgs<CoreConnection>>(Content_CoreConnectionChanged);
    5957
    6058      base.DeregisterContentEvents();
     
    6664      Content.SlaveStatusChanged += new System.EventHandler<EventArgs<StatusCommons>>(Content_SlaveStatusChanged);
    6765      Content.SlaveDisplayStateChanged += new EventHandler<EventArgs<SlaveDisplayStat>>(Content_SlaveDisplayStateChanged);
    68       Content.CoreConnectionChanged += new EventHandler<EventArgs<CoreConnection>>(Content_CoreConnectionChanged);
    6966    }
    7067    #endregion
     
    8077    #region Event Handlers
    8178    void Content_SlaveStatusChanged(object sender, EventArgs<StatusCommons> e) {
    82       RenderJobChart(e.Value);
    83       RenderCoreChart(e.Value);
     79      if (InvokeRequired) {
     80        Action<object, EventArgs<StatusCommons>> action = new Action<object, EventArgs<StatusCommons>>(Content_SlaveStatusChanged);
     81        Invoke(action, sender, e);
     82      } else {
     83        RenderJobChart(e.Value);
     84        RenderCoreChart(e.Value);
     85      }
    8486    }
    8587
    8688    void Content_SlaveDisplayStateChanged(object sender, EventArgs<SlaveDisplayStat> e) {
    87       lblSlaveState.Text = e.Value.ToString();
    88       lastSlaveDisplayStat = e.Value;
    89     }
    90 
    91     void Content_CoreConnectionChanged(object sender, EventArgs<CoreConnection> e) {
    92 
     89      if (InvokeRequired) {
     90        Action<object, EventArgs<SlaveDisplayStat>> action = new Action<object, EventArgs<SlaveDisplayStat>>(Content_SlaveDisplayStateChanged);
     91        Invoke(action, sender, e);
     92      } else {
     93        lblSlaveState.Text = e.Value.ToString();
     94        lastSlaveDisplayStat = e.Value;
     95      }
    9396    }
    9497    #endregion
    9598
    9699    private void RenderJobChart(StatusCommons status) {
    97       jobChart.Series[0].Points.Clear();
    98       jobChart.Series[1].Points.Clear();
    99       jobChart.Series[2].Points.Clear();
    100       jobChart.Series[3].Points.Clear();
    101       jobChart.Series[4].Points.Clear();
     100      if (InvokeRequired) {
     101        Invoke(new Action<StatusCommons>(RenderJobChart), status);
     102      } else {
     103        jobChart.Series[0].Points.Clear();
     104        jobChart.Series[1].Points.Clear();
     105        jobChart.Series[2].Points.Clear();
     106        jobChart.Series[3].Points.Clear();
     107        jobChart.Series[4].Points.Clear();
    102108
    103109
    104       DataPoint pJobs = new DataPoint(1, status.Jobs.Count);
    105       DataPoint pJobsAborted = new DataPoint(2, status.JobsAborted);
    106       DataPoint pJobsDone = new DataPoint(3, status.JobsFinished);
    107       DataPoint pJobsFetched = new DataPoint(4, status.JobsFetched);
    108       DataPoint pJobsFailed = new DataPoint(5, status.JobsFailed);
     110        DataPoint pJobs = new DataPoint(1, status.Jobs.Count);
     111        DataPoint pJobsAborted = new DataPoint(2, status.JobsAborted);
     112        DataPoint pJobsDone = new DataPoint(3, status.JobsFinished);
     113        DataPoint pJobsFetched = new DataPoint(4, status.JobsFetched);
     114        DataPoint pJobsFailed = new DataPoint(5, status.JobsFailed);
    109115
    110       pJobs.LegendText = "Current jobs: " + status.Jobs.Count;
    111       pJobs.Color = System.Drawing.Color.Yellow;
    112       pJobs.ToolTip = pJobs.LegendText;
    113       jobChart.Series[0].Color = System.Drawing.Color.Yellow;
    114       jobChart.Series[0].LegendText = pJobs.LegendText;
    115       jobChart.Series[0].Points.Add(pJobs);
     116        pJobs.LegendText = "Current jobs: " + status.Jobs.Count;
     117        pJobs.Color = System.Drawing.Color.Yellow;
     118        pJobs.ToolTip = pJobs.LegendText;
     119        jobChart.Series[0].Color = System.Drawing.Color.Yellow;
     120        jobChart.Series[0].LegendText = pJobs.LegendText;
     121        jobChart.Series[0].Points.Add(pJobs);
    116122
    117       pJobsAborted.LegendText = "Aborted jobs: " + status.JobsAborted;
    118       pJobsAborted.Color = System.Drawing.Color.Orange;
    119       pJobsAborted.ToolTip = pJobsAborted.LegendText;
    120       jobChart.Series[1].Color = System.Drawing.Color.Orange;
    121       jobChart.Series[1].LegendText = pJobsAborted.LegendText;
    122       jobChart.Series[1].Points.Add(pJobsAborted);
     123        pJobsAborted.LegendText = "Aborted jobs: " + status.JobsAborted;
     124        pJobsAborted.Color = System.Drawing.Color.Orange;
     125        pJobsAborted.ToolTip = pJobsAborted.LegendText;
     126        jobChart.Series[1].Color = System.Drawing.Color.Orange;
     127        jobChart.Series[1].LegendText = pJobsAborted.LegendText;
     128        jobChart.Series[1].Points.Add(pJobsAborted);
    123129
    124       pJobsDone.LegendText = "Finished jobs: " + status.JobsFinished;
    125       pJobsDone.Color = System.Drawing.Color.Green;
    126       pJobsDone.ToolTip = pJobsDone.LegendText;
    127       jobChart.Series[2].Color = System.Drawing.Color.Green;
    128       jobChart.Series[2].LegendText = pJobsDone.LegendText;
    129       jobChart.Series[2].Points.Add(pJobsDone);
     130        pJobsDone.LegendText = "Finished jobs: " + status.JobsFinished;
     131        pJobsDone.Color = System.Drawing.Color.Green;
     132        pJobsDone.ToolTip = pJobsDone.LegendText;
     133        jobChart.Series[2].Color = System.Drawing.Color.Green;
     134        jobChart.Series[2].LegendText = pJobsDone.LegendText;
     135        jobChart.Series[2].Points.Add(pJobsDone);
    130136
    131       pJobsFetched.LegendText = "Fetched jobs: " + status.JobsFetched;
    132       pJobsFetched.ToolTip = pJobsFetched.LegendText;
    133       pJobsFetched.Color = System.Drawing.Color.Blue;
    134       jobChart.Series[3].Color = System.Drawing.Color.Blue;
    135       jobChart.Series[3].LegendText = pJobsFetched.LegendText;
    136       jobChart.Series[3].Points.Add(pJobsFetched);
     137        pJobsFetched.LegendText = "Fetched jobs: " + status.JobsFetched;
     138        pJobsFetched.ToolTip = pJobsFetched.LegendText;
     139        pJobsFetched.Color = System.Drawing.Color.Blue;
     140        jobChart.Series[3].Color = System.Drawing.Color.Blue;
     141        jobChart.Series[3].LegendText = pJobsFetched.LegendText;
     142        jobChart.Series[3].Points.Add(pJobsFetched);
    137143
    138       pJobsFailed.LegendText = "Failed jobs: " + status.JobsFailed;
    139       pJobsFailed.ToolTip = pJobsFailed.LegendText;
    140       pJobsFailed.Color = System.Drawing.Color.Red;
    141       jobChart.Series[4].Color = System.Drawing.Color.Red;
    142       jobChart.Series[4].LegendText = pJobsFailed.LegendText;
    143       jobChart.Series[4].Points.Add(pJobsFailed);
     144        pJobsFailed.LegendText = "Failed jobs: " + status.JobsFailed;
     145        pJobsFailed.ToolTip = pJobsFailed.LegendText;
     146        pJobsFailed.Color = System.Drawing.Color.Red;
     147        jobChart.Series[4].Color = System.Drawing.Color.Red;
     148        jobChart.Series[4].LegendText = pJobsFailed.LegendText;
     149        jobChart.Series[4].Points.Add(pJobsFailed);
     150      }
    144151    }
    145152
    146153    private void RenderCoreChart(StatusCommons statusCommons) {
    147       int usedCores = statusCommons.TotalCores - statusCommons.FreeCores;
    148       DataPoint pFreeCores = new DataPoint(statusCommons.FreeCores, statusCommons.FreeCores);
    149       DataPoint pUsedCores = new DataPoint(usedCores, usedCores);
     154      if (InvokeRequired) {
     155        Invoke(new Action<StatusCommons>(RenderCoreChart), statusCommons);
     156      } else {
     157        int usedCores = statusCommons.TotalCores - statusCommons.FreeCores;
     158        DataPoint pFreeCores = new DataPoint(statusCommons.FreeCores, statusCommons.FreeCores);
     159        DataPoint pUsedCores = new DataPoint(usedCores, usedCores);
    150160
    151       coresChart.Series[0].Points.Clear();
     161        coresChart.Series[0].Points.Clear();
    152162
    153       pFreeCores.LegendText = "Free cores: " + statusCommons.FreeCores;
    154       pFreeCores.Color = System.Drawing.Color.Green;
    155       pUsedCores.LegendText = "Used cores: " + usedCores;
    156       pUsedCores.Color = System.Drawing.Color.Red;
     163        pFreeCores.LegendText = "Free cores: " + statusCommons.FreeCores;
     164        pFreeCores.Color = System.Drawing.Color.Green;
     165        pUsedCores.LegendText = "Used cores: " + usedCores;
     166        pUsedCores.Color = System.Drawing.Color.Red;
    157167
    158       coresChart.Series[0].Points.Add(pFreeCores);
    159       coresChart.Series[0].Points.Add(pUsedCores);
     168        coresChart.Series[0].Points.Add(pFreeCores);
     169        coresChart.Series[0].Points.Add(pUsedCores);
     170      }
    160171    }
    161172  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/SlaveViewTray.cs

    r6734 r6743  
    3737    #region Register Content Events
    3838    protected override void DeregisterContentEvents() {
    39 
    4039      base.DeregisterContentEvents();
    4140    }
     
    4342    protected override void RegisterContentEvents() {
    4443      base.RegisterContentEvents();
    45 
    46 
    4744    }
    4845    #endregion
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs

    r6725 r6743  
    232232      int usedCores = 0;
    233233      try {
    234         task = wcfService.GetJob(taskId);
     234        task = wcfService.GetTask(taskId);
    235235        if (task == null) throw new TaskNotFoundException(taskId);
    236236        if (ConfigManager.Instance.GetFreeCores() < task.CoresNeeded) throw new OutOfCoresException();
    237237        if (ConfigManager.GetFreeMemory() < task.MemoryNeeded) throw new OutOfMemoryException();
    238238        SlaveStatusInfo.IncrementUsedCores(task.CoresNeeded); usedCores = task.CoresNeeded;
    239         TaskData taskData = wcfService.GetJobData(taskId);
     239        TaskData taskData = wcfService.GetTaskData(taskId);
    240240        if (taskData == null) throw new TaskDataNotFoundException(taskId);
    241241        task = wcfService.UpdateJobState(taskId, TaskState.Calculating, null);
     
    273273      Guid taskId = (Guid)taskIdObj;
    274274      try {
    275         Task task = wcfService.GetJob(taskId);
     275        Task task = wcfService.GetTask(taskId);
    276276        if (task == null) throw new TaskNotFoundException(taskId);
    277277        taskManager.StopTaskAsync(taskId);
     
    291291      Guid taskId = (Guid)taskIdObj;
    292292      try {
    293         Task task = wcfService.GetJob(taskId);
     293        Task task = wcfService.GetTask(taskId);
    294294        if (task == null) throw new TaskNotFoundException(taskId);
    295295        taskManager.PauseTaskAsync(taskId);
     
    334334        SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded);
    335335        heartbeatManager.AwakeHeartBeatThread();
    336         Task task = wcfService.GetJob(e.Value.TaskId);
     336        Task task = wcfService.GetTask(e.Value.TaskId);
    337337        if (task == null) throw new TaskNotFoundException(e.Value.TaskId);
    338338        task.ExecutionTime = e.Value.ExecutionTime;
    339339        TaskData taskData = e.Value.GetTaskData();
    340         wcfService.UpdateJobData(task, taskData, configManager.GetClientInfo().Id, TaskState.Paused);
     340        wcfService.UpdateTaskData(task, taskData, configManager.GetClientInfo().Id, TaskState.Paused);
    341341      }
    342342      catch (TaskNotFoundException ex) {
     
    352352        SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded);
    353353        heartbeatManager.AwakeHeartBeatThread();
    354         Task task = wcfService.GetJob(e.Value.TaskId);
     354        Task task = wcfService.GetTask(e.Value.TaskId);
    355355        if (task == null) throw new TaskNotFoundException(e.Value.TaskId);
    356356        task.ExecutionTime = e.Value.ExecutionTime;
    357357        TaskData taskData = e.Value.GetTaskData();
    358         wcfService.UpdateJobData(task, taskData, configManager.GetClientInfo().Id, TaskState.Finished);
     358        wcfService.UpdateTaskData(task, taskData, configManager.GetClientInfo().Id, TaskState.Finished);
    359359      }
    360360      catch (TaskNotFoundException ex) {
     
    374374        Exception exception = e.Value.Item3;
    375375
    376         Task task = wcfService.GetJob(slaveTask.TaskId);
     376        Task task = wcfService.GetTask(slaveTask.TaskId);
    377377        if (task == null) throw new TaskNotFoundException(slaveTask.TaskId);
    378378        task.ExecutionTime = slaveTask.ExecutionTime;
    379379        if (taskData != null) {
    380           wcfService.UpdateJobData(task, taskData, configManager.GetClientInfo().Id, TaskState.Failed, exception.ToString());
     380          wcfService.UpdateTaskData(task, taskData, configManager.GetClientInfo().Id, TaskState.Failed, exception.ToString());
    381381        } else {
    382382          wcfService.UpdateJobState(task.Id, TaskState.Failed, exception.ToString());
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/WcfService.cs

    r6725 r6743  
    5555
    5656    #region Task Methods
    57     public Task GetJob(Guid jobId) {
    58       return CallHiveService(s => s.GetJob(jobId));
     57    public Task GetTask(Guid taskId) {
     58      return CallHiveService(s => s.GetTask(taskId));
    5959    }
    6060
    61     public void UpdateJob(Task job) {
    62       CallHiveService(s => s.UpdateJob(job));
     61    public void UpdateTask(Task task) {
     62      CallHiveService(s => s.UpdateTask(task));
    6363    }
    6464    #endregion
    6565
    6666    #region TaskData Methods
    67     public TaskData GetJobData(Guid jobId) {
    68       return CallHiveService(s => s.GetJobData(jobId));
     67    public TaskData GetTaskData(Guid taskId) {
     68      return CallHiveService(s => s.GetTaskData(taskId));
    6969    }
    7070
    7171    /// <summary>
    72     /// Uploads the taskData and sets a new jobState (while correctly setting Transferring state)
     72    /// Uploads the taskData and sets a new taskState (while correctly setting Transferring state)
    7373    /// </summary>
    74     public void UpdateJobData(Task job, TaskData jobData, Guid slaveId, TaskState state, string exception = "") {
     74    public void UpdateTaskData(Task task, TaskData taskData, Guid slaveId, TaskState state, string exception = "") {
    7575      CallHiveService(service => {
    76         service.UpdateJob(job);
    77         job = service.UpdateJobState(job.Id, TaskState.Transferring, slaveId, null, null);
     76        service.UpdateTask(task);
     77        task = service.UpdateTaskState(task.Id, TaskState.Transferring, slaveId, null, null);
    7878        HiveClient.TryAndRepeat(() => {
    79           service.UpdateJobData(job, jobData);
     79          service.UpdateTaskData(task, taskData);
    8080        }, Settings.Default.PluginDeletionRetries, "Could not upload jobdata.");
    81         service.UpdateJobState(job.Id, state, slaveId, null, exception);
     81        service.UpdateTaskState(task.Id, state, slaveId, null, exception);
    8282      });
    8383    }
    8484
    85     public Task UpdateJobState(Guid jobId, TaskState jobState, string exception) {
    86       return CallHiveService(s => s.UpdateJobState(jobId, jobState, ConfigManager.Instance.GetClientInfo().Id, null, exception));
     85    public Task UpdateJobState(Guid taskId, TaskState taskState, string exception) {
     86      return CallHiveService(s => s.UpdateTaskState(taskId, taskState, ConfigManager.Instance.GetClientInfo().Id, null, exception));
    8787    }
    8888    #endregion
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Tests/ExperimentManagerTests.cs

    r6725 r6743  
    4545      var rhc = new RefreshableJob();
    4646      var optimizer = CreateOptimizer();
    47       rhc.HiveJobs.Add(new OptimizerHiveTask(optimizer));
     47      rhc.HiveTasks.Add(new OptimizerHiveTask(optimizer));
    4848     
    49       HiveClient.StartExperiment((Exception ex) => TestContext.WriteLine(ex.ToString()), rhc, new CancellationToken());
     49      HiveClient.StartJob((Exception ex) => TestContext.WriteLine(ex.ToString()), rhc, new CancellationToken());
    5050
    5151      while (rhc.ExecutionState != Core.ExecutionState.Stopped) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/HiveTaskView.cs

    r6727 r6743  
    129129          this.dateFinishedTextBox.Text = Content.Task.DateFinished.ToString();
    130130          this.exceptionTextBox.Text = Content.Task.CurrentStateLog != null ? Content.Task.CurrentStateLog.Exception : string.Empty;
    131           this.lastUpdatedTextBox.Text = Content.Task.LastJobDataUpdate.ToString();
     131          this.lastUpdatedTextBox.Text = Content.Task.LastTaskDataUpdate.ToString();
    132132        } else {
    133133          this.stateTextBox.Text = string.Empty;
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/ConcurrentTaskDownloader.cs

    r6725 r6743  
    4242    }
    4343
    44     public void DownloadJob(Task job, Action<Task, T> onFinishedAction) {
    45       Task<T> task = Task<TaskData>.Factory.StartNew((x) => DownloadJob(x), job.Id)
    46                                      .ContinueWith((x) => DeserializeJob(x.Result));
    47       task.ContinueWith((x) => OnJobFinished(job, x, onFinishedAction), TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion);
    48       task.ContinueWith((x) => OnJobFailed(job, x, onFinishedAction), TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnFaulted);
     44    public void DownloadTask(Task job, Action<Task, T> onFinishedAction) {
     45      Task<T> task = Task<TaskData>.Factory.StartNew((x) => DownloadTask(x), job.Id)
     46                                     .ContinueWith((x) => DeserializeTask(x.Result));
     47      task.ContinueWith((x) => OnTaskFinished(job, x, onFinishedAction), TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion);
     48      task.ContinueWith((x) => OnTaskFailed(job, x, onFinishedAction), TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnFaulted);
    4949    }
    5050
    51     private void OnJobFinished(Task job, Task<T> task, Action<Task, T> onFinishedAction) {
     51    private void OnTaskFinished(Task job, Task<T> task, Action<Task, T> onFinishedAction) {
    5252      onFinishedAction(job, task.Result);
    5353    }
    54     private void OnJobFailed(Task job, Task<T> task, Action<Task, T> onFinishedAction) {
     54    private void OnTaskFailed(Task job, Task<T> task, Action<Task, T> onFinishedAction) {
    5555      task.Exception.Flatten().Handle((e) => { return true; });
    5656      OnExceptionOccured(task.Exception.Flatten());
     
    5858    }
    5959
    60     protected TaskData DownloadJob(object jobId) {
     60    protected TaskData DownloadTask(object taskId) {
    6161      downloadSemaphore.WaitOne();
    6262      deserializeSemaphore.WaitOne();
     
    6464      try {
    6565        if (abort) return null;
    66         result = ServiceLocator.Instance.CallHiveService(s => s.GetJobData((Guid)jobId));
     66        result = ServiceLocator.Instance.CallHiveService(s => s.GetTaskData((Guid)taskId));
    6767      }
    6868      finally {
     
    7272    }
    7373
    74     protected T DeserializeJob(TaskData jobData) {
     74    protected T DeserializeTask(TaskData taskData) {
    7575      try {
    76         if (abort || jobData == null) return null;
    77         Task job = ServiceLocator.Instance.CallHiveService(s => s.GetJob(jobData.TaskId));
    78         if (job == null) return null;
    79         var deserializedJob = PersistenceUtil.Deserialize<T>(jobData.Data);
    80         jobData.Data = null; // reduce memory consumption.
     76        if (abort || taskData == null) return null;
     77        Task task = ServiceLocator.Instance.CallHiveService(s => s.GetTask(taskData.TaskId));
     78        if (task == null) return null;
     79        var deserializedJob = PersistenceUtil.Deserialize<T>(taskData.Data);
     80        taskData.Data = null; // reduce memory consumption.
    8181        return deserializedJob;
    8282      }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r6725 r6743  
    8686        var oldExperiments = jobs ?? new ItemCollection<RefreshableJob>();
    8787        jobs = new HiveItemCollection<RefreshableJob>();
    88         var experimentsLoaded = ServiceLocator.Instance.CallHiveService<IEnumerable<Job>>(s => s.GetHiveExperiments());
     88        var experimentsLoaded = ServiceLocator.Instance.CallHiveService<IEnumerable<Job>>(s => s.GetJobs());
    8989
    9090        foreach (var he in experimentsLoaded) {
    91           var hiveExperiment = oldExperiments.SingleOrDefault(x => x.Id == he.Id);
    92           if (hiveExperiment == null) {
     91          var job = oldExperiments.SingleOrDefault(x => x.Id == he.Id);
     92          if (job == null) {
    9393            // new
    9494            jobs.Add(new RefreshableJob(he) { IsAllowedPrivileged = this.isAllowedPrivileged });
    9595          } else {
    9696            // update
    97             hiveExperiment.Job = he;
    98             hiveExperiment.IsAllowedPrivileged = this.isAllowedPrivileged;
    99             jobs.Add(hiveExperiment);
     97            job.Job = he;
     98            job.IsAllowedPrivileged = this.isAllowedPrivileged;
     99            jobs.Add(job);
    100100          }
    101101        }
     
    139139      if (item.Id == Guid.Empty) {
    140140        if (item is RefreshableJob) {
    141           HiveClient.Instance.UploadExperiment((RefreshableJob)item, cancellationToken);
     141          HiveClient.Instance.UploadJob((RefreshableJob)item, cancellationToken);
    142142        }
    143143        if (item is JobPermission) {
     
    151151      } else {
    152152        if (item is Job)
    153           ServiceLocator.Instance.CallHiveService(s => s.UpdateHiveExperiment((Job)item));
     153          ServiceLocator.Instance.CallHiveService(s => s.UpdateJob((Job)item));
    154154      }
    155155    }
     
    177177
    178178      if (item is Job)
    179         ServiceLocator.Instance.CallHiveService(s => s.DeleteHiveExperiment(item.Id));
     179        ServiceLocator.Instance.CallHiveService(s => s.DeleteJob(item.Id));
    180180      if (item is RefreshableJob)
    181         ServiceLocator.Instance.CallHiveService(s => s.DeleteHiveExperiment(item.Id));
     181        ServiceLocator.Instance.CallHiveService(s => s.DeleteJob(item.Id));
    182182      if (item is JobPermission) {
    183183        var hep = (JobPermission)item;
     
    206206    #endregion
    207207
    208     public static void StartExperiment(Action<Exception> exceptionCallback, RefreshableJob refreshableJob, CancellationToken cancellationToken) {
     208    public static void StartJob(Action<Exception> exceptionCallback, RefreshableJob refreshableJob, CancellationToken cancellationToken) {
    209209      HiveClient.StoreAsync(
    210210        new Action<Exception>((Exception ex) => {
     
    215215    }
    216216
    217     public static void PauseExperiment(RefreshableJob refreshableHiveExperiment) {
     217    public static void PauseJob(RefreshableJob refreshableJob) {
    218218      ServiceLocator.Instance.CallHiveService(service => {
    219         foreach (HiveTask job in refreshableHiveExperiment.GetAllHiveJobs()) {
    220           if (job.Task.State != TaskState.Finished && job.Task.State != TaskState.Aborted && job.Task.State != TaskState.Failed)
    221             service.PauseJob(job.Task.Id);
     219        foreach (HiveTask task in refreshableJob.GetAllHiveTasks()) {
     220          if (task.Task.State != TaskState.Finished && task.Task.State != TaskState.Aborted && task.Task.State != TaskState.Failed)
     221            service.PauseTask(task.Task.Id);
    222222        }
    223223      });
    224       refreshableHiveExperiment.ExecutionState = ExecutionState.Paused;
    225     }
    226 
    227     public static void StopExperiment(RefreshableJob refreshableJob) {
     224      refreshableJob.ExecutionState = ExecutionState.Paused;
     225    }
     226
     227    public static void StopJob(RefreshableJob refreshableJob) {
    228228      ServiceLocator.Instance.CallHiveService(service => {
    229         foreach (HiveTask job in refreshableJob.GetAllHiveJobs()) {
    230           if (job.Task.State != TaskState.Finished && job.Task.State != TaskState.Aborted && job.Task.State != TaskState.Failed)
    231             service.StopJob(job.Task.Id);
     229        foreach (HiveTask task in refreshableJob.GetAllHiveTasks()) {
     230          if (task.Task.State != TaskState.Finished && task.Task.State != TaskState.Aborted && task.Task.State != TaskState.Failed)
     231            service.StopTask(task.Task.Id);
    232232        }
    233233      });
     
    235235    }
    236236
    237     #region Upload Experiment
     237    #region Upload Job
    238238    private Semaphore jobUploadSemaphore = new Semaphore(4, 4); // todo: take magic number into config
    239239    private static object jobCountLocker = new object();
    240240    private static object pluginLocker = new object();
    241     private void UploadExperiment(RefreshableJob refreshableJob, CancellationToken cancellationToken) {
     241    private void UploadJob(RefreshableJob refreshableJob, CancellationToken cancellationToken) {
    242242      try {
    243243        refreshableJob.Progress = new Progress("Connecting to server...");
     
    254254        }
    255255
    256         foreach (OptimizerHiveTask hiveJob in refreshableJob.HiveJobs.OfType<OptimizerHiveTask>()) {
     256        foreach (OptimizerHiveTask hiveJob in refreshableJob.HiveTasks.OfType<OptimizerHiveTask>()) {
    257257          hiveJob.SetIndexInParentOptimizerList(null);
    258258        }
     
    260260        // upload Task
    261261        refreshableJob.Progress.Status = "Uploading Task...";
    262         refreshableJob.Job.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddHiveExperiment(refreshableJob.Job));
     262        refreshableJob.Job.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddJob(refreshableJob.Job));
    263263        bool isPrivileged = refreshableJob.Job.IsPrivileged;
    264         refreshableJob.Job = ServiceLocator.Instance.CallHiveService((s) => s.GetHiveExperiment(refreshableJob.Job.Id)); // update owner and permissions
     264        refreshableJob.Job = ServiceLocator.Instance.CallHiveService((s) => s.GetJob(refreshableJob.Job.Id)); // update owner and permissions
    265265        refreshableJob.Job.IsPrivileged = isPrivileged;
    266266        cancellationToken.ThrowIfCancellationRequested();
    267267
    268         int totalJobCount = refreshableJob.GetAllHiveJobs().Count();
     268        int totalJobCount = refreshableJob.GetAllHiveTasks().Count();
    269269        int[] jobCount = new int[1]; // use a reference type (int-array) instead of value type (int) in order to pass the value via a delegate to task-parallel-library
    270270        cancellationToken.ThrowIfCancellationRequested();
     
    284284
    285285        var tasks = new List<TS.Task>();
    286         foreach (HiveTask hiveJob in refreshableJob.HiveJobs) {
     286        foreach (HiveTask hiveJob in refreshableJob.HiveTasks) {
    287287          tasks.Add(TS.Task.Factory.StartNew((hj) => {
    288             UploadJobWithChildren(refreshableJob.Progress, (HiveTask)hj, null, resourceIds, jobCount, totalJobCount, configFilePlugin.Id, refreshableJob.Job.Id, refreshableJob.Log, refreshableJob.Job.IsPrivileged, cancellationToken);
     288            UploadTaskWithChildren(refreshableJob.Progress, (HiveTask)hj, null, resourceIds, jobCount, totalJobCount, configFilePlugin.Id, refreshableJob.Job.Id, refreshableJob.Log, refreshableJob.Job.IsPrivileged, cancellationToken);
    289289          }, hiveJob)
    290290          .ContinueWith((x) => refreshableJob.Log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted));
     
    334334    /// </summary>
    335335    /// <param name="parentHiveTask">shall be null if its the root task</param>
    336     private void UploadJobWithChildren(IProgress progress, HiveTask hiveJob, HiveTask parentHiveJob, IEnumerable<Guid> groups, int[] jobCount, int totalJobCount, Guid configPluginId, Guid hiveExperimentId, ILog log, bool isPrivileged, CancellationToken cancellationToken) {
     336    private void UploadTaskWithChildren(IProgress progress, HiveTask hiveTask, HiveTask parentHiveJob, IEnumerable<Guid> groups, int[] taskCount, int totalJobCount, Guid configPluginId, Guid jobId, ILog log, bool isPrivileged, CancellationToken cancellationToken) {
    337337      jobUploadSemaphore.WaitOne();
    338338      bool semaphoreReleased = false;
     
    340340        cancellationToken.ThrowIfCancellationRequested();
    341341        lock (jobCountLocker) {
    342           jobCount[0]++;
     342          taskCount[0]++;
    343343        }
    344344        TaskData jobData;
    345345        List<IPluginDescription> plugins;
    346346
    347         if (hiveJob.ItemTask.ComputeInParallel && (hiveJob.ItemTask.Item is Optimization.Experiment || hiveJob.ItemTask.Item is Optimization.BatchRun)) {
    348           hiveJob.Task.IsParentTask = true;
    349           hiveJob.Task.FinishWhenChildJobsFinished = true;
    350           jobData = hiveJob.GetAsTaskData(true, out plugins);
     347        if (hiveTask.ItemTask.ComputeInParallel && (hiveTask.ItemTask.Item is Optimization.Experiment || hiveTask.ItemTask.Item is Optimization.BatchRun)) {
     348          hiveTask.Task.IsParentTask = true;
     349          hiveTask.Task.FinishWhenChildJobsFinished = true;
     350          jobData = hiveTask.GetAsTaskData(true, out plugins);
    351351        } else {
    352           hiveJob.Task.IsParentTask = false;
    353           hiveJob.Task.FinishWhenChildJobsFinished = false;
    354           jobData = hiveJob.GetAsTaskData(false, out plugins);
     352          hiveTask.Task.IsParentTask = false;
     353          hiveTask.Task.FinishWhenChildJobsFinished = false;
     354          jobData = hiveTask.GetAsTaskData(false, out plugins);
    355355        }
    356356        cancellationToken.ThrowIfCancellationRequested();
     
    359359          if (!cancellationToken.IsCancellationRequested) {
    360360            lock (pluginLocker) {
    361               ServiceLocator.Instance.CallHiveService((s) => hiveJob.Task.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins));
     361              ServiceLocator.Instance.CallHiveService((s) => hiveTask.Task.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins));
    362362            }
    363363          }
    364364        }, -1, "Failed to upload plugins");
    365365        cancellationToken.ThrowIfCancellationRequested();
    366         hiveJob.Task.PluginsNeededIds.Add(configPluginId);
    367         hiveJob.Task.JobId = hiveExperimentId;
    368         hiveJob.Task.IsPrivileged = isPrivileged;
    369 
    370         log.LogMessage(string.Format("Uploading task ({0} kb, {1} objects)", jobData.Data.Count() / 1024, hiveJob.ItemTask.GetObjectGraphObjects().Count()));
     366        hiveTask.Task.PluginsNeededIds.Add(configPluginId);
     367        hiveTask.Task.JobId = jobId;
     368        hiveTask.Task.IsPrivileged = isPrivileged;
     369
     370        log.LogMessage(string.Format("Uploading task ({0} kb, {1} objects)", jobData.Data.Count() / 1024, hiveTask.ItemTask.GetObjectGraphObjects().Count()));
    371371        TryAndRepeat(() => {
    372372          if (!cancellationToken.IsCancellationRequested) {
    373373            if (parentHiveJob != null) {
    374               hiveJob.Task.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddChildJob(parentHiveJob.Task.Id, hiveJob.Task, jobData));
     374              hiveTask.Task.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddChildTask(parentHiveJob.Task.Id, hiveTask.Task, jobData));
    375375            } else {
    376               hiveJob.Task.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddJob(hiveJob.Task, jobData, groups.ToList()));
     376              hiveTask.Task.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddTask(hiveTask.Task, jobData, groups.ToList()));
    377377            }
    378378          }
     
    381381
    382382        lock (jobCountLocker) {
    383           progress.ProgressValue = (double)jobCount[0] / totalJobCount;
    384           progress.Status = string.Format("Uploaded task ({0} of {1})", jobCount[0], totalJobCount);
     383          progress.ProgressValue = (double)taskCount[0] / totalJobCount;
     384          progress.Status = string.Format("Uploaded task ({0} of {1})", taskCount[0], totalJobCount);
    385385        }
    386386
    387387        var tasks = new List<TS.Task>();
    388         foreach (HiveTask child in hiveJob.ChildHiveTasks) {
     388        foreach (HiveTask child in hiveTask.ChildHiveTasks) {
    389389          tasks.Add(TS.Task.Factory.StartNew((tuple) => {
    390390            var arguments = (Tuple<HiveTask, HiveTask>)tuple;
    391             UploadJobWithChildren(progress, arguments.Item1, arguments.Item2, groups, jobCount, totalJobCount, configPluginId, hiveExperimentId, log, isPrivileged, cancellationToken);
    392           }, new Tuple<HiveTask, HiveTask>(child, hiveJob))
     391            UploadTaskWithChildren(progress, arguments.Item1, arguments.Item2, groups, taskCount, totalJobCount, configPluginId, jobId, log, isPrivileged, cancellationToken);
     392          }, new Tuple<HiveTask, HiveTask>(child, hiveTask))
    393393          .ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted));
    394394        }
     
    408408
    409409    #region Download Experiment
    410     public static void LoadExperiment(RefreshableJob refreshableJob) {
     410    public static void LoadJob(RefreshableJob refreshableJob) {
    411411      var hiveExperiment = refreshableJob.Job;
    412412      refreshableJob.Progress = new Progress();
     
    415415        refreshableJob.IsProgressing = true;
    416416        int totalJobCount = 0;
    417         IEnumerable<LightweightTask> allJobs;
     417        IEnumerable<LightweightTask> allTasks;
    418418
    419419        refreshableJob.Progress.Status = "Connecting to Server...";
    420420        // fetch all Task objects to create the full tree of tree of HiveTask objects
    421421        refreshableJob.Progress.Status = "Downloading list of jobs...";
    422         allJobs = ServiceLocator.Instance.CallHiveService(s => s.GetLightweightExperimentJobs(hiveExperiment.Id));
    423         totalJobCount = allJobs.Count();
    424 
    425         TaskDownloader downloader = new TaskDownloader(allJobs.Select(x => x.Id));
     422        allTasks = ServiceLocator.Instance.CallHiveService(s => s.GetLightweightJobTasks(hiveExperiment.Id));
     423        totalJobCount = allTasks.Count();
     424
     425        TaskDownloader downloader = new TaskDownloader(allTasks.Select(x => x.Id));
    426426        downloader.StartAsync();
    427427
     
    435435          }
    436436        }
    437         IDictionary<Guid, HiveTask> allHiveJobs = downloader.Results;
    438 
    439         refreshableJob.HiveJobs = new ItemCollection<HiveTask>(allHiveJobs.Values.Where(x => !x.Task.ParentTaskId.HasValue));
     437        IDictionary<Guid, HiveTask> allHiveTasks = downloader.Results;
     438
     439        refreshableJob.HiveTasks = new ItemCollection<HiveTask>(allHiveTasks.Values.Where(x => !x.Task.ParentTaskId.HasValue));
    440440
    441441        if (refreshableJob.IsFinished()) {
     
    446446
    447447        // build child-task tree
    448         foreach (HiveTask hiveJob in refreshableJob.HiveJobs) {
    449           BuildHiveJobTree(hiveJob, allJobs, allHiveJobs);
     448        foreach (HiveTask hiveTask in refreshableJob.HiveTasks) {
     449          BuildHiveJobTree(hiveTask, allTasks, allHiveTasks);
    450450        }
    451451
     
    482482
    483483    public static ItemTask LoadItemJob(Guid jobId) {
    484       TaskData jobData = ServiceLocator.Instance.CallHiveService(s => s.GetJobData(jobId));
     484      TaskData jobData = ServiceLocator.Instance.CallHiveService(s => s.GetTaskData(jobId));
    485485      try {
    486486        return PersistenceUtil.Deserialize<ItemTask>(jobData.Data);
     
    506506    }
    507507
    508     public static HiveItemCollection<JobPermission> GetHiveExperimentPermissions(Guid hiveExperimentId) {
     508    public static HiveItemCollection<JobPermission> GetJobPermissions(Guid jobId) {
    509509      return ServiceLocator.Instance.CallHiveService((service) => {
    510         IEnumerable<JobPermission> heps = service.GetHiveExperimentPermissions(hiveExperimentId);
    511         foreach (var hep in heps) {
     510        IEnumerable<JobPermission> jps = service.GetJobPermissions(jobId);
     511        foreach (var hep in jps) {
    512512          hep.GrantedUserName = service.GetUsernameByUserId(hep.GrantedUserId);
    513513        }
    514         return new HiveItemCollection<JobPermission>(heps);
     514        return new HiveItemCollection<JobPermission>(jps);
    515515      });
    516516    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/HiveJobs/HiveTask.cs

    r6727 r6743  
    341341
    342342    /// <summary>
    343     /// Returns a list of HiveJobs including this and all its child-jobs recursively
     343    /// Returns a list of HiveTasks including this and all its child-jobs recursively
    344344    /// </summary>
    345345    public IEnumerable<HiveTask> GetAllHiveTasks() {
     
    453453        try {
    454454          foreach (var child in childHiveTasks) {
    455             ServiceLocator.Instance.CallHiveService(s => s.PauseJob(child.task.Id));
     455            ServiceLocator.Instance.CallHiveService(s => s.PauseTask(child.task.Id));
    456456          }
    457457        }
    458458        finally { childHiveTasksLock.ExitReadLock(); }
    459459      } else {
    460         ServiceLocator.Instance.CallHiveService(s => s.PauseJob(this.task.Id));
     460        ServiceLocator.Instance.CallHiveService(s => s.PauseTask(this.task.Id));
    461461      }
    462462    }
     
    467467        try {
    468468          foreach (var child in childHiveTasks) {
    469             ServiceLocator.Instance.CallHiveService(s => s.StopJob(child.task.Id));
     469            ServiceLocator.Instance.CallHiveService(s => s.StopTask(child.task.Id));
    470470          }
    471471        }
    472472        finally { childHiveTasksLock.ExitReadLock(); }
    473473      } else {
    474         ServiceLocator.Instance.CallHiveService(s => s.StopJob(this.task.Id));
     474        ServiceLocator.Instance.CallHiveService(s => s.StopTask(this.task.Id));
    475475      }
    476476    }
     
    481481        taskData.TaskId = this.task.Id;
    482482        taskData.Data = PersistenceUtil.Serialize(this.itemTask);
    483         service.UpdateJobData(this.Task, taskData);
    484         service.RestartJob(this.task.Id);
    485         Task job = service.GetJob(this.task.Id);
    486         this.task.LastJobDataUpdate = job.LastJobDataUpdate;
     483        service.UpdateTaskData(this.Task, taskData);
     484        service.RestartTask(this.task.Id);
     485        Task task = service.GetTask(this.task.Id);
     486        this.task.LastTaskDataUpdate = task.LastTaskDataUpdate;
    487487      });
    488488    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/JobResultPoller.cs

    r6726 r6743  
    108108      return ServiceLocator.Instance.CallHiveService(service => {
    109109        var responses = new List<LightweightTask>();
    110         responses.AddRange(service.GetLightweightExperimentJobs(jobId));
     110        responses.AddRange(service.GetLightweightJobTasks(jobId));
    111111        OnJobResultsReceived(responses);
    112112        return responses;
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/RefreshableJob.cs

    r6725 r6743  
    5555    }
    5656
    57     private ItemCollection<HiveTask> hiveJobs;
    58     public ItemCollection<HiveTask> HiveJobs {
    59       get { return hiveJobs; }
     57    private ItemCollection<HiveTask> hiveTasks;
     58    public ItemCollection<HiveTask> HiveTasks {
     59      get { return hiveTasks; }
    6060      set {
    61         if (hiveJobs != value) {
    62           if (hiveJobs != null) DeregisterHiveJobsEvents();
    63           hiveJobs = value;
    64           if (hiveJobs != null) RegisterHiveJobsEvents();
     61        if (hiveTasks != value) {
     62          if (hiveTasks != null) DeregisterHiveJobsEvents();
     63          hiveTasks = value;
     64          if (hiveTasks != null) RegisterHiveJobsEvents();
    6565          OnHiveJobsChanged();
    6666        }
     
    100100          }
    101101          if (RefreshAutomatically) {
    102             if (this.HiveJobs != null && this.HiveJobs.Count > 0 && (jobResultPoller == null || !jobResultPoller.IsPolling)) {
     102            if (this.HiveTasks != null && this.HiveTasks.Count > 0 && (jobResultPoller == null || !jobResultPoller.IsPolling)) {
    103103              StartResultPolling();
    104104            }
     
    130130          isControllable = value;
    131131          OnIsControllableChanged();
    132           if (this.hiveJobs != null) {
    133             foreach (var hiveJob in this.hiveJobs) {
     132          if (this.hiveTasks != null) {
     133            foreach (var hiveJob in this.hiveTasks) {
    134134              hiveJob.IsControllable = value;
    135135            }
     
    186186
    187187    public StateLogListList StateLogList {
    188       get { return new StateLogListList(this.GetAllHiveJobs().Select(x => x.StateLog)); }
     188      get { return new StateLogListList(this.GetAllHiveTasks().Select(x => x.StateLog)); }
    189189    }
    190190
     
    196196      this.jobDownloader = new ConcurrentTaskDownloader<ItemTask>(2, 2);
    197197      this.jobDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobDownloader_ExceptionOccured);
    198       this.HiveJobs = new ItemCollection<HiveTask>();
     198      this.HiveTasks = new ItemCollection<HiveTask>();
    199199    }
    200200    public RefreshableJob(Job hiveExperiment) {
     
    204204      this.jobDownloader = new ConcurrentTaskDownloader<ItemTask>(2, 2);
    205205      this.jobDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobDownloader_ExceptionOccured);
    206       this.HiveJobs = new ItemCollection<HiveTask>();
     206      this.HiveTasks = new ItemCollection<HiveTask>();
    207207    }
    208208    protected RefreshableJob(RefreshableJob original, Cloner cloner) {
     
    214214      this.jobDownloader = new ConcurrentTaskDownloader<ItemTask>(2, 2);
    215215      this.jobDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobDownloader_ExceptionOccured);
    216       this.HiveJobs = cloner.Clone(original.HiveJobs);
     216      this.HiveTasks = cloner.Clone(original.HiveTasks);
    217217      this.ExecutionTime = original.ExecutionTime;
    218218      this.ExecutionState = original.ExecutionState;
     
    263263    }
    264264    private void jobResultPoller_JobResultReceived(object sender, EventArgs<IEnumerable<LightweightTask>> e) {
    265       foreach (LightweightTask lightweightJob in e.Value) {
    266         HiveTask hiveJob = GetHiveJobById(lightweightJob.Id);
    267         if (hiveJob != null) {
     265      foreach (LightweightTask lightweightTask in e.Value) {
     266        HiveTask hiveTask = GetHiveJobById(lightweightTask.Id);
     267        if (hiveTask != null) {
    268268          // lastJobDataUpdate equals DateTime.MinValue right after it was uploaded. When the first results are polled, this value is updated
    269           if (hiveJob.Task.State == TaskState.Offline && lightweightJob.State != TaskState.Finished && lightweightJob.State != TaskState.Failed && lightweightJob.State != TaskState.Aborted) {
    270             hiveJob.Task.LastJobDataUpdate = lightweightJob.LastJobDataUpdate;
     269          if (hiveTask.Task.State == TaskState.Offline && lightweightTask.State != TaskState.Finished && lightweightTask.State != TaskState.Failed && lightweightTask.State != TaskState.Aborted) {
     270            hiveTask.Task.LastTaskDataUpdate = lightweightTask.LastTaskDataUpdate;
    271271          }
    272272
    273           hiveJob.UpdateFromLightweightJob(lightweightJob);
    274 
    275           if (!hiveJob.IsFinishedTaskDownloaded && !hiveJob.IsDownloading && hiveJob.Task.LastJobDataUpdate < lightweightJob.LastJobDataUpdate) {
    276             log.LogMessage(string.Format("Downloading task {0}", lightweightJob.Id));
    277             hiveJob.IsDownloading = true;
    278             jobDownloader.DownloadJob(hiveJob.Task, (localJob, itemJob) => {
     273          hiveTask.UpdateFromLightweightJob(lightweightTask);
     274
     275          if (!hiveTask.IsFinishedTaskDownloaded && !hiveTask.IsDownloading && hiveTask.Task.LastTaskDataUpdate < lightweightTask.LastTaskDataUpdate) {
     276            log.LogMessage(string.Format("Downloading task {0}", lightweightTask.Id));
     277            hiveTask.IsDownloading = true;
     278            jobDownloader.DownloadTask(hiveTask.Task, (localJob, itemJob) => {
    279279              log.LogMessage(string.Format("Finished downloading task {0}", localJob.Id));
    280               HiveTask localHiveJob = GetHiveJobById(localJob.Id);
     280              HiveTask localHiveTask = GetHiveJobById(localJob.Id);
    281281
    282282              if (itemJob == null) {
    283                 localHiveJob.IsDownloading = false;
     283                localHiveTask.IsDownloading = false;
    284284              }
    285285
     
    290290
    291291                if (localJob.State == TaskState.Paused) {
    292                   localHiveJob.ItemTask = itemJob;
     292                  localHiveTask.ItemTask = itemJob;
    293293                } else {
    294294                  if (localJob.ParentTaskId.HasValue) {
    295                     HiveTask parentHiveJob = GetHiveJobById(localJob.ParentTaskId.Value);
    296                     parentHiveJob.IntegrateChild(itemJob, localJob.Id);
     295                    HiveTask parentHiveTask = GetHiveJobById(localJob.ParentTaskId.Value);
     296                    parentHiveTask.IntegrateChild(itemJob, localJob.Id);
    297297                  } else {
    298                     localHiveJob.ItemTask = itemJob;
     298                    localHiveTask.ItemTask = itemJob;
    299299                  }
    300300                }
    301                 localHiveJob.IsDownloading = false;
    302                 localHiveJob.Task.LastJobDataUpdate = localJob.LastJobDataUpdate;
     301                localHiveTask.IsDownloading = false;
     302                localHiveTask.Task.LastTaskDataUpdate = localJob.LastTaskDataUpdate;
    303303              }
    304304            });
     
    317317
    318318    public HiveTask GetHiveJobById(Guid jobId) {
    319       foreach (HiveTask job in this.HiveJobs) {
     319      foreach (HiveTask job in this.HiveTasks) {
    320320        var hj = job.GetHiveTaskByTaskId(jobId);
    321321        if (hj != null)
     
    325325    }
    326326    private void UpdateStatistics() {
    327       var jobs = this.GetAllHiveJobs();
     327      var jobs = this.GetAllHiveTasks();
    328328      job.JobCount = jobs.Count();
    329329      job.CalculatingCount = jobs.Count(j => j.Task.State == TaskState.Calculating);
     
    333333
    334334    public bool AllJobsFinished() {
    335       return this.GetAllHiveJobs().All(j => (j.Task.State == TaskState.Finished
     335      return this.GetAllHiveTasks().All(j => (j.Task.State == TaskState.Finished
    336336                                                   || j.Task.State == TaskState.Aborted
    337337                                                   || j.Task.State == TaskState.Failed)
     
    346346    }
    347347    public void UpdateTotalExecutionTime() {
    348       this.ExecutionTime = TimeSpan.FromMilliseconds(this.GetAllHiveJobs().Sum(x => x.Task.ExecutionTime.TotalMilliseconds));
     348      this.ExecutionTime = TimeSpan.FromMilliseconds(this.GetAllHiveTasks().Sum(x => x.Task.ExecutionTime.TotalMilliseconds));
    349349    }
    350350    #endregion
     
    468468    #endregion
    469469
    470     #region HiveJobs Events
     470    #region HiveTasks Events
    471471    private void RegisterHiveJobsEvents() {
    472       this.hiveJobs.ItemsAdded += new CollectionItemsChangedEventHandler<HiveTask>(hiveJobs_ItemsAdded);
    473       this.hiveJobs.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveTask>(hiveJobs_ItemsRemoved);
    474       this.hiveJobs.CollectionReset += new CollectionItemsChangedEventHandler<HiveTask>(hiveJobs_CollectionReset);
     472      this.hiveTasks.ItemsAdded += new CollectionItemsChangedEventHandler<HiveTask>(hiveJobs_ItemsAdded);
     473      this.hiveTasks.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveTask>(hiveJobs_ItemsRemoved);
     474      this.hiveTasks.CollectionReset += new CollectionItemsChangedEventHandler<HiveTask>(hiveJobs_CollectionReset);
    475475    }
    476476
    477477    private void DeregisterHiveJobsEvents() {
    478       this.hiveJobs.ItemsAdded -= new CollectionItemsChangedEventHandler<HiveTask>(hiveJobs_ItemsAdded);
    479       this.hiveJobs.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveTask>(hiveJobs_ItemsRemoved);
    480       this.hiveJobs.CollectionReset -= new CollectionItemsChangedEventHandler<HiveTask>(hiveJobs_CollectionReset);
     478      this.hiveTasks.ItemsAdded -= new CollectionItemsChangedEventHandler<HiveTask>(hiveJobs_ItemsAdded);
     479      this.hiveTasks.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveTask>(hiveJobs_ItemsRemoved);
     480      this.hiveTasks.CollectionReset -= new CollectionItemsChangedEventHandler<HiveTask>(hiveJobs_CollectionReset);
    481481    }
    482482
     
    514514        DeregisterResultPollingEvents();
    515515      }
    516       if (this.HiveJobs != null && this.HiveJobs.Count > 0 && this.GetAllHiveJobs().All(x => x.Task.Id != Guid.Empty)) {
     516      if (this.HiveTasks != null && this.HiveTasks.Count > 0 && this.GetAllHiveTasks().All(x => x.Task.Id != Guid.Empty)) {
    517517        if (this.RefreshAutomatically)
    518518          StartResultPolling();
     
    581581
    582582    public bool IsFinished() {
    583       return HiveJobs != null
    584         && HiveJobs.All(x => x.Task.DateFinished.HasValue && x.Task.DateCreated.HasValue);
    585     }
    586 
    587     public IEnumerable<HiveTask> GetAllHiveJobs() {
    588       if (hiveJobs == null) return Enumerable.Empty<HiveTask>();
    589 
    590       var jobs = new List<HiveTask>();
    591       foreach (HiveTask job in HiveJobs) {
    592         jobs.AddRange(job.GetAllHiveTasks());
    593       }
    594       return jobs;
     583      return HiveTasks != null
     584        && HiveTasks.All(x => x.Task.DateFinished.HasValue && x.Task.DateCreated.HasValue);
     585    }
     586
     587    public IEnumerable<HiveTask> GetAllHiveTasks() {
     588      if (hiveTasks == null) return Enumerable.Empty<HiveTask>();
     589
     590      var tasks = new List<HiveTask>();
     591      foreach (HiveTask task in HiveTasks) {
     592        tasks.AddRange(task.GetAllHiveTasks());
     593      }
     594      return tasks;
    595595    }
    596596
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveServiceClient.cs

    r6725 r6743  
    5959
    6060    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
    61 
    62 
    6361  }
    6462
     
    7775
    7876    [System.Runtime.Serialization.OptionalFieldAttribute()]
    79     private System.DateTime LastJobDataUpdateField;
     77    private System.DateTime LastTaskDataUpdateField;
    8078
    8179    [System.Runtime.Serialization.OptionalFieldAttribute()]
     
    115113
    116114    [System.Runtime.Serialization.DataMemberAttribute()]
    117     public System.DateTime LastJobDataUpdate {
    118       get {
    119         return this.LastJobDataUpdateField;
    120       }
    121       set {
    122         if ((this.LastJobDataUpdateField.Equals(value) != true)) {
    123           this.LastJobDataUpdateField = value;
    124           this.RaisePropertyChanged("LastJobDataUpdate");
     115    public System.DateTime LastTaskDataUpdate {
     116      get {
     117        return this.LastTaskDataUpdateField;
     118      }
     119      set {
     120        if ((this.LastTaskDataUpdateField.Equals(value) != true)) {
     121          this.LastTaskDataUpdateField = value;
     122          this.RaisePropertyChanged("LastTaskDataUpdate");
    125123        }
    126124      }
     
    15771575    System.Guid GetResourceId(string resourceName);
    15781576
    1579     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetJobsByResourceId", ReplyAction = "http://tempuri.org/IHiveService/GetJobsByResourceIdResponse")]
    1580     System.Collections.Generic.List<HeuristicLab.Clients.Hive.Task> GetJobsByResourceId(System.Guid resourceId);
     1577    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetTasksByResourceId", ReplyAction = "http://tempuri.org/IHiveService/GetTasksByResourceIdResponse")]
     1578    System.Collections.Generic.List<HeuristicLab.Clients.Hive.Task> GetTasksByResourceId(System.Guid resourceId);
    15811579
    15821580    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/TriggerEventManager", ReplyAction = "http://tempuri.org/IHiveService/TriggerEventManagerResponse")]
     
    16011599    System.Guid GetUserIdByUsername(string username);
    16021600
     1601    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AddTask", ReplyAction = "http://tempuri.org/IHiveService/AddTaskResponse")]
     1602    System.Guid AddTask(HeuristicLab.Clients.Hive.Task task, HeuristicLab.Clients.Hive.TaskData taskData, System.Collections.Generic.List<System.Guid> resourceIds);
     1603
     1604    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AddChildTask", ReplyAction = "http://tempuri.org/IHiveService/AddChildTaskResponse")]
     1605    System.Guid AddChildTask(System.Guid parentTaskId, HeuristicLab.Clients.Hive.Task task, HeuristicLab.Clients.Hive.TaskData taskData);
     1606
     1607    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetTask", ReplyAction = "http://tempuri.org/IHiveService/GetTaskResponse")]
     1608    HeuristicLab.Clients.Hive.Task GetTask(System.Guid taskId);
     1609
     1610    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetTasks", ReplyAction = "http://tempuri.org/IHiveService/GetTasksResponse")]
     1611    System.Collections.Generic.List<HeuristicLab.Clients.Hive.Task> GetTasks();
     1612
     1613    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetLightweightTasks", ReplyAction = "http://tempuri.org/IHiveService/GetLightweightTasksResponse")]
     1614    System.Collections.Generic.List<HeuristicLab.Clients.Hive.LightweightTask> GetLightweightTasks(System.Collections.Generic.List<System.Guid> taskIds);
     1615
     1616    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetLightweightChildTasks", ReplyAction = "http://tempuri.org/IHiveService/GetLightweightChildTasksResponse")]
     1617    System.Collections.Generic.List<HeuristicLab.Clients.Hive.LightweightTask> GetLightweightChildTasks(System.Nullable<System.Guid> parentTaskId, bool recursive, bool includeParent);
     1618
     1619    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetLightweightJobTasks", ReplyAction = "http://tempuri.org/IHiveService/GetLightweightJobTasksResponse")]
     1620    System.Collections.Generic.List<HeuristicLab.Clients.Hive.LightweightTask> GetLightweightJobTasks(System.Guid jobId);
     1621
     1622    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetTaskData", ReplyAction = "http://tempuri.org/IHiveService/GetTaskDataResponse")]
     1623    HeuristicLab.Clients.Hive.TaskData GetTaskData(System.Guid taskId);
     1624
     1625    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/UpdateTask", ReplyAction = "http://tempuri.org/IHiveService/UpdateTaskResponse")]
     1626    void UpdateTask(HeuristicLab.Clients.Hive.Task taskDto);
     1627
     1628    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/UpdateTaskData", ReplyAction = "http://tempuri.org/IHiveService/UpdateTaskDataResponse")]
     1629    void UpdateTaskData(HeuristicLab.Clients.Hive.Task taskDto, HeuristicLab.Clients.Hive.TaskData taskDataDto);
     1630
     1631    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/DeleteTask", ReplyAction = "http://tempuri.org/IHiveService/DeleteTaskResponse")]
     1632    void DeleteTask(System.Guid taskId);
     1633
     1634    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/DeleteChildTasks", ReplyAction = "http://tempuri.org/IHiveService/DeleteChildTasksResponse")]
     1635    void DeleteChildTasks(System.Guid parentTaskId);
     1636
     1637    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/UpdateTaskState", ReplyAction = "http://tempuri.org/IHiveService/UpdateTaskStateResponse")]
     1638    HeuristicLab.Clients.Hive.Task UpdateTaskState(System.Guid taskId, HeuristicLab.Clients.Hive.TaskState taskState, System.Nullable<System.Guid> slaveId, System.Nullable<System.Guid> userId, string exception);
     1639
     1640    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/StopTask", ReplyAction = "http://tempuri.org/IHiveService/StopTaskResponse")]
     1641    void StopTask(System.Guid taskId);
     1642
     1643    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/PauseTask", ReplyAction = "http://tempuri.org/IHiveService/PauseTaskResponse")]
     1644    void PauseTask(System.Guid taskId);
     1645
     1646    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/RestartTask", ReplyAction = "http://tempuri.org/IHiveService/RestartTaskResponse")]
     1647    void RestartTask(System.Guid taskId);
     1648
     1649    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetJob", ReplyAction = "http://tempuri.org/IHiveService/GetJobResponse")]
     1650    HeuristicLab.Clients.Hive.Job GetJob(System.Guid id);
     1651
     1652    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetJobs", ReplyAction = "http://tempuri.org/IHiveService/GetJobsResponse")]
     1653    System.Collections.Generic.List<HeuristicLab.Clients.Hive.Job> GetJobs();
     1654
     1655    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetAllJobs", ReplyAction = "http://tempuri.org/IHiveService/GetAllJobsResponse")]
     1656    System.Collections.Generic.List<HeuristicLab.Clients.Hive.Job> GetAllJobs();
     1657
    16031658    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AddJob", ReplyAction = "http://tempuri.org/IHiveService/AddJobResponse")]
    1604     System.Guid AddJob(HeuristicLab.Clients.Hive.Task job, HeuristicLab.Clients.Hive.TaskData jobData, System.Collections.Generic.List<System.Guid> resourceIds);
    1605 
    1606     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AddChildJob", ReplyAction = "http://tempuri.org/IHiveService/AddChildJobResponse")]
    1607     System.Guid AddChildJob(System.Guid parentJobId, HeuristicLab.Clients.Hive.Task job, HeuristicLab.Clients.Hive.TaskData jobData);
    1608 
    1609     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetJob", ReplyAction = "http://tempuri.org/IHiveService/GetJobResponse")]
    1610     HeuristicLab.Clients.Hive.Task GetJob(System.Guid jobId);
    1611 
    1612     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetJobs", ReplyAction = "http://tempuri.org/IHiveService/GetJobsResponse")]
    1613     System.Collections.Generic.List<HeuristicLab.Clients.Hive.Task> GetJobs();
    1614 
    1615     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetLightweightJobs", ReplyAction = "http://tempuri.org/IHiveService/GetLightweightJobsResponse")]
    1616     System.Collections.Generic.List<HeuristicLab.Clients.Hive.LightweightTask> GetLightweightJobs(System.Collections.Generic.List<System.Guid> jobIds);
    1617 
    1618     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetLightweightChildJobs", ReplyAction = "http://tempuri.org/IHiveService/GetLightweightChildJobsResponse")]
    1619     System.Collections.Generic.List<HeuristicLab.Clients.Hive.LightweightTask> GetLightweightChildJobs(System.Nullable<System.Guid> parentJobId, bool recursive, bool includeParent);
    1620 
    1621     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetLightweightExperimentJobs", ReplyAction = "http://tempuri.org/IHiveService/GetLightweightExperimentJobsResponse")]
    1622     System.Collections.Generic.List<HeuristicLab.Clients.Hive.LightweightTask> GetLightweightExperimentJobs(System.Guid experimentId);
    1623 
    1624     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetJobData", ReplyAction = "http://tempuri.org/IHiveService/GetJobDataResponse")]
    1625     HeuristicLab.Clients.Hive.TaskData GetJobData(System.Guid jobId);
     1659    System.Guid AddJob(HeuristicLab.Clients.Hive.Job jobDto);
    16261660
    16271661    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/UpdateJob", ReplyAction = "http://tempuri.org/IHiveService/UpdateJobResponse")]
    1628     void UpdateJob(HeuristicLab.Clients.Hive.Task jobDto);
    1629 
    1630     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/UpdateJobData", ReplyAction = "http://tempuri.org/IHiveService/UpdateJobDataResponse")]
    1631     void UpdateJobData(HeuristicLab.Clients.Hive.Task jobDto, HeuristicLab.Clients.Hive.TaskData jobDataDto);
     1662    void UpdateJob(HeuristicLab.Clients.Hive.Job jobDto);
    16321663
    16331664    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/DeleteJob", ReplyAction = "http://tempuri.org/IHiveService/DeleteJobResponse")]
    1634     void DeleteJob(System.Guid jobId);
    1635 
    1636     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/DeleteChildJobs", ReplyAction = "http://tempuri.org/IHiveService/DeleteChildJobsResponse")]
    1637     void DeleteChildJobs(System.Guid parentJobId);
    1638 
    1639     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/UpdateJobState", ReplyAction = "http://tempuri.org/IHiveService/UpdateJobStateResponse")]
    1640     HeuristicLab.Clients.Hive.Task UpdateJobState(System.Guid jobId, HeuristicLab.Clients.Hive.TaskState jobState, System.Nullable<System.Guid> slaveId, System.Nullable<System.Guid> userId, string exception);
    1641 
    1642     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/StopJob", ReplyAction = "http://tempuri.org/IHiveService/StopJobResponse")]
    1643     void StopJob(System.Guid jobId);
    1644 
    1645     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/PauseJob", ReplyAction = "http://tempuri.org/IHiveService/PauseJobResponse")]
    1646     void PauseJob(System.Guid jobId);
    1647 
    1648     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/RestartJob", ReplyAction = "http://tempuri.org/IHiveService/RestartJobResponse")]
    1649     void RestartJob(System.Guid jobId);
    1650 
    1651     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetHiveExperiment", ReplyAction = "http://tempuri.org/IHiveService/GetHiveExperimentResponse")]
    1652     HeuristicLab.Clients.Hive.Job GetHiveExperiment(System.Guid id);
    1653 
    1654     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetHiveExperiments", ReplyAction = "http://tempuri.org/IHiveService/GetHiveExperimentsResponse")]
    1655     System.Collections.Generic.List<HeuristicLab.Clients.Hive.Job> GetHiveExperiments();
    1656 
    1657     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetAllHiveExperiments", ReplyAction = "http://tempuri.org/IHiveService/GetAllHiveExperimentsResponse")]
    1658     System.Collections.Generic.List<HeuristicLab.Clients.Hive.Job> GetAllHiveExperiments();
    1659 
    1660     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AddHiveExperiment", ReplyAction = "http://tempuri.org/IHiveService/AddHiveExperimentResponse")]
    1661     System.Guid AddHiveExperiment(HeuristicLab.Clients.Hive.Job hiveExperimentDto);
    1662 
    1663     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/UpdateHiveExperiment", ReplyAction = "http://tempuri.org/IHiveService/UpdateHiveExperimentResponse")]
    1664     void UpdateHiveExperiment(HeuristicLab.Clients.Hive.Job hiveExperimentDto);
    1665 
    1666     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/DeleteHiveExperiment", ReplyAction = "http://tempuri.org/IHiveService/DeleteHiveExperimentResponse")]
    1667     void DeleteHiveExperiment(System.Guid hiveExperimentId);
     1665    void DeleteJob(System.Guid JobId);
    16681666
    16691667    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GrantPermission", ReplyAction = "http://tempuri.org/IHiveService/GrantPermissionResponse")]
    1670     void GrantPermission(System.Guid hiveExperimentId, System.Guid grantedUserId, HeuristicLab.Clients.Hive.Permission permission);
     1668    void GrantPermission(System.Guid jobId, System.Guid grantedUserId, HeuristicLab.Clients.Hive.Permission permission);
    16711669
    16721670    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/RevokePermission", ReplyAction = "http://tempuri.org/IHiveService/RevokePermissionResponse")]
    16731671    void RevokePermission(System.Guid hiveExperimentId, System.Guid grantedUserId);
    16741672
    1675     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetHiveExperimentPermissions", ReplyAction = "http://tempuri.org/IHiveService/GetHiveExperimentPermissionsResponse")]
    1676     System.Collections.Generic.List<HeuristicLab.Clients.Hive.JobPermission> GetHiveExperimentPermissions(System.Guid hiveExperimentId);
     1673    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetJobPermissions", ReplyAction = "http://tempuri.org/IHiveService/GetJobPermissionsResponse")]
     1674    System.Collections.Generic.List<HeuristicLab.Clients.Hive.JobPermission> GetJobPermissions(System.Guid jobId);
    16771675
    16781676    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/IsAllowedPrivileged", ReplyAction = "http://tempuri.org/IHiveService/IsAllowedPrivilegedResponse")]
     
    17801778    }
    17811779
    1782     public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Task> GetJobsByResourceId(System.Guid resourceId) {
    1783       return base.Channel.GetJobsByResourceId(resourceId);
     1780    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Task> GetTasksByResourceId(System.Guid resourceId) {
     1781      return base.Channel.GetTasksByResourceId(resourceId);
    17841782    }
    17851783
     
    18121810    }
    18131811
    1814     public System.Guid AddJob(HeuristicLab.Clients.Hive.Task job, HeuristicLab.Clients.Hive.TaskData jobData, System.Collections.Generic.List<System.Guid> resourceIds) {
    1815       return base.Channel.AddJob(job, jobData, resourceIds);
    1816     }
    1817 
    1818     public System.Guid AddChildJob(System.Guid parentJobId, HeuristicLab.Clients.Hive.Task job, HeuristicLab.Clients.Hive.TaskData jobData) {
    1819       return base.Channel.AddChildJob(parentJobId, job, jobData);
    1820     }
    1821 
    1822     public HeuristicLab.Clients.Hive.Task GetJob(System.Guid jobId) {
    1823       return base.Channel.GetJob(jobId);
    1824     }
    1825 
    1826     public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Task> GetJobs() {
     1812    public System.Guid AddTask(HeuristicLab.Clients.Hive.Task task, HeuristicLab.Clients.Hive.TaskData taskData, System.Collections.Generic.List<System.Guid> resourceIds) {
     1813      return base.Channel.AddTask(task, taskData, resourceIds);
     1814    }
     1815
     1816    public System.Guid AddChildTask(System.Guid parentTaskId, HeuristicLab.Clients.Hive.Task task, HeuristicLab.Clients.Hive.TaskData taskData) {
     1817      return base.Channel.AddChildTask(parentTaskId, task, taskData);
     1818    }
     1819
     1820    public HeuristicLab.Clients.Hive.Task GetTask(System.Guid taskId) {
     1821      return base.Channel.GetTask(taskId);
     1822    }
     1823
     1824    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Task> GetTasks() {
     1825      return base.Channel.GetTasks();
     1826    }
     1827
     1828    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.LightweightTask> GetLightweightTasks(System.Collections.Generic.List<System.Guid> taskIds) {
     1829      return base.Channel.GetLightweightTasks(taskIds);
     1830    }
     1831
     1832    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.LightweightTask> GetLightweightChildTasks(System.Nullable<System.Guid> parentTaskId, bool recursive, bool includeParent) {
     1833      return base.Channel.GetLightweightChildTasks(parentTaskId, recursive, includeParent);
     1834    }
     1835
     1836    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.LightweightTask> GetLightweightJobTasks(System.Guid jobId) {
     1837      return base.Channel.GetLightweightJobTasks(jobId);
     1838    }
     1839
     1840    public HeuristicLab.Clients.Hive.TaskData GetTaskData(System.Guid taskId) {
     1841      return base.Channel.GetTaskData(taskId);
     1842    }
     1843
     1844    public void UpdateTask(HeuristicLab.Clients.Hive.Task taskDto) {
     1845      base.Channel.UpdateTask(taskDto);
     1846    }
     1847
     1848    public void UpdateTaskData(HeuristicLab.Clients.Hive.Task taskDto, HeuristicLab.Clients.Hive.TaskData taskDataDto) {
     1849      base.Channel.UpdateTaskData(taskDto, taskDataDto);
     1850    }
     1851
     1852    public void DeleteTask(System.Guid taskId) {
     1853      base.Channel.DeleteTask(taskId);
     1854    }
     1855
     1856    public void DeleteChildTasks(System.Guid parentTaskId) {
     1857      base.Channel.DeleteChildTasks(parentTaskId);
     1858    }
     1859
     1860    public HeuristicLab.Clients.Hive.Task UpdateTaskState(System.Guid taskId, HeuristicLab.Clients.Hive.TaskState taskState, System.Nullable<System.Guid> slaveId, System.Nullable<System.Guid> userId, string exception) {
     1861      return base.Channel.UpdateTaskState(taskId, taskState, slaveId, userId, exception);
     1862    }
     1863
     1864    public void StopTask(System.Guid taskId) {
     1865      base.Channel.StopTask(taskId);
     1866    }
     1867
     1868    public void PauseTask(System.Guid taskId) {
     1869      base.Channel.PauseTask(taskId);
     1870    }
     1871
     1872    public void RestartTask(System.Guid taskId) {
     1873      base.Channel.RestartTask(taskId);
     1874    }
     1875
     1876    public HeuristicLab.Clients.Hive.Job GetJob(System.Guid id) {
     1877      return base.Channel.GetJob(id);
     1878    }
     1879
     1880    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Job> GetJobs() {
    18271881      return base.Channel.GetJobs();
    18281882    }
    18291883
    1830     public System.Collections.Generic.List<HeuristicLab.Clients.Hive.LightweightTask> GetLightweightJobs(System.Collections.Generic.List<System.Guid> jobIds) {
    1831       return base.Channel.GetLightweightJobs(jobIds);
    1832     }
    1833 
    1834     public System.Collections.Generic.List<HeuristicLab.Clients.Hive.LightweightTask> GetLightweightChildJobs(System.Nullable<System.Guid> parentJobId, bool recursive, bool includeParent) {
    1835       return base.Channel.GetLightweightChildJobs(parentJobId, recursive, includeParent);
    1836     }
    1837 
    1838     public System.Collections.Generic.List<HeuristicLab.Clients.Hive.LightweightTask> GetLightweightExperimentJobs(System.Guid experimentId) {
    1839       return base.Channel.GetLightweightExperimentJobs(experimentId);
    1840     }
    1841 
    1842     public HeuristicLab.Clients.Hive.TaskData GetJobData(System.Guid jobId) {
    1843       return base.Channel.GetJobData(jobId);
    1844     }
    1845 
    1846     public void UpdateJob(HeuristicLab.Clients.Hive.Task jobDto) {
     1884    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Job> GetAllJobs() {
     1885      return base.Channel.GetAllJobs();
     1886    }
     1887
     1888    public System.Guid AddJob(HeuristicLab.Clients.Hive.Job jobDto) {
     1889      return base.Channel.AddJob(jobDto);
     1890    }
     1891
     1892    public void UpdateJob(HeuristicLab.Clients.Hive.Job jobDto) {
    18471893      base.Channel.UpdateJob(jobDto);
    18481894    }
    18491895
    1850     public void UpdateJobData(HeuristicLab.Clients.Hive.Task jobDto, HeuristicLab.Clients.Hive.TaskData jobDataDto) {
    1851       base.Channel.UpdateJobData(jobDto, jobDataDto);
    1852     }
    1853 
    1854     public void DeleteJob(System.Guid jobId) {
    1855       base.Channel.DeleteJob(jobId);
    1856     }
    1857 
    1858     public void DeleteChildJobs(System.Guid parentJobId) {
    1859       base.Channel.DeleteChildJobs(parentJobId);
    1860     }
    1861 
    1862     public HeuristicLab.Clients.Hive.Task UpdateJobState(System.Guid jobId, HeuristicLab.Clients.Hive.TaskState jobState, System.Nullable<System.Guid> slaveId, System.Nullable<System.Guid> userId, string exception) {
    1863       return base.Channel.UpdateJobState(jobId, jobState, slaveId, userId, exception);
    1864     }
    1865 
    1866     public void StopJob(System.Guid jobId) {
    1867       base.Channel.StopJob(jobId);
    1868     }
    1869 
    1870     public void PauseJob(System.Guid jobId) {
    1871       base.Channel.PauseJob(jobId);
    1872     }
    1873 
    1874     public void RestartJob(System.Guid jobId) {
    1875       base.Channel.RestartJob(jobId);
    1876     }
    1877 
    1878     public HeuristicLab.Clients.Hive.Job GetHiveExperiment(System.Guid id) {
    1879       return base.Channel.GetHiveExperiment(id);
    1880     }
    1881 
    1882     public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Job> GetHiveExperiments() {
    1883       return base.Channel.GetHiveExperiments();
    1884     }
    1885 
    1886     public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Job> GetAllHiveExperiments() {
    1887       return base.Channel.GetAllHiveExperiments();
    1888     }
    1889 
    1890     public System.Guid AddHiveExperiment(HeuristicLab.Clients.Hive.Job hiveExperimentDto) {
    1891       return base.Channel.AddHiveExperiment(hiveExperimentDto);
    1892     }
    1893 
    1894     public void UpdateHiveExperiment(HeuristicLab.Clients.Hive.Job hiveExperimentDto) {
    1895       base.Channel.UpdateHiveExperiment(hiveExperimentDto);
    1896     }
    1897 
    1898     public void DeleteHiveExperiment(System.Guid hiveExperimentId) {
    1899       base.Channel.DeleteHiveExperiment(hiveExperimentId);
    1900     }
    1901 
    1902     public void GrantPermission(System.Guid hiveExperimentId, System.Guid grantedUserId, HeuristicLab.Clients.Hive.Permission permission) {
    1903       base.Channel.GrantPermission(hiveExperimentId, grantedUserId, permission);
     1896    public void DeleteJob(System.Guid JobId) {
     1897      base.Channel.DeleteJob(JobId);
     1898    }
     1899
     1900    public void GrantPermission(System.Guid jobId, System.Guid grantedUserId, HeuristicLab.Clients.Hive.Permission permission) {
     1901      base.Channel.GrantPermission(jobId, grantedUserId, permission);
    19041902    }
    19051903
     
    19081906    }
    19091907
    1910     public System.Collections.Generic.List<HeuristicLab.Clients.Hive.JobPermission> GetHiveExperimentPermissions(System.Guid hiveExperimentId) {
    1911       return base.Channel.GetHiveExperimentPermissions(hiveExperimentId);
     1908    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.JobPermission> GetJobPermissions(System.Guid jobId) {
     1909      return base.Channel.GetJobPermissions(jobId);
    19121910    }
    19131911
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/ServiceClients/LightweightTask.cs

    r6721 r6743  
    4242      this.State = job.State;
    4343      this.Command = job.Command;
    44       this.LastJobDataUpdate = job.LastJobDataUpdate;
     44      this.LastTaskDataUpdate = job.LastTaskDataUpdate;
    4545    }
    4646
     
    5252      this.State = original.State;
    5353      this.Command = original.Command;
    54       this.LastJobDataUpdate = original.LastJobDataUpdate;
     54      this.LastTaskDataUpdate = original.LastTaskDataUpdate;
    5555    }
    5656    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/TaskDownloader.cs

    r6725 r6743  
    7272   
    7373    public void StartAsync() {
    74       foreach (Guid jobId in taskIds) {
    75         Task job = ServiceLocator.Instance.CallHiveService(s => s.GetJob(jobId));
     74      foreach (Guid taskId in taskIds) {
     75        Task task = ServiceLocator.Instance.CallHiveService(s => s.GetTask(taskId));
    7676
    77         taskDownloader.DownloadJob(job,
     77        taskDownloader.DownloadTask(task,
    7878          (localJob, itemJob) => {
    7979            if (localJob != null && itemJob != null) {
    80               HiveTask hiveJob;
     80              HiveTask hiveTask;
    8181              if (itemJob is OptimizerTask) {
    82                 hiveJob = new OptimizerHiveTask((OptimizerTask)itemJob);
     82                hiveTask = new OptimizerHiveTask((OptimizerTask)itemJob);
    8383              } else {
    84                 hiveJob = new HiveTask(itemJob, true);
     84                hiveTask = new HiveTask(itemJob, true);
    8585              }
    86               hiveJob.Task = localJob;
    87               this.results.Add(localJob.Id, hiveJob);
     86              hiveTask.Task = localJob;
     87              this.results.Add(localJob.Id, hiveTask);
    8888            }
    8989          });
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Hive/3.3/HeuristicLab.Hive-3.3.csproj

    r6725 r6743  
    7777      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath>
    7878    </Reference>
    79     <Reference Include="HeuristicLab.Persistence-3.3">
    80       <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Persistence-3.3.dll</HintPath>
    81     </Reference>
    8279    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
    8380      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Hive/3.3/HeuristicLabHivePlugin.cs.frame

    r6701 r6743  
    99  [PluginFile("HeuristicLab.Hive-3.3.dll", PluginFileType.Assembly)]
    1010  [PluginDependency("HeuristicLab.Common", "3.3")]
    11   [PluginDependency("HeuristicLab.Core", "3.3")]
    12   [PluginDependency("HeuristicLab.Persistence", "3.3")]
     11  [PluginDependency("HeuristicLab.Core", "3.3")] 
    1312  public class HeuristicLabHivePlugin : PluginBase {
    1413  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.3/HiveEngine.cs

    r6725 r6743  
    252252          var engineHiveJob = new EngineHiveTask(jobs[i], parentScopeClone);
    253253          engineHiveJob.Task.Priority = this.Priority;
    254           refreshableJob.HiveJobs.Add(engineHiveJob);
     254          refreshableJob.HiveTasks.Add(engineHiveJob);
    255255
    256256          // shuffle random variable to avoid the same random sequence in each operation; todo: does not yet work (it cannot find the random variable)
     
    259259            random.Reset(random.Next());
    260260        }
    261         HiveClient.StartExperiment((e) => { log.LogException(e); }, refreshableJob, cancellationToken);
     261        HiveClient.StartJob((e) => { log.LogException(e); }, refreshableJob, cancellationToken);
    262262
    263263        // do polling until experiment is finished and all jobs are downloaded
     
    269269        log.LogMessage(string.Format("{0} finished (TotalExecutionTime: {1}).", refreshableJob.ToString(), refreshableJob.ExecutionTime));
    270270
    271         var failedJobs = refreshableJob.HiveJobs.Where(x => x.Task.State == TaskState.Failed);
     271        var failedJobs = refreshableJob.HiveTasks.Where(x => x.Task.State == TaskState.Failed);
    272272        if (failedJobs.Count() > 0) {
    273273          throw new HiveEngineException("Task failed: " + failedJobs.First().Task.StateLog.Last().Exception);
     
    276276        // get scopes
    277277        int j = 0;
    278         foreach (var hiveJob in refreshableJob.HiveJobs) {
     278        foreach (var hiveJob in refreshableJob.HiveTasks) {
    279279          var scope = ((IAtomicOperation)((EngineTask)hiveJob.ItemTask).InitialOperation).Scope;
    280280          scopes[j++] = scope;
     
    315315
    316316    private void ClearData(RefreshableJob refreshableJob) {
    317       var jobs = refreshableJob.GetAllHiveJobs();
     317      var jobs = refreshableJob.GetAllHiveTasks();
    318318      foreach (var job in jobs) {
    319319        job.ClearData();
     
    321321    }
    322322
    323     private void DeleteHiveExperiment(Guid hiveExperimentId) {
     323    private void DeleteHiveExperiment(Guid jobId) {
    324324      HiveClient.TryAndRepeat(() => {
    325         ServiceLocator.Instance.CallHiveService(s => s.DeleteHiveExperiment(hiveExperimentId));
     325        ServiceLocator.Instance.CallHiveService(s => s.DeleteJob(jobId));
    326326      }, 5, string.Format("Could not delete jobs"));
    327327    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.3/HeuristicLab.Services.Hive.DataAccess-3.3.csproj

    r6721 r6743  
    7171  </PropertyGroup>
    7272  <ItemGroup>
    73     <Reference Include="HeuristicLab.Common-3.3">
    74       <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
    75     </Reference>
    76     <Reference Include="HeuristicLab.Core-3.3">
    77       <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Core-3.3.dll</HintPath>
    78     </Reference>
    79     <Reference Include="HeuristicLab.Persistence-3.3">
    80       <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Persistence-3.3.dll</HintPath>
    81     </Reference>
    8273    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
    8374      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.3/HeuristicLabServicesHiveDataAccessPlugin.cs.frame

    r6717 r6743  
    2828namespace HeuristicLab.Services.Hive.DataAccess {
    2929  [Plugin("HeuristicLab.Services.Hive.DataAccess", "3.3.5.$WCREV$")]
    30   [PluginFile("HeuristicLab.Services.Hive.DataAccess-3.3.dll", PluginFileType.Assembly)]
    31   [PluginDependency("HeuristicLab.Common", "3.3")]
    32   [PluginDependency("HeuristicLab.Core", "3.3")]
    33   [PluginDependency("HeuristicLab.Persistence", "3.3")] 
     30  [PluginFile("HeuristicLab.Services.Hive.DataAccess-3.3.dll", PluginFileType.Assembly)] 
    3431  public class HeuristicLabServicesHiveDataAccessPlugin : PluginBase {
    3532  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.3/Logger.cs

    r6717 r6743  
    2828  public class LogFactory {
    2929    public static ILogger GetLogger(string source) {
    30       return new Logger("HL.Hive", source);
     30      return new Logger(Settings.Default.EventLogName, source);
    3131    }
    3232  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.3/Settings.Designer.cs

    r6717 r6743  
    4343            }
    4444        }
     45       
     46        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     47        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     48        [global::System.Configuration.DefaultSettingValueAttribute("HL.Hive")]
     49        public string EventLogName {
     50            get {
     51                return ((string)(this["EventLogName"]));
     52            }
     53        }
    4554    }
    4655}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.3/Settings.settings

    r6712 r6743  
    1414      <Value Profile="(Default)">00:05:00</Value>
    1515    </Setting>
     16    <Setting Name="EventLogName" Type="System.String" Scope="Application">
     17      <Value Profile="(Default)">HL.Hive</Value>
     18    </Setting>
    1619  </Settings>
    1720</SettingsFile>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.3/app.config

    r6712 r6743  
    66    </sectionGroup>
    77  </configSections>
    8   <connectionStrings>   
     8  <connectionStrings>
    99    <add name="HeuristicLab.Services.Hive.DataAccess.Settings.HeuristicLab_Hive_LinqConnectionString"
    1010      connectionString="Data Source=localhost;Initial Catalog=HeuristicLab.Hive-3.3;Integrated Security=True;"
     
    1616        <value>00:05:00</value>
    1717      </setting>
     18      <setting name="EventLogName" serializeAs="String">
     19        <value>HL.Hive</value>
     20      </setting>
    1821    </HeuristicLab.Services.Hive.DataAccess.Settings>
    1922  </applicationSettings>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/DaoTests.cs

    r6723 r6743  
    4949      he.OwnerUserId = Guid.NewGuid();
    5050      he.ResourceNames = "HEAL";
    51       he.Id = dao.AddHiveExperiment(he);
     51      he.Id = dao.AddJob(he);
    5252
    5353      DT.Task job1 = new DT.Task();
     
    8080      job1.PluginsNeededIds.Add(plugin1.Id);
    8181
    82       job1.Id = dao.AddJob(job1);
     82      job1.Id = dao.AddTask(job1);
    8383      jobData1.TaskId = job1.Id;
    84       dao.AddJobData(jobData1);
    85 
    86       DT.Task job1loaded = dao.GetJob(job1.Id);
     84      dao.AddTaskData(jobData1);
     85
     86      DT.Task job1loaded = dao.GetTask(job1.Id);
    8787      Assert.AreEqual(job1.Id, job1loaded.Id);
    8888      Assert.AreEqual(job1.CoresNeeded, job1loaded.CoresNeeded);
     
    9494      Assert.AreEqual(job1.JobId, job1loaded.JobId);
    9595      Assert.AreEqual(job1.IsPrivileged, job1loaded.IsPrivileged);
    96       Assert.IsTrue(Math.Abs((job1loaded.LastJobDataUpdate - jobData1.LastUpdate).TotalSeconds) < 1);
     96      Assert.IsTrue(Math.Abs((job1loaded.LastTaskDataUpdate - jobData1.LastUpdate).TotalSeconds) < 1);
    9797      for (int i = 0; i < job1.StateLog.Count; i++) {
    9898        Assert.AreEqual(job1.Id, job1loaded.StateLog[i].TaskId);
     
    111111      job1.StateLog.Add(new DT.StateLog { State = DT.TaskState.Transferring, DateTime = DateTime.Now }); Thread.Sleep(10);
    112112      job1.StateLog.Add(new DT.StateLog { State = DT.TaskState.Finished, DateTime = DateTime.Now }); Thread.Sleep(10);
    113       dao.UpdateJob(job1);
    114 
    115       job1loaded = dao.GetJob(job1.Id);
     113      dao.UpdateTask(job1);
     114
     115      job1loaded = dao.GetTask(job1.Id);
    116116      for (int i = 0; i < job1.StateLog.Count; i++) {
    117117        Assert.AreEqual(job1.Id, job1loaded.StateLog[i].TaskId);
     
    123123      }
    124124
    125       DT.TaskData jobData1Loaded = dao.GetJobData(job1.Id);
     125      DT.TaskData jobData1Loaded = dao.GetTaskData(job1.Id);
    126126      Assert.AreEqual(jobData1.TaskId, jobData1Loaded.TaskId);
    127127      Assert.IsTrue(Math.Abs((jobData1.LastUpdate - jobData1Loaded.LastUpdate).TotalSeconds) < 1);
    128128      Assert.IsTrue(jobData1.Data.SequenceEqual(jobData1Loaded.Data));
    129129
    130       dao.DeleteHiveExperiment(he.Id);
    131 
    132       Assert.AreEqual(null, dao.GetJob(job1.Id));
    133       Assert.AreEqual(null, dao.GetJobData(job1.Id));
    134       Assert.AreEqual(null, dao.GetHiveExperiment(he.Id));
     130      dao.DeleteJob(he.Id);
     131
     132      Assert.AreEqual(null, dao.GetTask(job1.Id));
     133      Assert.AreEqual(null, dao.GetTaskData(job1.Id));
     134      Assert.AreEqual(null, dao.GetJob(he.Id));
    135135
    136136      dao.DeletePlugin(plugin1.Id);
     
    220220      he.OwnerUserId = Guid.NewGuid();
    221221      he.ResourceNames = "HEAL";
    222       he.Id = dao.AddHiveExperiment(he);
     222      he.Id = dao.AddJob(he);
    223223
    224224      DT.Task job = new DT.Task();
     
    226226      job.StateLog.Add(new DT.StateLog { State = DT.TaskState.Offline, DateTime = DateTime.Now });
    227227      job.JobId = he.Id;
    228       job.Id = dao.AddJob(job);
     228      job.Id = dao.AddTask(job);
    229229
    230230      DT.JobPermission perm = new DT.JobPermission();
     
    233233      perm.GrantedUserId = Guid.NewGuid();
    234234      perm.Permission = DT.Permission.Full;
    235       dao.AddHiveExperimentPermission(perm);
    236 
    237       DT.Job heLoaded = dao.GetHiveExperiment(he.Id);
     235      dao.AddJobPermission(perm);
     236
     237      DT.Job heLoaded = dao.GetJob(he.Id);
    238238      Assert.AreEqual(he.Id, heLoaded.Id);
    239239      Assert.AreEqual(he.Name, heLoaded.Name);
    240240      Assert.AreEqual(he.ResourceNames, heLoaded.ResourceNames);
    241       //Assert.AreEqual(he.LastAccessed, heLoaded.LastAccessed);
    242       //Assert.AreEqual(he.DateCreated, heLoaded.DateCreated);
    243 
    244       DT.Task jobLoaded = dao.GetJob(job.Id);
     241      //Assert.AreEqual(job.LastAccessed, heLoaded.LastAccessed);
     242      //Assert.AreEqual(job.DateCreated, heLoaded.DateCreated);
     243
     244      DT.Task jobLoaded = dao.GetTask(job.Id);
    245245      Assert.AreEqual(job.Id, jobLoaded.Id);
    246246      Assert.AreEqual(job.State, jobLoaded.State);
    247247      Assert.AreEqual(job.JobId, jobLoaded.JobId);
    248248
    249       DT.JobPermission permLoaded = dao.GetHiveExperimentPermission(he.Id, perm.GrantedUserId);
     249      DT.JobPermission permLoaded = dao.GetJobPermission(he.Id, perm.GrantedUserId);
    250250      Assert.AreEqual(perm.JobId, permLoaded.JobId);
    251251      Assert.AreEqual(perm.GrantedUserId, permLoaded.GrantedUserId);
     
    253253      Assert.AreEqual(perm.Permission, permLoaded.Permission);
    254254
    255       dao.DeleteHiveExperiment(he.Id);
    256       Assert.AreEqual(null, dao.GetHiveExperiment(he.Id));
    257       Assert.AreEqual(null, dao.GetJob(job.Id));
    258       Assert.AreEqual(null, dao.GetHiveExperimentPermission(perm.JobId, perm.GrantedUserId));
     255      dao.DeleteJob(he.Id);
     256      Assert.AreEqual(null, dao.GetJob(he.Id));
     257      Assert.AreEqual(null, dao.GetTask(job.Id));
     258      Assert.AreEqual(null, dao.GetJobPermission(perm.JobId, perm.GrantedUserId));
    259259
    260260    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/HeuristicLab.Services.Hive.Tests-3.3.csproj

    r6717 r6743  
    8585      <SubType>Designer</SubType>
    8686    </None>
    87     <Shadow Include="Test References\HeuristicLab.Services.Hive-3.4.accessor" />
     87    <Shadow Include="Test References\HeuristicLab.Services.Hive-3.3.accessor" />
    8888  </ItemGroup>
    8989  <ItemGroup />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/Mocks/MockAuthorizationManager.cs

    r6717 r6743  
    2828    }
    2929
    30     public void AuthorizeForJob(Guid jobId, DataTransfer.Permission requiredPermission) {
     30    public void AuthorizeForTask(Guid jobId, DataTransfer.Permission requiredPermission) {
    3131      // ok.
    3232    }
    3333
    34     public void AuthorizeForExperiment(Guid experimentId, DataTransfer.Permission requiredPermission) {
     34    public void AuthorizeForJob(Guid experimentId, DataTransfer.Permission requiredPermission) {
    3535      // ok.
    3636    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/ServiceTests.cs

    r6725 r6743  
    9898
    9999      // add hive experiment
    100       experiment.Id = service.AddHiveExperiment(experiment);
     100      experiment.Id = service.AddJob(experiment);
    101101
    102102      // add task
    103103      job.JobId = experiment.Id;
    104       job.Id = service.AddJob(job, jobData, new List<Guid> { slave.Id });
     104      job.Id = service.AddTask(job, jobData, new List<Guid> { slave.Id });
    105105
    106106      // test task
    107       DT.Task jobLoaded = service.GetJob(job.Id);
     107      DT.Task jobLoaded = service.GetTask(job.Id);
    108108      Assert.AreEqual(job.Id, jobLoaded.Id);
    109109      Assert.AreEqual(job.CoresNeeded, jobLoaded.CoresNeeded);
     
    114114      Assert.AreEqual(job.JobId, jobLoaded.JobId);
    115115
    116       DT.TaskData jobDataLoaded = service.GetJobData(job.Id);
     116      DT.TaskData jobDataLoaded = service.GetTaskData(job.Id);
    117117      Assert.AreEqual(job.Id, jobDataLoaded.TaskId);
    118118      Assert.IsTrue(jobData.Data.SequenceEqual(jobDataLoaded.Data));
    119119
    120120      // test hive experiment
    121       DT.Job experimentLoaded = service.GetHiveExperiment(experiment.Id);
     121      DT.Job experimentLoaded = service.GetJob(experiment.Id);
    122122      Assert.AreEqual(experiment.Id, experimentLoaded.Id);
    123123      Assert.AreEqual(experiment.Name, experimentLoaded.Name);
     
    130130      Assert.AreEqual(job.Id, actions[0].TaskId);
    131131
    132       jobLoaded = service.GetJob(job.Id);
     132      jobLoaded = service.GetTask(job.Id);
    133133      Assert.AreEqual(TaskState.Transferring, jobLoaded.State);
    134134
    135135      // slave is responsible for updating state to 'Calculating'
    136       service.UpdateJobState(jobLoaded.Id, DT.TaskState.Calculating, slave.Id, null, null);
     136      service.UpdateTaskState(jobLoaded.Id, DT.TaskState.Calculating, slave.Id, null, null);
    137137
    138138      // send progress
     
    143143
    144144      // the task should be in state 'Calculating' now
    145       jobLoaded = service.GetJob(job.Id);
     145      jobLoaded = service.GetTask(job.Id);
    146146      Assert.AreEqual(TaskState.Calculating, jobLoaded.State);
    147147      Assert.AreEqual(new TimeSpan(1, 5, 10, 20, 30), jobLoaded.ExecutionTime);
    148148
    149149      // test if the task is returned for the resource
    150       var jobsBySlave = service.GetJobsByResourceId(slave.Id);
     150      var jobsBySlave = service.GetTasksByResourceId(slave.Id);
    151151      Assert.AreEqual(1, jobsBySlave.Count());
    152152      Assert.AreEqual(job.Id, jobsBySlave.Single().Id);
    153153
    154154      // set it to finished
    155       service.UpdateJobState(jobLoaded.Id, DT.TaskState.Finished, slave.Id, null, null);
     155      service.UpdateTaskState(jobLoaded.Id, DT.TaskState.Finished, slave.Id, null, null);
    156156
    157157      // test if the task is returned for the resource (it should not be)
    158       var jobsBySlave2 = service.GetJobsByResourceId(slave.Id);
     158      var jobsBySlave2 = service.GetTasksByResourceId(slave.Id);
    159159      Assert.AreEqual(0, jobsBySlave2.Count());
    160160
    161161      // set task waiting again
    162       service.UpdateJobState(job.Id, DT.TaskState.Waiting, null, null, string.Empty);
     162      service.UpdateTaskState(job.Id, DT.TaskState.Waiting, null, null, string.Empty);
    163163
    164164      // get task again
     
    181181
    182182      // delete
    183       service.DeleteHiveExperiment(experiment.Id);
    184       Assert.AreEqual(null, service.GetHiveExperiment(experiment.Id));
    185       Assert.AreEqual(null, service.GetJob(job.Id));
    186       Assert.AreEqual(null, service.GetJobData(job.Id));
     183      service.DeleteJob(experiment.Id);
     184      Assert.AreEqual(null, service.GetJob(experiment.Id));
     185      Assert.AreEqual(null, service.GetTask(job.Id));
     186      Assert.AreEqual(null, service.GetTaskData(job.Id));
    187187
    188188      // send another heartbeat with the deleted task; the server should command the abortion of the task
     
    241241
    242242      // add hive experiment
    243       experiment.Id = service.AddHiveExperiment(experiment);
     243      experiment.Id = service.AddJob(experiment);
    244244
    245245      // add parent task
    246246      parentJob.JobId = experiment.Id;
    247       parentJob.Id = service.AddJob(parentJob, parentJobData, new List<Guid> { slave.Id });
     247      parentJob.Id = service.AddTask(parentJob, parentJobData, new List<Guid> { slave.Id });
    248248
    249249      // add child task
    250250      childJob.JobId = experiment.Id;
    251       childJob.Id = service.AddChildJob(parentJob.Id, childJob, childJobData);
     251      childJob.Id = service.AddChildTask(parentJob.Id, childJob, childJobData);
    252252      childJob.ParentTaskId = parentJob.Id;
    253253
    254254      // test child task
    255       var childJobLoaded = service.GetJob(childJob.Id);
     255      var childJobLoaded = service.GetTask(childJob.Id);
    256256      Assert.AreEqual(childJob.ParentTaskId, childJobLoaded.ParentTaskId);
    257257      Assert.AreEqual(childJob.JobId, childJobLoaded.JobId);
     
    261261
    262262      // test parent task
    263       var parentJobLoaded = service.GetJob(parentJob.Id);
     263      var parentJobLoaded = service.GetTask(parentJob.Id);
    264264      Assert.AreEqual(parentJob.JobId, parentJobLoaded.JobId);
    265265      Assert.AreEqual(TaskState.Waiting, parentJobLoaded.State);
     
    276276      service.TriggerEventManager(true);
    277277
    278       parentJobLoaded = service.GetJob(parentJob.Id);
     278      parentJobLoaded = service.GetTask(parentJob.Id);
    279279      Assert.AreEqual(TaskState.Waiting, parentJobLoaded.State);
    280280
    281281      // set child task to finished
    282       childJobLoaded = service.UpdateJobState(childJobLoaded.Id, DT.TaskState.Finished, slave.Id, null, null);
     282      childJobLoaded = service.UpdateTaskState(childJobLoaded.Id, DT.TaskState.Finished, slave.Id, null, null);
    283283
    284284      // lifecycle - let it process one server-heartbeat; this should set the parent task to finished
     
    286286
    287287      // test if parent task is finished
    288       parentJobLoaded = service.GetJob(parentJob.Id);
     288      parentJobLoaded = service.GetTask(parentJob.Id);
    289289      Assert.AreEqual(TaskState.Finished, parentJobLoaded.State);
    290290
    291291      // delete experiment
    292       service.DeleteHiveExperiment(experiment.Id);
    293       Assert.AreEqual(null, service.GetJob(parentJob.Id));
    294       Assert.AreEqual(null, service.GetJob(childJob.Id));
     292      service.DeleteJob(experiment.Id);
     293      Assert.AreEqual(null, service.GetTask(parentJob.Id));
     294      Assert.AreEqual(null, service.GetTask(childJob.Id));
    295295
    296296      service.DeleteSlave(slave.Id);
     
    305305      // create hive experiment
    306306      DT.Job e1 = new DT.Job() { Name = "TestExperiment", Description = "" };
    307       e1.Id = service.AddHiveExperiment(e1);
    308 
    309       var e1loaded = service.GetHiveExperiment(e1.Id);
     307      e1.Id = service.AddJob(e1);
     308
     309      var e1loaded = service.GetJob(e1.Id);
    310310      Assert.AreEqual(Permission.Full, e1loaded.Permission);
    311       var allExp = service.GetHiveExperiments();
     311      var allExp = service.GetJobs();
    312312      Assert.AreEqual(1, allExp.Count(x => x.Id == e1.Id));
    313313
     
    315315      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId2);
    316316      try {
    317         e1loaded = service.GetHiveExperiment(e1.Id);
     317        e1loaded = service.GetJob(e1.Id);
    318318        Assert.Fail("Access should not be possible");
    319319      }
    320320      catch { /* ok, cool */ }
    321       allExp = service.GetHiveExperiments();
     321      allExp = service.GetJobs();
    322322      Assert.AreEqual(0, allExp.Count(x => x.Id == e1.Id));
    323323
     
    335335      // back to user2
    336336      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId2);
    337       e1loaded = service.GetHiveExperiment(e1.Id);
     337      e1loaded = service.GetJob(e1.Id);
    338338      Assert.AreEqual(Permission.Read, e1loaded.Permission);
    339       allExp = service.GetHiveExperiments();
     339      allExp = service.GetJobs();
    340340      Assert.AreEqual(1, allExp.Count(x => x.Id == e1.Id));
    341341
     
    353353      // back to user2
    354354      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId2);
    355       e1loaded = service.GetHiveExperiment(e1.Id);
     355      e1loaded = service.GetJob(e1.Id);
    356356      Assert.AreEqual(Permission.Full, e1loaded.Permission);
    357       allExp = service.GetHiveExperiments();
     357      allExp = service.GetJobs();
    358358      Assert.AreEqual(1, allExp.Count(x => x.Id == e1.Id));
    359359
     
    368368      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId2);
    369369      try {
    370         e1loaded = service.GetHiveExperiment(e1.Id);
     370        e1loaded = service.GetJob(e1.Id);
    371371        Assert.Fail("Access should not be possible");
    372372      }
    373373      catch { /* ok, cool */ }
    374       allExp = service.GetHiveExperiments();
     374      allExp = service.GetJobs();
    375375      Assert.AreEqual(0, allExp.Count(x => x.Id == e1.Id));
    376376
    377377      // back to user1
    378378      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId1);
    379       service.DeleteHiveExperiment(e1.Id);
     379      service.DeleteJob(e1.Id);
    380380    }
    381381  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Web/Hive-3.4/Status.aspx.cs

    r6721 r6743  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Collections.Generic;
    324using System.Linq;
     
    3253    int currentlyAvailableCores = onlineSlaves.Sum(s => s.Cores.Value);
    3354    int currentlyUsedCores = currentlyAvailableCores - onlineSlaves.Sum(s => s.FreeCores.Value);
    34     int currentlyJobsWaiting = ServiceLocator.Instance.HiveDao.GetJobs(x => x.State == DA.TaskState.Waiting).Count();
     55    int currentlyJobsWaiting = ServiceLocator.Instance.HiveDao.GetTasks(x => x.State == DA.TaskState.Waiting).Count();
    3556
    3657    this.availableCoresLabel.Text = currentlyAvailableCores.ToString();
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Convert.cs

    r6725 r6743  
    2727using DT = HeuristicLab.Services.Hive.DataTransfer;
    2828
    29 
    3029namespace HeuristicLab.Services.Hive.DataTransfer {
    3130  public static class Convert {
    32     #region Job
     31    #region Task
    3332    public static DT.Task ToDto(DB.Task source) {
    3433      if (source == null) return null;
     
    4746        FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished,
    4847        Command = Convert.ToDto(source.Command),
    49         LastJobDataUpdate = (source.JobData == null ? DateTime.MinValue : source.JobData.LastUpdate),
     48        LastTaskDataUpdate = (source.JobData == null ? DateTime.MinValue : source.JobData.LastUpdate),
    5049        JobId = source.JobId,
    5150        IsPrivileged = source.IsPrivileged
     
    150149    #endregion
    151150
    152     #region HiveExperimentPermission
     151    #region JobPermission
    153152    public static DT.JobPermission ToDto(DB.JobPermission source) {
    154153      if (source == null) return null;
     
    363362    }
    364363    #endregion
    365 
    366364
    367365    #region TaskData
     
    433431    #endregion
    434432
    435 
    436433    #region Command
    437434    public static DT.Command? ToDto(DB.Command? source) {
     
    462459        return null;
    463460    }
    464 
    465461    #endregion
    466462
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Heartbeat.cs

    r6717 r6743  
    3535    public int FreeCores { get; set; }
    3636    [DataMember]
    37     public Dictionary<Guid, TimeSpan> JobProgress { get; set; } // TODO: define Type
     37    public Dictionary<Guid, TimeSpan> JobProgress { get; set; }
    3838    [DataMember]
    39     public bool AssignJob { get; set; } // if false, the server will not assign a new job
     39    public bool AssignJob { get; set; } // if false, the server will not assign a new task
    4040    [DataMember]
    4141    public float CpuUtilization { get; set; }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/LightweightTask.cs

    r6721 r6743  
    4040    public Command? Command { get; set; }
    4141    [DataMember]
    42     public DateTime LastJobDataUpdate { get; set; }
     42    public DateTime LastTaskDataUpdate { get; set; }
    4343
    4444    public StateLog CurrentStateLog { get { return StateLog.LastOrDefault(); } }
     
    5050    }
    5151
    52     public LightweightTask(Task job) {
    53       this.Id = job.Id;
    54       this.ExecutionTime = job.ExecutionTime;
    55       this.ParentTaskId = job.ParentTaskId;
    56       this.StateLog = new List<StateLog>(job.StateLog);
    57       this.State = job.State;
    58       this.Command = job.Command;
    59       this.LastJobDataUpdate = job.LastJobDataUpdate;
     52    public LightweightTask(Task task) {
     53      this.Id = task.Id;
     54      this.ExecutionTime = task.ExecutionTime;
     55      this.ParentTaskId = task.ParentTaskId;
     56      this.StateLog = new List<StateLog>(task.StateLog);
     57      this.State = task.State;
     58      this.Command = task.Command;
     59      this.LastTaskDataUpdate = task.LastTaskDataUpdate;
    6060    }
    6161  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Permission.cs

    r6717 r6743  
    2828
    2929    /// <summary>
    30     /// User can only download and view experiments
     30    /// User can only download and view jobs
    3131    /// </summary>
    3232    Read,
    3333
    3434    /// <summary>
    35     /// User can pause, stop, restart, delete experiment. can also grant other
     35    /// User can pause, stop, restart, delete job. can also grant other
    3636    /// </summary>
    3737    Full
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/TaskState.cs

    r6721 r6743  
    2626  public enum TaskState {
    2727    /// <summary>
    28     /// A task is offline as long as he is not yet submitted to the hive
     28    /// A task is offline as long as job is not yet submitted to the hive
    2929    /// </summary>
    3030    Offline,
     
    6868  public static class TaskStateExtensions {
    6969    /// <summary>
    70     /// This job is not yet done
     70    /// This task is not yet done
    7171    /// </summary>
    7272    public static bool IsActive(this TaskState taskState) {
     
    7575
    7676    /// <summary>
    77     /// This job is Waiting
     77    /// This task is Waiting
    7878    /// </summary>
    7979    public static bool IsWaiting(this TaskState taskState) {
     
    8282
    8383    /// <summary>
    84     /// This job is Finished || Failed || Aborted
     84    /// This task is Finished || Failed || Aborted
    8585    /// </summary>
    8686    public static bool IsDone(this TaskState taskState) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj

    r6723 r6743  
    7474    <Reference Include="HeuristicLab.Common-3.3">
    7575      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
    76     </Reference>
    77     <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    78       <SpecificVersion>False</SpecificVersion>
    79       <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Common.Resources-3.3.dll</HintPath>
    8076    </Reference>
    8177    <Reference Include="HeuristicLab.Core-3.3">
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HeuristicLabServicesHivePlugin.cs.frame

    r6717 r6743  
    2929  [Plugin("HeuristicLab.Services.Hive", "3.3.5.$WCREV$")]
    3030  [PluginFile("HeuristicLab.Services.Hive-3.3.dll", PluginFileType.Assembly)]
    31   [PluginDependency("HeuristicLab.Common", "3.3")]
    32   [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
     31  [PluginDependency("HeuristicLab.Common", "3.3")] 
    3332  [PluginDependency("HeuristicLab.Core", "3.3")]
    3433  [PluginDependency("HeuristicLab.Persistence", "3.3")] 
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs

    r6725 r6743  
    3636    public HiveDao() { }
    3737
    38     #region Job Methods
    39     public DT.Task GetJob(Guid id) {
     38    #region Task Methods
     39    public DT.Task GetTask(Guid id) {
    4040      using (var db = CreateContext()) {
    4141        return DT.Convert.ToDto(db.Tasks.SingleOrDefault(x => x.TaskId == id));
     
    4343    }
    4444
    45     public IEnumerable<DT.Task> GetJobs(Expression<Func<Task, bool>> predicate) {
     45    public IEnumerable<DT.Task> GetTasks(Expression<Func<Task, bool>> predicate) {
    4646      using (var db = CreateContext()) {
    4747        return db.Tasks.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
     
    4949    }
    5050
    51     public Guid AddJob(DT.Task dto) {
     51    public Guid AddTask(DT.Task dto) {
    5252      using (var db = CreateContext()) {
    5353        var entity = DT.Convert.ToEntity(dto);
     
    6262    }
    6363
    64     public void UpdateJob(DT.Task dto) {
     64    public void UpdateTask(DT.Task dto) {
    6565      using (var db = CreateContext()) {
    6666        var entity = db.Tasks.FirstOrDefault(x => x.TaskId == dto.Id);
     
    7676    }
    7777
    78     public void DeleteJob(Guid id) {
     78    public void DeleteTask(Guid id) {
    7979      using (var db = CreateContext()) {
    8080        var entity = db.Tasks.FirstOrDefault(x => x.TaskId == id);
    8181        if (entity != null) db.Tasks.DeleteOnSubmit(entity);
    82         db.SubmitChanges(); // JobData and child jobs are deleted by db-trigger
     82        db.SubmitChanges(); // taskData and child tasks are deleted by db-trigger
    8383      }
    8484    }
    8585
    8686    /// <summary>
    87     /// returns all parent jobs which are waiting for their child jobs to finish
     87    /// returns all parent tasks which are waiting for their child tasks to finish
    8888    /// </summary>
    89     /// <param name="resourceIds">list of resourceids which for which the jobs should be valid</param>
    90     /// <param name="count">maximum number of jobs to return</param>
    91     /// <param name="finished">if true, all parent jobs which have FinishWhenChildJobsFinished=true are returned, otherwise only FinishWhenChildJobsFinished=false are returned</param>
     89    /// <param name="resourceIds">list of resourceids which for which the task should be valid</param>
     90    /// <param name="count">maximum number of task to return</param>
     91    /// <param name="finished">if true, all parent task which have FinishWhenChildJobsFinished=true are returned, otherwise only FinishWhenChildJobsFinished=false are returned</param>
    9292    /// <returns></returns>
    93     public IEnumerable<DT.Task> GetParentJobs(IEnumerable<Guid> resourceIds, int count, bool finished) {
     93    public IEnumerable<DT.Task> GetParentTasks(IEnumerable<Guid> resourceIds, int count, bool finished) {
    9494      using (var db = CreateContext()) {
    9595        var query = from ar in db.AssignedResources
     
    103103                               || child.State == TaskState.Aborted
    104104                               || child.State == TaskState.Failed).All(x => x)
    105                        && (from child in db.Tasks // avoid returning WaitForChildJobs jobs where no child-jobs exist (yet)
     105                       && (from child in db.Tasks // avoid returning WaitForChildTasks task where no child-task exist (yet)
    106106                           where child.ParentTaskId == ar.Task.TaskId
    107107                           select child).Count() > 0
     
    112112    }
    113113
    114     public IEnumerable<DT.Task> GetWaitingJobs(DT.Slave slave, int count) {
     114    public IEnumerable<DT.Task> GetWaitingTasks(DT.Slave slave, int count) {
    115115      using (var db = CreateContext()) {
    116116        var resourceIds = GetParentResources(slave.Id).Select(r => r.Id);
    117         var waitingParentJobs = GetParentJobs(resourceIds, count, false);
     117        var waitingParentJobs = GetParentTasks(resourceIds, count, false);
    118118        if (count > 0 && waitingParentJobs.Count() >= count) return waitingParentJobs.Take(count).ToArray();
    119119
     
    124124                       && ar.Task.CoresNeeded <= slave.FreeCores
    125125                       && ar.Task.MemoryNeeded <= slave.FreeMemory
    126                     orderby ar.Task.Priority descending, db.Random() // take random job to avoid the race condition that occurs when this method is called concurrently (the same job would be returned)
     126                    orderby ar.Task.Priority descending, db.Random() // take random task to avoid the race condition that occurs when this method is called concurrently (the same task would be returned)
    127127                    select DT.Convert.ToDto(ar.Task);
    128         var waitingJobs = (count == 0 ? query : query.Take(count)).ToArray();
    129         return waitingJobs.Union(waitingParentJobs).OrderByDescending(x => x.Priority);
    130       }
    131     }
    132 
    133     public DT.Task UpdateJobState(Guid jobId, TaskState jobState, Guid? slaveId, Guid? userId, string exception) {
    134       using (var db = CreateContext()) {
    135         var job = db.Tasks.SingleOrDefault(x => x.TaskId == jobId);
    136         job.State = jobState;
     128        var waitingTasks = (count == 0 ? query : query.Take(count)).ToArray();
     129        return waitingTasks.Union(waitingParentJobs).OrderByDescending(x => x.Priority);
     130      }
     131    }
     132
     133    public DT.Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception) {
     134      using (var db = CreateContext()) {
     135        var job = db.Tasks.SingleOrDefault(x => x.TaskId == taskId);
     136        job.State = taskState;
    137137        db.StateLogs.InsertOnSubmit(new StateLog {
    138           TaskId = jobId,
    139           State = jobState,
     138          TaskId = taskId,
     139          State = taskState,
    140140          SlaveId = slaveId,
    141141          UserId = userId,
     
    144144        });
    145145        db.SubmitChanges();
    146         job = db.Tasks.SingleOrDefault(x => x.TaskId == jobId);
     146        job = db.Tasks.SingleOrDefault(x => x.TaskId == taskId);
    147147        return DT.Convert.ToDto(job);
    148148      }
     
    151151
    152152    #region TaskData Methods
    153     public DT.TaskData GetJobData(Guid id) {
     153    public DT.TaskData GetTaskData(Guid id) {
    154154      using (var db = CreateContext(true)) {
    155155        return DT.Convert.ToDto(db.TaskDatas.SingleOrDefault(x => x.TaskId == id));
     
    157157    }
    158158
    159     public IEnumerable<DT.TaskData> GetJobDatas(Expression<Func<TaskData, bool>> predicate) {
     159    public IEnumerable<DT.TaskData> GetTaskDatas(Expression<Func<TaskData, bool>> predicate) {
    160160      using (var db = CreateContext(true)) {
    161161        return db.TaskDatas.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
     
    163163    }
    164164
    165     public Guid AddJobData(DT.TaskData dto) {
     165    public Guid AddTaskData(DT.TaskData dto) {
    166166      using (var db = CreateContext(true)) {
    167167        var entity = DT.Convert.ToEntity(dto);
     
    172172    }
    173173
    174     public void UpdateJobData(DT.TaskData dto) {
     174    public void UpdateTaskData(DT.TaskData dto) {
    175175      using (var db = CreateContext(true)) {
    176176        var entity = db.TaskDatas.FirstOrDefault(x => x.TaskId == dto.TaskId);
     
    181181    }
    182182
    183     public void DeleteJobData(Guid id) {
     183    public void DeleteTaskData(Guid id) {
    184184      using (var db = CreateContext()) {
    185185        var entity = db.TaskDatas.FirstOrDefault(x => x.TaskId == id); // check if all the byte[] is loaded into memory here. otherwise work around to delete without loading it
     
    231231
    232232    #region Job Methods
    233     public DT.Job GetHiveExperiment(Guid id) {
     233    public DT.Job GetJob(Guid id) {
    234234      using (var db = CreateContext()) {
    235235        return AddStatsToExperiment(db, DT.Convert.ToDto(db.Jobs.SingleOrDefault(x => x.JobId == id)));
     
    248248    }
    249249
    250     public IEnumerable<DT.Job> GetHiveExperiments(Expression<Func<Job, bool>> predicate) {
     250    public IEnumerable<DT.Job> GetJobs(Expression<Func<Job, bool>> predicate) {
    251251      using (var db = CreateContext()) {
    252252        return db.Jobs.Where(predicate).Select(x => AddStatsToExperiment(db, DT.Convert.ToDto(x))).ToArray();
     
    254254    }
    255255
    256     public Guid AddHiveExperiment(DT.Job dto) {
     256    public Guid AddJob(DT.Job dto) {
    257257      using (var db = CreateContext()) {
    258258        var entity = DT.Convert.ToEntity(dto);
     
    263263    }
    264264
    265     public void UpdateHiveExperiment(DT.Job dto) {
     265    public void UpdateJob(DT.Job dto) {
    266266      using (var db = CreateContext()) {
    267267        var entity = db.Jobs.FirstOrDefault(x => x.JobId == dto.Id);
     
    272272    }
    273273
    274     public void DeleteHiveExperiment(Guid id) {
     274    public void DeleteJob(Guid id) {
    275275      using (var db = CreateContext()) {
    276276        var entity = db.Jobs.FirstOrDefault(x => x.JobId == id);
     
    282282
    283283    #region JobPermission Methods
    284     public DT.JobPermission GetHiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId) {
    285       using (var db = CreateContext()) {
    286         return DT.Convert.ToDto(db.JobPermissions.SingleOrDefault(x => x.JobId == hiveExperimentId && x.GrantedUserId == grantedUserId));
    287       }
    288     }
    289 
    290     public IEnumerable<DT.JobPermission> GetHiveExperimentPermissions(Expression<Func<JobPermission, bool>> predicate) {
     284    public DT.JobPermission GetJobPermission(Guid jobId, Guid grantedUserId) {
     285      using (var db = CreateContext()) {
     286        return DT.Convert.ToDto(db.JobPermissions.SingleOrDefault(x => x.JobId == jobId && x.GrantedUserId == grantedUserId));
     287      }
     288    }
     289
     290    public IEnumerable<DT.JobPermission> GetJobPermissions(Expression<Func<JobPermission, bool>> predicate) {
    291291      using (var db = CreateContext()) {
    292292        return db.JobPermissions.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
     
    294294    }
    295295
    296     public void AddHiveExperimentPermission(DT.JobPermission dto) {
     296    public void AddJobPermission(DT.JobPermission dto) {
    297297      using (var db = CreateContext()) {
    298298        var entity = DT.Convert.ToEntity(dto);
     
    302302    }
    303303
    304     public void UpdateHiveExperimentPermission(DT.JobPermission dto) {
     304    public void UpdateJobPermission(DT.JobPermission dto) {
    305305      using (var db = CreateContext()) {
    306306        var entity = db.JobPermissions.FirstOrDefault(x => x.JobId == dto.JobId && x.GrantedUserId == dto.GrantedUserId);
     
    311311    }
    312312
    313     public void DeleteHiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId) {
    314       using (var db = CreateContext()) {
    315         var entity = db.JobPermissions.FirstOrDefault(x => x.JobId == hiveExperimentId && x.GrantedUserId == grantedUserId);
     313    public void DeleteJobPermission(Guid jobId, Guid grantedUserId) {
     314      using (var db = CreateContext()) {
     315        var entity = db.JobPermissions.FirstOrDefault(x => x.JobId == jobId && x.GrantedUserId == grantedUserId);
    316316        if (entity != null) db.JobPermissions.DeleteOnSubmit(entity);
    317317        db.SubmitChanges();
     
    322322    /// Sets the permissions for a experiment. makes sure that only one permission per user exists.
    323323    /// </summary>
    324     public void SetHiveExperimentPermission(Guid hiveExperimentId, Guid grantedByUserId, Guid grantedUserId, Permission permission) {
    325       using (var db = CreateContext()) {
    326         JobPermission hiveExperimentPermission = db.JobPermissions.SingleOrDefault(x => x.JobId == hiveExperimentId && x.GrantedUserId == grantedUserId);
    327         if (hiveExperimentPermission != null) {
     324    public void SetJobPermission(Guid jobId, Guid grantedByUserId, Guid grantedUserId, Permission permission) {
     325      using (var db = CreateContext()) {
     326        JobPermission jobPermission = db.JobPermissions.SingleOrDefault(x => x.JobId == jobId && x.GrantedUserId == grantedUserId);
     327        if (jobPermission != null) {
    328328          if (permission == Permission.NotAllowed) {
    329329            // not allowed, delete
    330             db.JobPermissions.DeleteOnSubmit(hiveExperimentPermission);
     330            db.JobPermissions.DeleteOnSubmit(jobPermission);
    331331          } else {
    332332            // update
    333             hiveExperimentPermission.Permission = permission;
    334             hiveExperimentPermission.GrantedByUserId = grantedByUserId; // update grantedByUserId, always the last "granter" is stored
     333            jobPermission.Permission = permission;
     334            jobPermission.GrantedByUserId = grantedByUserId; // update grantedByUserId, always the last "granter" is stored
    335335          }
    336336        } else {
    337337          // insert
    338338          if (permission != Permission.NotAllowed) {
    339             hiveExperimentPermission = new JobPermission() { JobId = hiveExperimentId, GrantedByUserId = grantedByUserId, GrantedUserId = grantedUserId, Permission = permission };
    340             db.JobPermissions.InsertOnSubmit(hiveExperimentPermission);
     339            jobPermission = new JobPermission() { JobId = jobId, GrantedByUserId = grantedByUserId, GrantedUserId = grantedUserId, Permission = permission };
     340            db.JobPermissions.InsertOnSubmit(jobPermission);
    341341          }
    342342        }
     
    613613
    614614    #region Authorization Methods
     615    public Permission GetPermissionForTask(Guid taskId, Guid userId) {
     616      using (var db = CreateContext()) {
     617        return GetPermissionForJob(GetJobForTask(taskId), userId);
     618      }
     619    }
     620
    615621    public Permission GetPermissionForJob(Guid jobId, Guid userId) {
    616622      using (var db = CreateContext()) {
    617         return GetPermissionForExperiment(GetExperimentForJob(jobId), userId);
    618       }
    619     }
    620 
    621     public Permission GetPermissionForExperiment(Guid experimentId, Guid userId) {
    622       using (var db = CreateContext()) {
    623         Job hiveExperiment = db.Jobs.SingleOrDefault(x => x.JobId == experimentId);
    624         if (hiveExperiment == null) return Permission.NotAllowed;
    625         if (hiveExperiment.OwnerUserId == userId) return Permission.Full;
    626         JobPermission permission = db.JobPermissions.SingleOrDefault(p => p.JobId == experimentId && p.GrantedUserId == userId);
     623        Job job = db.Jobs.SingleOrDefault(x => x.JobId == jobId);
     624        if (job == null) return Permission.NotAllowed;
     625        if (job.OwnerUserId == userId) return Permission.Full;
     626        JobPermission permission = db.JobPermissions.SingleOrDefault(p => p.JobId == jobId && p.GrantedUserId == userId);
    627627        return permission != null ? permission.Permission : Permission.NotAllowed;
    628628      }
    629629    }
    630630
    631     public Guid GetExperimentForJob(Guid jobId) {
    632       using (var db = CreateContext()) {
    633         return db.Tasks.Single(j => j.TaskId == jobId).JobId;
     631    public Guid GetJobForTask(Guid taskId) {
     632      using (var db = CreateContext()) {
     633        return db.Tasks.Single(j => j.TaskId == taskId).JobId;
    634634      }
    635635    }
     
    765765        }
    766766
    767         // execution times only of finished jobs - necessary to compute efficieny
     767        // execution times only of finished task - necessary to compute efficieny
    768768        var executionTimesFinishedJobs = from job in db.Tasks
    769769                                         where job.State == TaskState.Finished
     
    778778        }
    779779
    780         // start to end times only of finished jobs - necessary to compute efficiency
     780        // start to end times only of finished task - necessary to compute efficiency
    781781        var startToEndTimesFinishedJobs = from job in db.Tasks
    782782                                          where job.State == TaskState.Finished
     
    817817
    818818    #region Helpers
    819     private void CollectChildJobs(HiveDataContext db, Guid parentJobId, List<Task> collection) {
    820       var jobs = db.Tasks.Where(j => j.ParentTaskId == parentJobId);
    821       foreach (var job in jobs) {
    822         collection.Add(job);
    823         if (job.IsParentTask)
    824           CollectChildJobs(db, job.TaskId, collection);
     819    private void CollectChildTasks(HiveDataContext db, Guid parentTaskId, List<Task> collection) {
     820      var tasks = db.Tasks.Where(j => j.ParentTaskId == parentTaskId);
     821      foreach (var task in tasks) {
     822        collection.Add(task);
     823        if (task.IsParentTask)
     824          CollectChildTasks(db, task.TaskId, collection);
    825825      }
    826826    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r6725 r6743  
    6161
    6262    #region Job Methods
    63     public Guid AddJob(Task job, TaskData jobData, IEnumerable<Guid> resourceIds) {
    64       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    65       return trans.UseTransaction(() => {
    66         job.Id = dao.AddJob(job);
    67         jobData.TaskId = job.Id;
    68         jobData.LastUpdate = DateTime.Now;
     63    public Guid AddTask(Task task, TaskData taskData, IEnumerable<Guid> resourceIds) {
     64      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     65      return trans.UseTransaction(() => {
     66        task.Id = dao.AddTask(task);
     67        taskData.TaskId = task.Id;
     68        taskData.LastUpdate = DateTime.Now;
    6969        foreach (Guid slaveGroupId in resourceIds) {
    70           dao.AssignJobToResource(job.Id, slaveGroupId);
    71         }
    72         dao.AddJobData(jobData);
    73         dao.UpdateJobState(job.Id, DA.TaskState.Waiting, null, userManager.CurrentUserId, null);
    74         return jobData.TaskId;
     70          dao.AssignJobToResource(task.Id, slaveGroupId);
     71        }
     72        dao.AddTaskData(taskData);
     73        dao.UpdateTaskState(task.Id, DA.TaskState.Waiting, null, userManager.CurrentUserId, null);
     74        return taskData.TaskId;
    7575      }, false, true);
    7676    }
    7777
    78     public Guid AddChildJob(Guid parentJobId, Task job, TaskData jobData) {
    79       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    80       return trans.UseTransaction(() => {
    81         job.ParentTaskId = parentJobId;
    82         return AddJob(job, jobData, dao.GetAssignedResources(parentJobId).Select(x => x.Id));
     78    public Guid AddChildTask(Guid parentTaskId, Task task, TaskData taskData) {
     79      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     80      return trans.UseTransaction(() => {
     81        task.ParentTaskId = parentTaskId;
     82        return AddTask(task, taskData, dao.GetAssignedResources(parentTaskId).Select(x => x.Id));
    8383      }, false, true);
    8484    }
    8585
    86     public Task GetJob(Guid jobId) {
    87       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     86    public Task GetTask(Guid taskId) {
     87      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     88      author.AuthorizeForTask(taskId, Permission.Read);
     89      return dao.GetTask(taskId);
     90    }
     91
     92    public IEnumerable<Task> GetTasks() {
     93      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     94      var tasks = dao.GetTasks(x => true);
     95      foreach (var task in tasks)
     96        author.AuthorizeForTask(task.Id, Permission.Read);
     97      return tasks;
     98    }
     99
     100    public IEnumerable<LightweightTask> GetLightweightTasks(IEnumerable<Guid> taskIds) {
     101      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     102      var tasks = dao.GetTasks(x => taskIds.Contains(x.TaskId)).Select(x => new LightweightTask(x)).ToArray();
     103      foreach (var task in tasks)
     104        author.AuthorizeForTask(task.Id, Permission.Read);
     105      return tasks;
     106    }
     107
     108    public IEnumerable<LightweightTask> GetLightweightChildTasks(Guid? parentTaskId, bool recursive, bool includeParent) {
     109      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     110      var tasks = GetChildTasks(parentTaskId, recursive, includeParent).Select(x => new LightweightTask(x)).ToArray();
     111      foreach (var task in tasks)
     112        author.AuthorizeForTask(task.Id, Permission.Read);
     113      return tasks;
     114    }
     115
     116    public IEnumerable<LightweightTask> GetLightweightJobTasks(Guid jobId) {
     117      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    88118      author.AuthorizeForJob(jobId, Permission.Read);
    89       return dao.GetJob(jobId);
    90     }
    91 
    92     public IEnumerable<Task> GetJobs() {
    93       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    94       var jobs = dao.GetJobs(x => true);
    95       foreach (var job in jobs)
    96         author.AuthorizeForJob(job.Id, Permission.Read);
    97       return jobs;
    98     }
    99 
    100     public IEnumerable<LightweightTask> GetLightweightJobs(IEnumerable<Guid> jobIds) {
    101       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    102       var jobs = dao.GetJobs(x => jobIds.Contains(x.TaskId)).Select(x => new LightweightTask(x)).ToArray();
    103       foreach (var job in jobs)
    104         author.AuthorizeForJob(job.Id, Permission.Read);
    105       return jobs;
    106     }
    107 
    108     public IEnumerable<LightweightTask> GetLightweightChildJobs(Guid? parentJobId, bool recursive, bool includeParent) {
    109       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    110       var jobs = GetChildJobs(parentJobId, recursive, includeParent).Select(x => new LightweightTask(x)).ToArray();
    111       foreach (var job in jobs)
    112         author.AuthorizeForJob(job.Id, Permission.Read);
    113       return jobs;
    114     }
    115 
    116     public IEnumerable<LightweightTask> GetLightweightExperimentJobs(Guid experimentId) {
    117       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    118       author.AuthorizeForExperiment(experimentId, Permission.Read);
    119       return dao.GetJobs(x => x.JobId == experimentId).Select(x => new LightweightTask(x)).ToArray();
    120     }
    121 
    122     public TaskData GetJobData(Guid jobId) {
    123       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    124       author.AuthorizeForJob(jobId, Permission.Read);
    125       return dao.GetJobData(jobId);
    126     }
    127 
    128     public void UpdateJob(Task job) {
    129       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    130       author.AuthorizeForJob(job.Id, Permission.Full);
    131       trans.UseTransaction(() => {
    132         dao.UpdateJob(job);
    133       });
    134     }
    135 
    136     public void UpdateJobData(Task job, TaskData jobData) {
    137       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    138       author.AuthorizeForJob(job.Id, Permission.Full);
    139       author.AuthorizeForJob(jobData.TaskId, Permission.Full);
     119      return dao.GetTasks(x => x.JobId == jobId).Select(x => new LightweightTask(x)).ToArray();
     120    }
     121
     122    public TaskData GetTaskData(Guid taskId) {
     123      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     124      author.AuthorizeForTask(taskId, Permission.Read);
     125      return dao.GetTaskData(taskId);
     126    }
     127
     128    public void UpdateTask(Task taskDto) {
     129      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     130      author.AuthorizeForTask(taskDto.Id, Permission.Full);
     131      trans.UseTransaction(() => {
     132        dao.UpdateTask(taskDto);
     133      });
     134    }
     135
     136    public void UpdateTaskData(Task task, TaskData taskData) {
     137      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     138      author.AuthorizeForTask(task.Id, Permission.Full);
     139      author.AuthorizeForTask(taskData.TaskId, Permission.Full);
    140140      //trans.UseTransaction(() => { // cneumuel: try without transaction
    141       jobData.LastUpdate = DateTime.Now;
    142       dao.UpdateJob(job);
    143       dao.UpdateJobData(jobData);
     141      taskData.LastUpdate = DateTime.Now;
     142      dao.UpdateTask(task);
     143      dao.UpdateTaskData(taskData);
    144144      //}, false, true);
    145145    }
    146146
    147     public void DeleteJob(Guid jobId) {
    148       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    149       author.AuthorizeForJob(jobId, Permission.Full);
    150       trans.UseTransaction(() => {
    151         dao.DeleteJob(jobId);
    152       });
    153     }
    154 
    155     public void DeleteChildJobs(Guid parentJobId) {
    156       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    157       author.AuthorizeForJob(parentJobId, Permission.Full);
    158       trans.UseTransaction(() => {
    159         var jobs = GetChildJobs(parentJobId, true, false);
    160         foreach (var job in jobs) {
    161           dao.DeleteJob(job.Id);
    162           dao.DeleteJobData(job.Id);
     147    public void DeleteTask(Guid taskId) {
     148      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     149      author.AuthorizeForTask(taskId, Permission.Full);
     150      trans.UseTransaction(() => {
     151        dao.DeleteTask(taskId);
     152      });
     153    }
     154
     155    public void DeleteChildTasks(Guid parentTaskId) {
     156      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     157      author.AuthorizeForTask(parentTaskId, Permission.Full);
     158      trans.UseTransaction(() => {
     159        var tasks = GetChildTasks(parentTaskId, true, false);
     160        foreach (var task in tasks) {
     161          dao.DeleteTask(task.Id);
     162          dao.DeleteTaskData(task.Id);
    163163        };
    164164      });
    165165    }
    166166
    167     public Task UpdateJobState(Guid jobId, TaskState jobState, Guid? slaveId, Guid? userId, string exception) {
    168       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    169       author.AuthorizeForJob(jobId, Permission.Full);
    170       return trans.UseTransaction(() => {
    171         Task job = dao.UpdateJobState(jobId, DataTransfer.Convert.ToEntity(jobState), slaveId, userId, exception);
    172 
    173         if (job.Command.HasValue && job.Command.Value == Command.Pause && job.State == TaskState.Paused) {
    174           job.Command = null;
    175         } else if (job.Command.HasValue && job.Command.Value == Command.Abort && job.State == TaskState.Aborted) {
    176           job.Command = null;
    177         } else if (job.Command.HasValue && job.Command.Value == Command.Stop && job.State == TaskState.Aborted) {
    178           job.Command = null;
    179         } else if (jobState == TaskState.Paused && !job.Command.HasValue) {
    180           // slave paused and uploaded the job (no user-command) -> set waiting.
    181           job = dao.UpdateJobState(jobId, DataTransfer.Convert.ToEntity(TaskState.Waiting), slaveId, userId, exception);
    182         }
    183 
    184         dao.UpdateJob(job);
    185         return job;
    186       });
    187     }
    188 
    189     public IEnumerable<Task> GetJobsByResourceId(Guid resourceId) {
    190       authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    191       var jobs = trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId));
    192       foreach (var job in jobs)
    193         author.AuthorizeForJob(job.Id, Permission.Read);
    194       return jobs;
     167    public Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception) {
     168      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     169      author.AuthorizeForTask(taskId, Permission.Full);
     170      return trans.UseTransaction(() => {
     171        Task task = dao.UpdateTaskState(taskId, DataTransfer.Convert.ToEntity(taskState), slaveId, userId, exception);
     172
     173        if (task.Command.HasValue && task.Command.Value == Command.Pause && task.State == TaskState.Paused) {
     174          task.Command = null;
     175        } else if (task.Command.HasValue && task.Command.Value == Command.Abort && task.State == TaskState.Aborted) {
     176          task.Command = null;
     177        } else if (task.Command.HasValue && task.Command.Value == Command.Stop && task.State == TaskState.Aborted) {
     178          task.Command = null;
     179        } else if (taskState == TaskState.Paused && !task.Command.HasValue) {
     180          // slave paused and uploaded the task (no user-command) -> set waiting.
     181          task = dao.UpdateTaskState(taskId, DataTransfer.Convert.ToEntity(TaskState.Waiting), slaveId, userId, exception);
     182        }
     183
     184        dao.UpdateTask(task);
     185        return task;
     186      });
     187    }
     188
     189    public IEnumerable<Task> GetTasksByResourceId(Guid resourceId) {
     190      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
     191      var tasks = trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId));
     192      foreach (var task in tasks)
     193        author.AuthorizeForTask(task.Id, Permission.Read);
     194      return tasks;
    195195    }
    196196    #endregion
    197197
    198198    #region Task Control Methods
    199     public void StopJob(Guid jobId) {
    200       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    201       author.AuthorizeForJob(jobId, Permission.Full);
    202       trans.UseTransaction(() => {
    203         var job = dao.GetJob(jobId);
    204         if (job.State == TaskState.Calculating || job.State == TaskState.Transferring) {
    205           job.Command = Command.Stop;
    206           dao.UpdateJob(job);
     199    public void StopTask(Guid taskId) {
     200      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     201      author.AuthorizeForTask(taskId, Permission.Full);
     202      trans.UseTransaction(() => {
     203        var task = dao.GetTask(taskId);
     204        if (task.State == TaskState.Calculating || task.State == TaskState.Transferring) {
     205          task.Command = Command.Stop;
     206          dao.UpdateTask(task);
    207207        } else {
    208           if (job.State != TaskState.Aborted && job.State != TaskState.Finished && job.State != TaskState.Failed) {
    209             job = UpdateJobState(jobId, TaskState.Aborted, null, null, string.Empty);
     208          if (task.State != TaskState.Aborted && task.State != TaskState.Finished && task.State != TaskState.Failed) {
     209            task = UpdateTaskState(taskId, TaskState.Aborted, null, null, string.Empty);
    210210          }
    211211        }
     
    213213    }
    214214
    215     public void PauseJob(Guid jobId) {
    216       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    217       author.AuthorizeForJob(jobId, Permission.Full);
    218       trans.UseTransaction(() => {
    219         var job = dao.GetJob(jobId);
     215    public void PauseTask(Guid taskId) {
     216      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     217      author.AuthorizeForTask(taskId, Permission.Full);
     218      trans.UseTransaction(() => {
     219        var job = dao.GetTask(taskId);
    220220        if (job.State == TaskState.Calculating || job.State == TaskState.Transferring) {
    221221          job.Command = Command.Pause;
    222           dao.UpdateJob(job);
     222          dao.UpdateTask(job);
    223223        } else {
    224           job = UpdateJobState(jobId, TaskState.Paused, null, null, string.Empty);
    225         }
    226       });
    227     }
    228 
    229     public void RestartJob(Guid jobId) {
    230       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    231       author.AuthorizeForJob(jobId, Permission.Full);
    232       trans.UseTransaction(() => {
    233         Task job = dao.UpdateJobState(jobId, DA.TaskState.Waiting, null, userManager.CurrentUserId, string.Empty);
    234         job.Command = null;
    235         dao.UpdateJob(job);
     224          job = UpdateTaskState(taskId, TaskState.Paused, null, null, string.Empty);
     225        }
     226      });
     227    }
     228
     229    public void RestartTask(Guid taskId) {
     230      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     231      author.AuthorizeForTask(taskId, Permission.Full);
     232      trans.UseTransaction(() => {
     233        Task task = dao.UpdateTaskState(taskId, DA.TaskState.Waiting, null, userManager.CurrentUserId, string.Empty);
     234        task.Command = null;
     235        dao.UpdateTask(task);
    236236      });
    237237    }
     
    239239
    240240    #region Job Methods
    241     public Job GetHiveExperiment(Guid id) {
    242       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    243       author.AuthorizeForExperiment(id, Permission.Read);
    244       var hiveExperiment = dao.GetHiveExperiments(x =>
     241    public Job GetJob(Guid id) {
     242      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     243      author.AuthorizeForJob(id, Permission.Read);
     244      var job = dao.GetJobs(x =>
    245245            x.JobId == id
    246246            && (x.OwnerUserId == userManager.CurrentUserId || x.JobPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0)
    247247          ).FirstOrDefault();
    248       if (hiveExperiment != null) {
    249         hiveExperiment.Permission = DT.Convert.ToDto(dao.GetPermissionForExperiment(hiveExperiment.Id, userManager.CurrentUserId));
    250         hiveExperiment.OwnerUsername = userManager.GetUserById(hiveExperiment.OwnerUserId).UserName;
     248      if (job != null) {
     249        job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId));
     250        job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName;
    251251      }
    252       return hiveExperiment;
    253     }
    254 
    255     public IEnumerable<Job> GetHiveExperiments() {
    256       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    257       var hiveExperiments = dao.GetHiveExperiments(x => x.OwnerUserId == userManager.CurrentUserId || x.JobPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0);
    258       foreach (var he in hiveExperiments) {
    259         author.AuthorizeForExperiment(he.Id, Permission.Read);
    260         he.Permission = DT.Convert.ToDto(dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId));
    261         he.OwnerUsername = userManager.GetUserById(he.OwnerUserId).UserName;
     252      return job;
     253    }
     254
     255    public IEnumerable<Job> GetJobs() {
     256      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     257      var jobs = dao.GetJobs(x => x.OwnerUserId == userManager.CurrentUserId || x.JobPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0);
     258      foreach (var job in jobs) {
     259        author.AuthorizeForJob(job.Id, Permission.Read);
     260        job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId));
     261        job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName;
    262262      }
    263       return hiveExperiments;
    264     }
    265 
    266     public IEnumerable<Job> GetAllHiveExperiments() {
    267       authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    268       var hiveExperiments = dao.GetHiveExperiments(x => true);
    269       foreach (var he in hiveExperiments) { // no authorization here, since this method is admin-only! (admin is allowed to read all jobs)
    270         he.Permission = DT.Convert.ToDto(dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId));
    271         he.OwnerUsername = userManager.GetUserById(he.OwnerUserId).UserName;
     263      return jobs;
     264    }
     265
     266    public IEnumerable<Job> GetAllJobs() {
     267      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
     268      var jobs = dao.GetJobs(x => true);
     269      foreach (var job in jobs) { // no authorization here, since this method is admin-only! (admin is allowed to read all task)
     270        job.Permission = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId));
     271        job.OwnerUsername = userManager.GetUserById(job.OwnerUserId).UserName;
    272272      }
    273       return hiveExperiments;
    274     }
    275 
    276     public Guid AddHiveExperiment(Job hiveExperimentDto) {
    277       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    278       return trans.UseTransaction(() => {
    279         hiveExperimentDto.OwnerUserId = userManager.CurrentUserId;
    280         hiveExperimentDto.DateCreated = DateTime.Now;
    281         return dao.AddHiveExperiment(hiveExperimentDto);
    282       });
    283     }
    284 
    285     public void UpdateHiveExperiment(Job hiveExperimentDto) {
    286       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    287       author.AuthorizeForExperiment(hiveExperimentDto.Id, Permission.Full);
    288       trans.UseTransaction(() => {
    289         dao.UpdateHiveExperiment(hiveExperimentDto);
    290       });
    291     }
    292 
    293     public void DeleteHiveExperiment(Guid hiveExperimentId) {
    294       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    295       author.AuthorizeForExperiment(hiveExperimentId, Permission.Full);
    296       trans.UseTransaction(() => {
    297         dao.DeleteHiveExperiment(hiveExperimentId); // child jobs will be deleted by db-trigger
    298       });
    299     }
    300     #endregion
    301 
    302     #region HiveExperimentPermission Methods
    303     public void GrantPermission(Guid hiveExperimentId, Guid grantedUserId, Permission permission) {
    304       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    305       trans.UseTransaction(() => {
    306         Job he = dao.GetHiveExperiment(hiveExperimentId);
    307         if (he == null) throw new FaultException<FaultReason>(new FaultReason("Could not find hiveExperiment with id " + hiveExperimentId));
    308         Permission perm = DT.Convert.ToDto(dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId));
     273      return jobs;
     274    }
     275
     276    public Guid AddJob(Job jobDto) {
     277      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     278      return trans.UseTransaction(() => {
     279        jobDto.OwnerUserId = userManager.CurrentUserId;
     280        jobDto.DateCreated = DateTime.Now;
     281        return dao.AddJob(jobDto);
     282      });
     283    }
     284
     285    public void UpdateJob(Job jobDto) {
     286      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     287      author.AuthorizeForJob(jobDto.Id, Permission.Full);
     288      trans.UseTransaction(() => {
     289        dao.UpdateJob(jobDto);
     290      });
     291    }
     292
     293    public void DeleteJob(Guid jobId) {
     294      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     295      author.AuthorizeForJob(jobId, Permission.Full);
     296      trans.UseTransaction(() => {
     297        dao.DeleteJob(jobId); // child task will be deleted by db-trigger
     298      });
     299    }
     300    #endregion
     301
     302    #region JobPermission Methods
     303    public void GrantPermission(Guid jobId, Guid grantedUserId, Permission permission) {
     304      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     305      trans.UseTransaction(() => {
     306        Job job = dao.GetJob(jobId);
     307        if (job == null) throw new FaultException<FaultReason>(new FaultReason("Could not find task with id " + jobId));
     308        Permission perm = DT.Convert.ToDto(dao.GetPermissionForJob(job.Id, userManager.CurrentUserId));
    309309        if (perm != Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment"));
    310         dao.SetHiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, DT.Convert.ToEntity(permission));
    311       });
    312     }
    313 
    314     public void RevokePermission(Guid hiveExperimentId, Guid grantedUserId) {
    315       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    316       trans.UseTransaction(() => {
    317         Job he = dao.GetHiveExperiment(hiveExperimentId);
    318         if (he == null) throw new FaultException<FaultReason>(new FaultReason("Could not find hiveExperiment with id " + hiveExperimentId));
    319         DA.Permission perm = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);
     310        dao.SetJobPermission(jobId, userManager.CurrentUserId, grantedUserId, DT.Convert.ToEntity(permission));
     311      });
     312    }
     313
     314    public void RevokePermission(Guid jobId, Guid grantedUserId) {
     315      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     316      trans.UseTransaction(() => {
     317        Job job = dao.GetJob(jobId);
     318        if (job == null) throw new FaultException<FaultReason>(new FaultReason("Could not find task with id " + jobId));
     319        DA.Permission perm = dao.GetPermissionForJob(job.Id, userManager.CurrentUserId);
    320320        if (perm != DA.Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment"));
    321         dao.SetHiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, DA.Permission.NotAllowed);
    322       });
    323     }
    324     public IEnumerable<JobPermission> GetHiveExperimentPermissions(Guid hiveExperimentId) {
    325       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    326       return trans.UseTransaction(() => {
    327         DA.Permission currentUserPermission = dao.GetPermissionForExperiment(hiveExperimentId, userManager.CurrentUserId);
     321        dao.SetJobPermission(jobId, userManager.CurrentUserId, grantedUserId, DA.Permission.NotAllowed);
     322      });
     323    }
     324    public IEnumerable<JobPermission> GetJobPermissions(Guid jobId) {
     325      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     326      return trans.UseTransaction(() => {
     327        DA.Permission currentUserPermission = dao.GetPermissionForJob(jobId, userManager.CurrentUserId);
    328328        if (currentUserPermission != DA.Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to list permissions for this experiment"));
    329         return dao.GetHiveExperimentPermissions(x => x.JobId == hiveExperimentId);
     329        return dao.GetJobPermissions(x => x.JobId == jobId);
    330330      });
    331331    }
     
    591591
    592592    #region Helper Methods
    593     private IEnumerable<Task> GetChildJobs(Guid? parentJobId, bool recursive, bool includeParent) {
    594       var jobs = new List<Task>(dao.GetJobs(x => parentJobId == null ? !x.ParentTaskId.HasValue : x.ParentTaskId.Value == parentJobId));
     593    private IEnumerable<Task> GetChildTasks(Guid? parentTaskId, bool recursive, bool includeParent) {
     594      var tasks = new List<Task>(dao.GetTasks(x => parentTaskId == null ? !x.ParentTaskId.HasValue : x.ParentTaskId.Value == parentTaskId));
    595595
    596596      if (recursive) {
    597597        var childs = new List<Task>();
    598         foreach (var job in jobs) {
    599           childs.AddRange(GetChildJobs(job.Id, recursive, false));
    600         }
    601         jobs.AddRange(childs);
     598        foreach (var task in tasks) {
     599          childs.AddRange(GetChildTasks(task.Id, recursive, false));
     600        }
     601        tasks.AddRange(childs);
    602602      }
    603603
    604       if (includeParent) jobs.Add(GetJob(parentJobId.Value));
    605       return jobs;
     604      if (includeParent) tasks.Add(GetTask(parentTaskId.Value));
     605      return tasks;
    606606    }
    607607    #endregion
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IAuthorizationManager.cs

    r6717 r6743  
    3030    void Authorize(Guid userId);
    3131
     32    void AuthorizeForTask(Guid taskId, Permission requiredPermission);
     33
    3234    void AuthorizeForJob(Guid jobId, Permission requiredPermission);
    33 
    34     void AuthorizeForExperiment(Guid experimentId, Permission requiredPermission);
    3535  }
    3636}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IEventManager.cs

    r6698 r6743  
    2222namespace HeuristicLab.Services.Hive {
    2323  /// <summary>
    24   /// The only object in hive which holds a state. Must allow restarts without resetting all jobs
     24  /// The only object in hive which holds a state. Must allow restarts without resetting all task
    2525  /// </summary>
    2626  public interface IEventManager {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IHiveDao.cs

    r6725 r6743  
    2929  public interface IHiveDao {
    3030    #region Task Methods
    31     DT.Task GetJob(Guid id);
    32     IEnumerable<DT.Task> GetJobs(Expression<Func<Task, bool>> predicate);
    33     Guid AddJob(DT.Task dto);
    34     void UpdateJob(DT.Task dto);
    35     void DeleteJob(Guid id);
    36     IEnumerable<DT.Task> GetWaitingJobs(DT.Slave slave, int count);
    37     IEnumerable<DT.Task> GetParentJobs(IEnumerable<Guid> resourceIds, int count, bool finished);
    38     DT.Task UpdateJobState(Guid jobId, TaskState jobState, Guid? slaveId, Guid? userId, string exception);
     31    DT.Task GetTask(Guid id);
     32    IEnumerable<DT.Task> GetTasks(Expression<Func<Task, bool>> predicate);
     33    Guid AddTask(DT.Task dto);
     34    void UpdateTask(DT.Task dto);
     35    void DeleteTask(Guid id);
     36    IEnumerable<DT.Task> GetWaitingTasks(DT.Slave slave, int count);
     37    IEnumerable<DT.Task> GetParentTasks(IEnumerable<Guid> resourceIds, int count, bool finished);
     38    DT.Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception);
    3939    #endregion
    4040
    4141    #region TaskData Methods
    42     DT.TaskData GetJobData(Guid id);
    43     IEnumerable<DT.TaskData> GetJobDatas(Expression<Func<TaskData, bool>> predicate);
    44     Guid AddJobData(DT.TaskData dto);
    45     void UpdateJobData(DT.TaskData dto);
    46     void DeleteJobData(Guid id);
     42    DT.TaskData GetTaskData(Guid id);
     43    IEnumerable<DT.TaskData> GetTaskDatas(Expression<Func<TaskData, bool>> predicate);
     44    Guid AddTaskData(DT.TaskData dto);
     45    void UpdateTaskData(DT.TaskData dto);
     46    void DeleteTaskData(Guid id);
    4747    #endregion
    4848
     
    5555    #endregion
    5656
    57     #region HiveExperiment Methods
    58     DT.Job GetHiveExperiment(Guid id);
    59     IEnumerable<DT.Job> GetHiveExperiments(Expression<Func<Job, bool>> predicate);
    60     Guid AddHiveExperiment(DT.Job dto);
    61     void UpdateHiveExperiment(DT.Job dto);
    62     void DeleteHiveExperiment(Guid id);
     57    #region Job Methods
     58    DT.Job GetJob(Guid id);
     59    IEnumerable<DT.Job> GetJobs(Expression<Func<Job, bool>> predicate);
     60    Guid AddJob(DT.Job dto);
     61    void UpdateJob(DT.Job dto);
     62    void DeleteJob(Guid id);
    6363    #endregion
    6464
    65     #region HiveExperimentPermission Methods
    66     DT.JobPermission GetHiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId);
    67     IEnumerable<DT.JobPermission> GetHiveExperimentPermissions(Expression<Func<JobPermission, bool>> predicate);
    68     void AddHiveExperimentPermission(DT.JobPermission dto);
    69     void UpdateHiveExperimentPermission(DT.JobPermission dto);
    70     void DeleteHiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId);
    71     void SetHiveExperimentPermission(Guid hiveExperimentId, Guid grantedByUserId, Guid grantedUserId, Permission permission);
     65    #region JobPermission Methods
     66    DT.JobPermission GetJobPermission(Guid jobId, Guid grantedUserId);
     67    IEnumerable<DT.JobPermission> GetJobPermissions(Expression<Func<JobPermission, bool>> predicate);
     68    void AddJobPermission(DT.JobPermission dto);
     69    void UpdateJobPermission(DT.JobPermission dto);
     70    void DeleteJobPermission(Guid jobId, Guid grantedUserId);
     71    void SetJobPermission(Guid jobId, Guid grantedByUserId, Guid grantedUserId, Permission permission);
    7272    #endregion
    7373
     
    8686    void UpdatePluginData(DT.PluginData dto);
    8787    void DeletePluginData(Guid id);
    88     #endregion
    89 
    90     #region Calendar Methods
    9188    #endregion
    9289
     
    121118
    122119    #region Authorization Methods
     120    Permission GetPermissionForTask(Guid taskId, Guid userId);
    123121    Permission GetPermissionForJob(Guid jobId, Guid userId);
    124     Permission GetPermissionForExperiment(Guid experimentId, Guid userId);
    125     Guid GetExperimentForJob(Guid jobId);
     122    Guid GetJobForTask(Guid taskId);
    126123    #endregion
    127124
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/AuthorizationManager.cs

    r6717 r6743  
    3333    }
    3434
     35    public void AuthorizeForTask(Guid taskId, DT.Permission requiredPermission) {
     36      if (ServiceLocator.Instance.AuthenticationManager.IsInRole(HiveRoles.Slave)) return; // slave-users can access all tasks
     37
     38      Permission permission = ServiceLocator.Instance.HiveDao.GetPermissionForTask(taskId, ServiceLocator.Instance.UserManager.CurrentUserId);
     39      if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full))
     40        throw new SecurityException("Current user is not authorized to access task");
     41    }
     42
    3543    public void AuthorizeForJob(Guid jobId, DT.Permission requiredPermission) {
    36       if (ServiceLocator.Instance.AuthenticationManager.IsInRole(HiveRoles.Slave)) return; // slave-users can access all jobs
    37 
    3844      Permission permission = ServiceLocator.Instance.HiveDao.GetPermissionForJob(jobId, ServiceLocator.Instance.UserManager.CurrentUserId);
    3945      if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full))
    40         throw new SecurityException("Current user is not authorized to access job");
    41     }
    42 
    43     public void AuthorizeForExperiment(Guid experimentId, DT.Permission requiredPermission) {
    44       Permission permission = ServiceLocator.Instance.HiveDao.GetPermissionForExperiment(experimentId, ServiceLocator.Instance.UserManager.CurrentUserId);
    45       if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full))
    46         throw new SecurityException("Current user is not authorized to access experiment");
     46        throw new SecurityException("Current user is not authorized to access task");
    4747    }
    4848  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/EventManager.cs

    r6721 r6743  
    2929namespace HeuristicLab.Services.Hive {
    3030  /// <summary>
    31   /// This class offers methods for cleaning up offline slaves and jobs
     31  /// This class offers methods for cleaning up offline slaves and task
    3232  /// </summary>
    3333  public class EventManager : IEventManager {
     
    4545      log.Log("EventManager.Cleanup()");
    4646      SetTimeoutSlavesOffline();
    47       SetTimeoutJobsWaiting();
    48       FinishParentJobs();
     47      SetTimeoutTasksWaiting();
     48      FinishParentTasks();
    4949      UpdateStatistics();
    5050    }
     
    7272
    7373    /// <summary>
    74     /// Searches for slaves which are timed out, puts them and their jobs offline
     74    /// Searches for slaves which are timed out, puts them and their task offline
    7575    /// </summary>
    7676    private void SetTimeoutSlavesOffline() {
     
    7979        if (!slave.LastHeartbeat.HasValue || (DateTime.Now - slave.LastHeartbeat.Value) > HeuristicLab.Services.Hive.Properties.Settings.Default.SlaveHeartbeatTimeout) {
    8080          slave.SlaveState = DT.SlaveState.Offline;
    81           SetJobsWaiting(slave.Id);
     81          SetTasksWaiting(slave.Id);
    8282          dao.UpdateSlave(slave);
    8383        }
     
    8686
    8787    /// <summary>
    88     /// Looks for parent jobs which have FinishWhenChildJobsFinished and set their state to finished
     88    /// Looks for parent tasks which have FinishWhenChildJobsFinished and set their state to finished
    8989    /// </summary>
    90     private void FinishParentJobs() {
    91       var parentJobsToFinish = dao.GetParentJobs(dao.GetResources(x => true).Select(x => x.Id), 0, true);
    92       foreach (var job in parentJobsToFinish) {
    93         dao.UpdateJobState(job.Id, TaskState.Finished, null, null, string.Empty);
     90    private void FinishParentTasks() {
     91      var parentTasksToFinish = dao.GetParentTasks(dao.GetResources(x => true).Select(x => x.Id), 0, true);
     92      foreach (var task in parentTasksToFinish) {
     93        dao.UpdateTaskState(task.Id, TaskState.Finished, null, null, string.Empty);
    9494      }
    9595    }
    9696
    97     private void SetJobsWaiting(Guid slaveId) {
    98       var jobs = dao.GetJobs(x => x.State == TaskState.Calculating).Where(x => x.StateLog.Last().SlaveId == slaveId);
    99       foreach (var j in jobs) {
    100         DT.Task job = dao.UpdateJobState(j.Id, TaskState.Waiting, slaveId, null, "Slave timed out.");
    101         job.Command = null;
    102         dao.UpdateJob(job);
     97    private void SetTasksWaiting(Guid slaveId) {
     98      var tasks = dao.GetTasks(x => x.State == TaskState.Calculating).Where(x => x.StateLog.Last().SlaveId == slaveId);
     99      foreach (var j in tasks) {
     100        DT.Task task = dao.UpdateTaskState(j.Id, TaskState.Waiting, slaveId, null, "Slave timed out.");
     101        task.Command = null;
     102        dao.UpdateTask(task);
    103103      }
    104104    }
    105105
    106106    /// <summary>
    107     /// Looks for jobs which have not sent heartbeats for some time and reschedules them for calculation
     107    /// Looks for task which have not sent heartbeats for some time and reschedules them for calculation
    108108    /// </summary>
    109     private void SetTimeoutJobsWaiting() {
    110       var jobs = dao.GetJobs(x => (x.State == TaskState.Calculating && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.CalculatingJobHeartbeatTimeout)
     109    private void SetTimeoutTasksWaiting() {
     110      var tasks = dao.GetTasks(x => (x.State == TaskState.Calculating && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.CalculatingJobHeartbeatTimeout)
    111111                               || (x.State == TaskState.Transferring && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.TransferringJobHeartbeatTimeout));
    112       foreach (var j in jobs) {
    113         DT.Task job = dao.UpdateJobState(j.Id, TaskState.Waiting, null, null, "Slave timed out.");
    114         job.Command = null;
    115         dao.UpdateJob(job);
     112      foreach (var j in tasks) {
     113        DT.Task task = dao.UpdateTaskState(j.Id, TaskState.Waiting, null, null, "Slave timed out.");
     114        task.Command = null;
     115        dao.UpdateTask(task);
    116116      }
    117117    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs

    r6725 r6743  
    5454        dao.UpdateSlave(slave);
    5555
    56         // update job data
    57         actions.AddRange(UpdateJobs(heartbeat, slave.IsAllowedToCalculate));
     56        // update task data
     57        actions.AddRange(UpdateTasks(heartbeat, slave.IsAllowedToCalculate));
    5858
    59         // assign new job
     59        // assign new task
    6060        if (heartbeat.AssignJob && slave.IsAllowedToCalculate && heartbeat.FreeCores > 0) {
    61           var availableJobs = dao.GetWaitingJobs(slave, 1);
     61          var availableJobs = dao.GetWaitingTasks(slave, 1);
    6262          if (availableJobs.Count() > 0) {
    6363            var job = availableJobs.First();
     
    7171
    7272    // returns true if assignment was successful
    73     private bool AssignJob(Slave slave, Task job) {
    74       // load job again and check if it is still available (this is an attempt to reduce the race condition which causes multiple heartbeats to get the same job assigned)
    75       if (dao.GetJob(job.Id).State != TaskState.Waiting) return false;
     73    private bool AssignJob(Slave slave, Task task) {
     74      // load task again and check if it is still available (this is an attempt to reduce the race condition which causes multiple heartbeats to get the same task assigned)
     75      if (dao.GetTask(task.Id).State != TaskState.Waiting) return false;
    7676
    77       job = dao.UpdateJobState(job.Id, DataAccess.TaskState.Transferring, slave.Id, null, null);
     77      task = dao.UpdateTaskState(task.Id, DataAccess.TaskState.Transferring, slave.Id, null, null);
    7878
    79       // from now on the job has some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout)
    80       job.LastHeartbeat = DateTime.Now;
    81       dao.UpdateJob(job);
     79      // from now on the task has some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout)
     80      task.LastHeartbeat = DateTime.Now;
     81      dao.UpdateTask(task);
    8282      return true;
    8383    }
    8484
    8585    /// <summary>
    86     /// Update the progress of each job
    87     /// Checks if all the jobs sent by heartbeat are supposed to be calculated by this slave
     86    /// Update the progress of each task
     87    /// Checks if all the task sent by heartbeat are supposed to be calculated by this slave
    8888    /// </summary>
    89     private IEnumerable<MessageContainer> UpdateJobs(Heartbeat heartbeat, bool IsAllowedToCalculate) {
     89    private IEnumerable<MessageContainer> UpdateTasks(Heartbeat heartbeat, bool IsAllowedToCalculate) {
    9090      List<MessageContainer> actions = new List<MessageContainer>();
    9191
     
    9898        // process the jobProgresses
    9999        foreach (var jobProgress in heartbeat.JobProgress) {
    100           Task curJob = dao.GetJob(jobProgress.Key);
     100          Task curJob = dao.GetTask(jobProgress.Key);
    101101          if (curJob == null) {
    102             // job does not exist in db
     102            // task does not exist in db
    103103            actions.Add(new MessageContainer(MessageContainer.MessageType.AbortTask, jobProgress.Key));
    104104            DA.LogFactory.GetLogger(this.GetType().Namespace).Log("Job does not exist in DB: " + jobProgress.Key);
     
    108108              actions.Add(new MessageContainer(MessageContainer.MessageType.AbortTask, curJob.Id));
    109109              DA.LogFactory.GetLogger(this.GetType().Namespace).Log("The slave " + heartbeat.SlaveId + " is not supposed to calculate Job: " + curJob);
    110             } else if (!JobIsAllowedToBeCalculatedBySlave(heartbeat.SlaveId, curJob)) {
    111               // assigned resources ids of job do not match with slaveId (and parent resourceGroupIds); this might happen when slave is moved to different group
     110            } else if (!TaskIsAllowedToBeCalculatedBySlave(heartbeat.SlaveId, curJob)) {
     111              // assigned resources ids of task do not match with slaveId (and parent resourceGroupIds); this might happen when slave is moved to different group
    112112              actions.Add(new MessageContainer(MessageContainer.MessageType.PauseTask, curJob.Id));
    113113            } else {
    114               // save job execution time
     114              // save task execution time
    115115              curJob.ExecutionTime = jobProgress.Value;
    116116              curJob.LastHeartbeat = DateTime.Now;
     
    127127                  break;
    128128              }
    129               dao.UpdateJob(curJob);
     129              dao.UpdateTask(curJob);
    130130            }
    131131          }
     
    135135    }
    136136
    137     private bool JobIsAllowedToBeCalculatedBySlave(Guid slaveId, Task curJob) {
    138       var assignedResourceIds = dao.GetAssignedResources(curJob.Id).Select(x => x.Id);
     137    private bool TaskIsAllowedToBeCalculatedBySlave(Guid slaveId, Task curTask) {
     138      var assignedResourceIds = dao.GetAssignedResources(curTask.Id).Select(x => x.Id);
    139139      var slaveResourceIds = dao.GetParentResources(slaveId).Select(x => x.Id);
    140140      return assignedResourceIds.Any(x => slaveResourceIds.Contains(x));
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/MessageContainer.cs

    r6725 r6743  
    3737    public enum MessageType {
    3838      // *** commands from hive server ***
    39       CalculateTask, // slave should calculate a job. the job is already assigned to the slave
    40       StopTask,   // slave should stop the job and submit results
     39      CalculateTask, // slave should calculate a task. the task is already assigned to the slave
     40      StopTask,   // slave should stop the task and submit results
    4141      StopAll,   // stop all and submit results
    42       AbortTask,  // slave should shut the job down immediately without submitting results
    43       AbortAll,  // slave should abort all jobs immediately
    44       PauseTask,  // pause the job and submit the results   
    45       PauseAll,  // pause all jobs and submit results
     42      AbortTask,  // slave should shut the task down immediately without submitting results
     43      AbortAll,  // slave should abort all task immediately
     44      PauseTask,  // pause the task and submit the results   
     45      PauseAll,  // pause all task and submit results
    4646      Restart,   // restart operation after Sleep
    4747      Sleep,     // disconnect from server, but don't shutdown
    4848      ShutdownSlave,  // slave should shutdown immediately without submitting results
    49       SayHello,  // Slave should say hello, because he is unknown to the server
     49      SayHello,  // Slave should say hello, because job is unknown to the server
    5050    };
    5151
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs

    r6725 r6743  
    3333    #region Task Methods
    3434    [OperationContract]
    35     Guid AddJob(Task job, TaskData jobData, IEnumerable<Guid> resourceIds);
    36 
    37     [OperationContract]
    38     Guid AddChildJob(Guid parentJobId, Task job, TaskData jobData);
    39 
    40     [OperationContract]
    41     Task GetJob(Guid jobId);
    42 
    43     [OperationContract]
    44     IEnumerable<Task> GetJobs();
    45 
    46     [OperationContract]
    47     IEnumerable<LightweightTask> GetLightweightJobs(IEnumerable<Guid> jobIds);
    48 
    49     [OperationContract]
    50     IEnumerable<LightweightTask> GetLightweightChildJobs(Guid? parentJobId, bool recursive, bool includeParent);
    51 
    52     [OperationContract]
    53     IEnumerable<LightweightTask> GetLightweightExperimentJobs(Guid experimentId);
    54 
    55     [OperationContract]
    56     TaskData GetJobData(Guid jobId);
    57 
    58     [OperationContract]
    59     void UpdateJob(Task jobDto);
    60 
    61     [OperationContract]
    62     void UpdateJobData(Task jobDto, TaskData jobDataDto);
    63 
    64     [OperationContract]
    65     void DeleteJob(Guid jobId);
    66 
    67     [OperationContract]
    68     void DeleteChildJobs(Guid parentJobId);
    69 
    70     [OperationContract]
    71     Task UpdateJobState(Guid jobId, TaskState jobState, Guid? slaveId, Guid? userId, string exception);
    72     #endregion
    73 
    74     #region Job Control Methods
    75     [OperationContract]
    76     void StopJob(Guid jobId);
    77 
    78     [OperationContract]
    79     void PauseJob(Guid jobId);
    80 
    81     [OperationContract]
    82     void RestartJob(Guid jobId);
     35    Guid AddTask(Task task, TaskData taskData, IEnumerable<Guid> resourceIds);
     36
     37    [OperationContract]
     38    Guid AddChildTask(Guid parentTaskId, Task task, TaskData taskData);
     39
     40    [OperationContract]
     41    Task GetTask(Guid taskId);
     42
     43    [OperationContract]
     44    IEnumerable<Task> GetTasks();
     45
     46    [OperationContract]
     47    IEnumerable<LightweightTask> GetLightweightTasks(IEnumerable<Guid> taskIds);
     48
     49    [OperationContract]
     50    IEnumerable<LightweightTask> GetLightweightChildTasks(Guid? parentTaskId, bool recursive, bool includeParent);
     51
     52    [OperationContract]
     53    IEnumerable<LightweightTask> GetLightweightJobTasks(Guid jobId);
     54
     55    [OperationContract]
     56    TaskData GetTaskData(Guid taskId);
     57
     58    [OperationContract]
     59    void UpdateTask(Task taskDto);
     60
     61    [OperationContract]
     62    void UpdateTaskData(Task taskDto, TaskData taskDataDto);
     63
     64    [OperationContract]
     65    void DeleteTask(Guid taskId);
     66
     67    [OperationContract]
     68    void DeleteChildTasks(Guid parentTaskId);
     69
     70    [OperationContract]
     71    Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception);
     72    #endregion
     73
     74    #region Task Control Methods
     75    [OperationContract]
     76    void StopTask(Guid taskId);
     77
     78    [OperationContract]
     79    void PauseTask(Guid taskId);
     80
     81    [OperationContract]
     82    void RestartTask(Guid taskId);
    8383    #endregion
    8484
    8585    #region Job Methods
    8686    [OperationContract]
    87     Job GetHiveExperiment(Guid id);
     87    Job GetJob(Guid id);
    8888
    8989    /// <summary>
    90     /// Returns all experiments for the current user
     90    /// Returns all task for the current user
    9191    /// </summary>
    9292    [OperationContract]
    93     IEnumerable<Job> GetHiveExperiments();
     93    IEnumerable<Job> GetJobs();
    9494
    9595    /// <summary>
    96     /// Returns all experiments in the hive (only for admins)
     96    /// Returns all task in the hive (only for admins)
    9797    /// </summary>
    9898    /// <returns></returns>
    9999    [OperationContract]
    100     IEnumerable<Job> GetAllHiveExperiments();
    101 
    102     [OperationContract]
    103     Guid AddHiveExperiment(Job hiveExperimentDto);
    104 
    105     [OperationContract]
    106     void UpdateHiveExperiment(Job hiveExperimentDto);
    107 
    108     [OperationContract]
    109     void DeleteHiveExperiment(Guid hiveExperimentId);
    110     #endregion
    111 
    112     #region HiveExperimentPermission Methods
    113     [OperationContract]
    114     void GrantPermission(Guid hiveExperimentId, Guid grantedUserId, Permission permission);
     100    IEnumerable<Job> GetAllJobs();
     101
     102    [OperationContract]
     103    Guid AddJob(Job jobDto);
     104
     105    [OperationContract]
     106    void UpdateJob(Job jobDto);
     107
     108    [OperationContract]
     109    void DeleteJob(Guid JobId);
     110    #endregion
     111
     112    #region JobPermission Methods
     113    [OperationContract]
     114    void GrantPermission(Guid jobId, Guid grantedUserId, Permission permission);
    115115
    116116    [OperationContract]
     
    118118
    119119    [OperationContract]
    120     IEnumerable<JobPermission> GetHiveExperimentPermissions(Guid hiveExperimentId);
    121 
    122     [OperationContract]
    123     bool IsAllowedPrivileged(); // current user may execute privileged jobs
     120    IEnumerable<JobPermission> GetJobPermissions(Guid jobId);
     121
     122    [OperationContract]
     123    bool IsAllowedPrivileged(); // current user may execute privileged task
    124124    #endregion
    125125
     
    140140    [OperationContract]
    141141    Plugin GetPlugin(Guid pluginId);
     142
    142143    [OperationContract]
    143144    Plugin GetPluginByHash(byte[] hash);
     145
    144146    [OperationContract]
    145147    [FaultContract(typeof(PluginAlreadyExistsFault))]
    146148    Guid AddPlugin(Plugin plugin, List<PluginData> pluginData);
     149
    147150    [OperationContract]
    148151    IEnumerable<Plugin> GetPlugins();
     152
    149153    [OperationContract]
    150154    IEnumerable<PluginData> GetPluginDatas(List<Guid> pluginIds);
     155
    151156    [OperationContract]
    152157    void DeletePlugin(Guid pluginId);
     
    194199
    195200    [OperationContract]
    196     IEnumerable<Task> GetJobsByResourceId(Guid resourceId);
     201    IEnumerable<Task> GetTasksByResourceId(Guid resourceId);
    197202
    198203    [OperationContract]
Note: See TracChangeset for help on using the changeset viewer.