Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5458


Ignore:
Timestamp:
02/14/11 18:23:37 (13 years ago)
Author:
cneumuel
Message:

#1233

  • removed GetConfigurationFile from service -> configuration is now submitted as a plugin with one file (the configuration file)
  • resource ids are now checked before uploading a hive experiment, only valid resource names are accepted
  • added SharpZipLib License to ConsoleClient project, so dependecies are satisfied
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4/HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4.csproj

    r5375 r5458  
    8282    </None>
    8383  </ItemGroup>
     84  <ItemGroup>
     85    <Content Include="ICSharpCode.SharpZipLib License.txt">
     86      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     87    </Content>
     88  </ItemGroup>
    8489  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    8590  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Tests/Mocks/MockHiveService.cs

    r5405 r5458  
    231231    }
    232232
     233    public Guid GetResourceId(string resourceName) {
     234      // todo
     235      return Guid.Empty;
     236    }
     237
    233238    #endregion
    234239
     
    324329    }
    325330    #endregion
     331
    326332  }
    327333}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs

    r5451 r5458  
    402402      String pluginDir = Path.Combine(PluginCache.Instance.PluginTempBaseDir, myJob.Id.ToString());
    403403      bool pluginsPrepared = false;
     404      string configFileName = string.Empty;
    404405
    405406      try {
    406         PluginCache.Instance.PreparePlugins(myJob, jobData);
     407        PluginCache.Instance.PreparePlugins(myJob, out configFileName);
    407408        ClientCom.LogMessage("Plugins fetched for job " + myJob.Id);
    408409        pluginsPrepared = true;
     
    414415      if (pluginsPrepared) {
    415416        try {
    416           AppDomain appDomain = HeuristicLab.PluginInfrastructure.Sandboxing.SandboxManager.CreateAndInitSandbox(myJob.Id.ToString(), pluginDir, Path.Combine(pluginDir, PluginCache.ConfigFileName));
     417          AppDomain appDomain = HeuristicLab.PluginInfrastructure.Sandboxing.SandboxManager.CreateAndInitSandbox(myJob.Id.ToString(), pluginDir, Path.Combine(pluginDir, configFileName));
    417418          appDomain.UnhandledException += new UnhandledExceptionEventHandler(appDomain_UnhandledException);
    418419          lock (engines) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/PluginCache.cs

    r5451 r5458  
    3434  public class PluginCache {
    3535    private static object locker = new object();
    36     public const string ConfigFileName = "Sandbox.config";
    3736    private const string lastUsedFileName = "lastUsed.dat";
    3837
     
    5251          instance = new PluginCache();
    5352        return instance;
    54       }
    55     }
    56 
    57     public string ConfigFilePath {
    58       get {
    59         return Path.Combine(PluginCacheDir, ConfigFileName);
    6053      }
    6154    }
     
    8376
    8477      foreach (string dir in Directory.EnumerateDirectories(PluginCacheDir)) {
    85         cachedPluginsGuids.Add(Guid.Parse(getFilenameFromPath(dir)));
     78        cachedPluginsGuids.Add(Guid.Parse(getFilenameFromPath(dir))); // Todo: cleaner solution to getFilenameFromPath
    8679      }
    8780    }
    8881
    8982    [MethodImpl(MethodImplOptions.Synchronized)]
    90     public void CopyPluginsForJob(List<Plugin> requests, Guid jobId) {
     83    public void CopyPluginsForJob(List<Plugin> requests, Guid jobId, out string configFileName) {
    9184      lock (locker) {
     85        configFileName = string.Empty;
    9286        String targetDir = Path.Combine(PluginTempBaseDir, jobId.ToString());
    9387
     
    9791        Directory.CreateDirectory(targetDir);
    9892
    99 
    10093        foreach (Plugin requestedPlugin in requests) {
    101           string curPath = Path.Combine(PluginCacheDir, requestedPlugin.Id.ToString());
    102           if (Directory.Exists(curPath)) {
    103             writeDateLastUsed(curPath);
    104 
    105             foreach (string file in Directory.GetFiles(curPath)) {
    106               string fn = getFilenameFromPath(file);
    107               if (fn != lastUsedFileName)
    108                 File.Copy(file, Path.Combine(targetDir, fn));
    109             }
    110           }
    111         }
    112 
    113         // copy config file
    114         File.Copy(ConfigFilePath, Path.Combine(targetDir, ConfigFileName));
    115 
    116         // copy files from PluginInfrastructure, which are not declared
     94          var filePaths = GetPluginFilePaths(requestedPlugin.Id);
     95          foreach (string filePath in filePaths) {
     96            File.Copy(filePath, Path.Combine(targetDir, Path.GetFileName(filePath)));
     97          }
     98
     99          if (requestedPlugin.Name == "Configuration") {
     100            configFileName = Path.Combine(targetDir, Path.GetFileName(filePaths.SingleOrDefault())); // configuration plugin consists only of 1 file (usually the "HeuristicLab X.X.exe.config")
     101          }
     102        }
     103
     104        // copy files from PluginInfrastructure (which are not declared in any plugins)
    117105        string baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    118106        CopyFile(baseDir, targetDir, "HeuristicLab.PluginInfrastructure-3.3.dll");
     
    137125
    138126    [MethodImpl(MethodImplOptions.Synchronized)]
    139     internal void PreparePlugins(Job myJob, JobData jobData) {
     127    internal void PreparePlugins(Job myJob, out string configFileName) {
    140128      lock (locker) {
    141129        SlaveClientCom.Instance.ClientCom.LogMessage("Fetching plugins for job");
     
    174162        localPlugins.AddRange(missingPlugins);
    175163
    176         IEnumerable<PluginData> updateablePlugins = WcfService.Instance.GetPluginDatas(missingGuids);
    177 
    178         foreach (PluginData updateablePlugin in updateablePlugins) {
    179           string pluginDir = Path.Combine(PluginCacheDir, updateablePlugin.PluginId.ToString());
     164        IEnumerable<PluginData> pluginDatas = WcfService.Instance.GetPluginDatas(missingGuids);
     165
     166        foreach (PluginData pluginData in pluginDatas) {
     167          string pluginDir = Path.Combine(PluginCacheDir, pluginData.PluginId.ToString());
    180168
    181169          //put all files belonging to a plugin in the same directory
     
    183171            DirectoryInfo di = Directory.CreateDirectory(pluginDir);
    184172          }
    185           File.WriteAllBytes(Path.Combine(pluginDir, Path.GetFileName(updateablePlugin.FileName)), updateablePlugin.Data);
    186         }
    187 
    188         PluginData configFile = WcfService.Instance.GetConfigurationFile();
    189         File.WriteAllBytes(ConfigFilePath, configFile.Data);
     173          File.WriteAllBytes(Path.Combine(pluginDir, Path.GetFileName(pluginData.FileName)), pluginData.Data);
     174        }
    190175
    191176        DoUpdateRun();
    192         CopyPluginsForJob(requiredPlugins, myJob.Id);
     177        CopyPluginsForJob(requiredPlugins, myJob.Id, out configFileName);
     178      }
     179    }
     180
     181    /// <summary>
     182    /// Returns a list of files which belong to a plugin from the plugincache
     183    /// </summary>
     184    private IEnumerable<string> GetPluginFilePaths(Guid pluginId) {
     185      string pluginPath = Path.Combine(PluginCacheDir, pluginId.ToString());
     186
     187      if (Directory.Exists(pluginPath)) {
     188        WriteDateLastUsed(pluginPath);
     189        foreach (string filePath in Directory.GetFiles(pluginPath)) {
     190          string fn = Path.GetFileName(filePath);
     191          if (fn != lastUsedFileName)
     192            yield return filePath;
     193        }
    193194      }
    194195    }
     
    198199    /// this can later be used to find plugins which are outdated
    199200    /// </summary>   
    200     private void writeDateLastUsed(string path) {
     201    private void WriteDateLastUsed(string path) {
    201202      FileStream fs = new FileStream(Path.Combine(path, lastUsedFileName), FileMode.Create);
    202203      BinaryFormatter formatter = new BinaryFormatter();
     
    218219    /// </summary>
    219220    /// <param name="path"></param>
    220     private void cleanPluginCache() {
     221    private void CleanPluginCache() {
    221222      FileStream fs = null;
    222223      DateTime luDate;
     
    274275        SlaveClientCom.Instance.ClientCom.LogMessage("failed while unloading " + id + " with exception " + ex);
    275276      }
    276       cleanPluginCache();
     277      CleanPluginCache();
    277278    }
    278279  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/WcfService.cs

    r5405 r5458  
    238238    }
    239239
    240     public PluginData GetConfigurationFile() {
    241       using (Disposable<IHiveService> service = GetSlaveService()) {
    242         try {
    243           PluginData msg = service.Obj.GetConfigurationFile();
    244           return msg;
    245         }
    246         catch (Exception ex) {
    247           HandleNetworkError(ex);
    248           return null;
    249         }
    250       }
    251     }
    252 
    253240    private static Disposable<IHiveService> GetSlaveService() {
    254241      return ServiceLocator.Instance.GetService("hiveslave", "hiveslave");
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/HiveExperimentView.Designer.cs

    r5402 r5458  
    6363      this.pauseButton = new System.Windows.Forms.Button();
    6464      this.resourceIdsLabel = new System.Windows.Forms.Label();
    65       this.resourceIdsTextBox = new System.Windows.Forms.TextBox();
     65      this.resourceNamesTextBox = new System.Windows.Forms.TextBox();
    6666      this.disconnectButton = new System.Windows.Forms.Button();
    6767      this.reconnectButton = new System.Windows.Forms.Button();
     
    289289      // resourceIdsTextBox
    290290      //
    291       this.resourceIdsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    292                   | System.Windows.Forms.AnchorStyles.Right)));
    293       this.resourceIdsTextBox.Location = new System.Drawing.Point(72, 52);
    294       this.resourceIdsTextBox.Name = "resourceIdsTextBox";
    295       this.resourceIdsTextBox.Size = new System.Drawing.Size(559, 20);
    296       this.resourceIdsTextBox.TabIndex = 14;
    297       this.resourceIdsTextBox.Validated += new System.EventHandler(this.resourceIdsTextBox_Validated);
     291      this.resourceNamesTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     292                  | System.Windows.Forms.AnchorStyles.Right)));
     293      this.resourceNamesTextBox.Location = new System.Drawing.Point(72, 52);
     294      this.resourceNamesTextBox.Name = "resourceIdsTextBox";
     295      this.resourceNamesTextBox.Size = new System.Drawing.Size(559, 20);
     296      this.resourceNamesTextBox.TabIndex = 14;
     297      this.resourceNamesTextBox.Validated += new System.EventHandler(this.resourceNamesTextBox_Validated);
    298298      //
    299299      // disconnectButton
     
    364364      this.Controls.Add(this.disconnectButton);
    365365      this.Controls.Add(this.startButton);
    366       this.Controls.Add(this.resourceIdsTextBox);
     366      this.Controls.Add(this.resourceNamesTextBox);
    367367      this.Controls.Add(this.executionTimeTextBox);
    368368      this.Controls.Add(this.resourceIdsLabel);
     
    385385      this.Controls.SetChildIndex(this.resourceIdsLabel, 0);
    386386      this.Controls.SetChildIndex(this.executionTimeTextBox, 0);
    387       this.Controls.SetChildIndex(this.resourceIdsTextBox, 0);
     387      this.Controls.SetChildIndex(this.resourceNamesTextBox, 0);
    388388      this.Controls.SetChildIndex(this.startButton, 0);
    389389      this.Controls.SetChildIndex(this.disconnectButton, 0);
     
    413413    private System.Windows.Forms.Button pauseButton;
    414414    private System.Windows.Forms.Label resourceIdsLabel;
    415     private System.Windows.Forms.TextBox resourceIdsTextBox;
     415    private System.Windows.Forms.TextBox resourceNamesTextBox;
    416416    private System.Windows.Forms.Button viewExperimentButton;
    417417    private Core.Views.NamedItemView experimentNamedItemView;
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/HiveExperimentView.cs

    r5402 r5458  
    8383      if (Content == null) {
    8484        executionTimeTextBox.Text = string.Empty;
    85         resourceIdsTextBox.Text = string.Empty;
     85        resourceNamesTextBox.Text = string.Empty;
    8686        useLocalPluginsCheckBox.Checked = false;
    8787        logView.Content = null;
    8888      } else {
    8989        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    90         resourceIdsTextBox.Text = Content.ResourceIds;
     90        resourceNamesTextBox.Text = Content.ResourceNames;
    9191        useLocalPluginsCheckBox.Checked = Content.UseLocalPlugins;
    9292        logView.Content = Content.Log;
     
    104104        this.nameTextBox.ReadOnly = Content.ExecutionState != ExecutionState.Prepared;
    105105        this.descriptionTextBox.ReadOnly = Content.ExecutionState != ExecutionState.Prepared;
    106         this.resourceIdsTextBox.ReadOnly = Content.ExecutionState != ExecutionState.Prepared;
     106        this.resourceNamesTextBox.ReadOnly = Content.ExecutionState != ExecutionState.Prepared;
    107107        this.hiveJobView.ReadOnly = Content.ExecutionState != ExecutionState.Prepared;
    108108        this.useLocalPluginsCheckBox.Enabled = Content.ExecutionState == ExecutionState.Prepared;
     
    214214    }
    215215
    216     private void resourceIdsTextBox_Validated(object sender, EventArgs e) {
    217       Content.ResourceIds = resourceIdsTextBox.Text;
     216    private void resourceNamesTextBox_Validated(object sender, EventArgs e) {
     217      Content.ResourceNames = resourceNamesTextBox.Text;
    218218    }
    219219
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/HiveExperimentClient.cs

    r5404 r5458  
    3838  using HeuristicLab.PluginInfrastructure;
    3939  using System.IO;
     40  using System.Configuration;
     41  using System.Reflection;
     42  using HeuristicLab.PluginInfrastructure.Manager;
    4043
    4144  /// <summary>
     
    7679    }
    7780
    78     private string resourceIds;
    79     public string ResourceIds {
    80       get { return resourceIds; }
     81    private string resourceNames;
     82    public string ResourceNames {
     83      get { return resourceNames; }
    8184      set {
    82         if (resourceIds != value) {
    83           resourceIds = value;
    84           OnResourceIdsChanged();
     85        if (resourceNames != value) {
     86          resourceNames = value;
     87          OnResourceNamesChanged();
    8588        }
    8689      }
     
    117120    public IEnumerable<Plugin> OnlinePlugins {
    118121      get { return onlinePlugins; }
    119       set { onlinePlugins = value; } 
     122      set { onlinePlugins = value; }
    120123    }
    121124
     
    131134      set { useLocalPlugins = value; }
    132135    }
    133    
    134     public HiveExperimentClient() : base(itemName, itemDescription) {
    135       // TODO //this.ResourceIds = HeuristicLab.Hive.Experiment.Properties.Settings.Default.ResourceIds;
    136       this.ResourceIds = "HEAL";
     136
     137    public HiveExperimentClient()
     138      : base(itemName, itemDescription) {
     139      this.ResourceNames = "HEAL";
    137140      this.log = new Log();
    138141      InitTimer();
    139142    }
    140     public HiveExperimentClient(DT.HiveExperiment hiveExperimentDto) : this() {
     143    public HiveExperimentClient(DT.HiveExperiment hiveExperimentDto)
     144      : this() {
    141145      UpdateFromDto(hiveExperimentDto);
    142146    }
    143147    protected HiveExperimentClient(HiveExperimentClient original, Cloner cloner)
    144148      : base(original, cloner) {
    145       this.ResourceIds = original.resourceIds;
     149      this.ResourceNames = original.resourceNames;
    146150      this.ExecutionState = original.executionState;
    147151      this.ExecutionTime = original.executionTime;
     
    158162      this.Name = hiveExperimentDto.Name;
    159163      this.Description = hiveExperimentDto.Description;
    160       // TODO: this.ResourceIds = hiveExperimentDto.ResourceIds;
     164      this.ResourceNames = hiveExperimentDto.ResourceNames;
    161165      this.rootJobId = hiveExperimentDto.RootJobId;
    162166    }
     
    167171        Name = this.Name,
    168172        Description = this.Description,
    169         //ResourceIds = this.ResourceIds,
     173        ResourceNames = this.ResourceNames,
    170174        RootJobId = this.rootJobId
    171175      };
     
    227231
    228232    public void Prepare() {
    229       // do nothing
     233      this.timer.Stop();
     234      this.ExecutionState = Core.ExecutionState.Prepared;
     235      this.ExecutionTime = TimeSpan.Zero;
    230236    }
    231237
    232238    public void Start() {
    233239      OnStarted();
    234       ExecutionTime = new TimeSpan();
     240      ExecutionTime = TimeSpan.Zero;
    235241      lastUpdateTime = DateTime.Now;
    236242      this.ExecutionState = Core.ExecutionState.Started;
     
    246252        IsProgressing = true;
    247253        using (Disposable<IHiveService> service = ServiceLocator.Instance.GetService()) {
    248           IEnumerable<string> groups = ToResourceIdList(this.ResourceIds);
     254          IEnumerable<string> resourceNames = ToResourceNameList(this.ResourceNames);
     255          var resourceIds = new List<Guid>();
     256          foreach (var resourceName in resourceNames) {
     257            Guid resourceId = service.Obj.GetResourceId(resourceName);
     258            if (resourceId == Guid.Empty) {
     259              throw new ResourceNotFoundException(string.Format("Could not find the resource '{0}'", resourceName));
     260            }
     261            resourceIds.Add(resourceId);
     262          }
     263
    249264          this.HiveJob.SetIndexInParentOptimizerList(null);
    250265
     
    255270          this.OnlinePlugins = service.Obj.GetPlugins();
    256271          this.AlreadyUploadedPlugins = new List<Plugin>();
     272          Plugin configFilePlugin = UploadConfigurationFile(service.Obj);
     273          this.alreadyUploadedPlugins.Add(configFilePlugin);
    257274
    258275          this.progress.Status = "Uploading jobs...";
    259           UploadJobWithChildren(service.Obj, this.HiveJob, null, groups, ref jobCount, totalJobCount);
     276          UploadJobWithChildren(service.Obj, this.HiveJob, null, resourceIds, ref jobCount, totalJobCount, configFilePlugin.Id);
    260277          this.rootJobId = this.HiveJob.Job.Id;
    261278          LogMessage("Finished sending jobs to hive");
     
    272289      catch (Exception e) {
    273290        OnExceptionOccured(e);
     291        this.Prepare();
    274292      }
    275293      finally {
    276294        IsProgressing = false;
    277295      }
     296    }
     297
     298    /// <summary>
     299    /// Uploads the local configuration file as plugin
     300    /// </summary>
     301    private static Plugin UploadConfigurationFile(IHiveService service) {
     302      string exeFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "HeuristicLab 3.3.exe");
     303      string configFileName = ConfigurationManager.OpenExeConfiguration(exeFilePath).FilePath;
     304
     305      Plugin configPlugin = new Plugin() {
     306        Name = "Configuration",
     307        IsLocal = true,
     308        Version = new Version()
     309      };
     310      PluginData configFile = new PluginData() {
     311        FileName = configFileName,
     312        Data = File.ReadAllBytes(configFileName)
     313      };
     314      configPlugin.Id = service.AddPlugin(configPlugin, new List<PluginData> { configFile });
     315      return configPlugin;
    278316    }
    279317
     
    286324    /// <param name="parentHiveJob">shall be null if its the root job</param>
    287325    /// <param name="groups"></param>
    288     private void UploadJobWithChildren(IHiveService service, HiveJob hiveJob, HiveJob parentHiveJob, IEnumerable<string> groups, ref int jobCount, int totalJobCount) {
     326    private void UploadJobWithChildren(IHiveService service, HiveJob hiveJob, HiveJob parentHiveJob, IEnumerable<Guid> groups, ref int jobCount, int totalJobCount, Guid configPluginId) {
    289327      jobCount++;
    290328      this.progress.Status = string.Format("Serializing job {0} of {1}", jobCount, totalJobCount);
     
    301339
    302340      hiveJob.Job.PluginsNeededIds = GetPluginDependencies(service, onlinePlugins, alreadyUploadedPlugins, plugins, useLocalPlugins);
     341      hiveJob.Job.PluginsNeededIds.Add(configPluginId);
    303342
    304343      this.progress.Status = string.Format("Uploading job {0} of {1} ({2} kb)", jobCount, totalJobCount, jobData.Data.Count() / 1024);
     
    306345
    307346      if (parentHiveJob != null) {
    308         //response = service.AddChildJob(parentHiveJob.Job.Id, serializedJob);
    309347        hiveJob.Job.Id = service.AddChildJob(parentHiveJob.Job.Id, hiveJob.Job, jobData);
    310348      } else {
    311         // response = service.AddJobWithGroupStrings(serializedJob, groups);
    312         hiveJob.Job.Id = service.AddJob(hiveJob.Job, jobData, null); // todo: use ResourceIds
     349        hiveJob.Job.Id = service.AddJob(hiveJob.Job, jobData, groups);
    313350      }
    314351
     
    316353
    317354      foreach (HiveJob child in hiveJob.ChildHiveJobs) {
    318         UploadJobWithChildren(service, child, hiveJob, groups, ref jobCount, totalJobCount);
    319       }
    320     }
    321    
     355        UploadJobWithChildren(service, child, hiveJob, groups, ref jobCount, totalJobCount, configPluginId);
     356      }
     357    }
     358
    322359    /// <summary>
    323360    /// Converts a string which can contain Ids separated by ';' to a enumerable
    324361    /// </summary>
    325     private IEnumerable<string> ToResourceIdList(string resourceGroups) {
     362    private IEnumerable<string> ToResourceNameList(string resourceGroups) {
    326363      if (!string.IsNullOrEmpty(resourceGroups)) {
    327         return resourceIds.Split(';');
     364        return resourceNames.Split(';');
    328365      } else {
    329366        return new List<string>();
     
    395432    }
    396433
    397     public event EventHandler ResourceIdsChanged;
    398     protected virtual void OnResourceIdsChanged() {
    399       EventHandler handler = ResourceIdsChanged;
     434    public event EventHandler ResourceNamesChanged;
     435    protected virtual void OnResourceNamesChanged() {
     436      EventHandler handler = ResourceNamesChanged;
    400437      if (handler != null) handler(this, EventArgs.Empty);
    401438    }
     
    649686      }
    650687    }
    651     #endregion 
     688    #endregion
    652689
    653690    #region Plugin Management
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HeuristicLab.Clients.Hive-3.4.csproj

    r5457 r5458  
    102102    </Reference>
    103103    <Reference Include="System" />
     104    <Reference Include="System.Configuration" />
    104105    <Reference Include="System.Core" />
    105106    <Reference Include="System.Drawing" />
     
    118119    <Compile Include="Exceptions\OptimizerNotFoundException.cs" />
    119120    <Compile Include="ExperimentManager\PluginClient.cs" />
     121    <Compile Include="Exceptions\ResourceNotFoundException.cs" />
    120122    <Compile Include="IServiceLocator.cs" />
    121123    <Compile Include="Jobs\OptimizerJob.cs" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/DataTransfer/HiveExperiment.cs

    r5106 r5458  
    3434    [DataMember]
    3535    public DateTime DateCreated { get; set; }
     36    [DataMember]
     37    public string ResourceNames { get; set; }
    3638
    3739    public HiveExperiment() { }
     
    4042      this.UserId = original.UserId;
    4143      this.DateCreated = original.DateCreated;
     44      this.ResourceNames = original.ResourceNames;
    4245    }
    4346    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/ServiceContracts/IHiveService.cs

    r5405 r5458  
    4040    [OperationContract]
    4141    void DeleteChildJobs(Guid parentJobId);
    42 
    43     [OperationContract]
    44     PluginData GetConfigurationFile();
    4542
    4643    #endregion
     
    133130    void RemoveResourceFromGroup(Guid slaveGroupId, Guid resourceId);
    134131
     132    [OperationContract]
     133    Guid GetResourceId(string resourceName);
     134
    135135    #endregion
    136136
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Convert.cs

    r5405 r5458  
    9494    public static DT.HiveExperiment ToDto(HiveExperiment source) {
    9595      if (source == null) return null;
    96       return new DT.HiveExperiment { Id = source.HiveExperimentId, Description = source.Description, Name = source.Name, RootJobId = source.RootJobId, UserId = source.UserId, DateCreated = source.DateCreated };
     96      return new DT.HiveExperiment { Id = source.HiveExperimentId, Description = source.Description, Name = source.Name, RootJobId = source.RootJobId, UserId = source.UserId, DateCreated = source.DateCreated, ResourceNames = source.ResourceIds };
    9797    }
    9898    public static HiveExperiment ToEntity(DT.HiveExperiment source) {
     
    103103    public static void ToEntity(DT.HiveExperiment source, HiveExperiment target) {
    104104      if ((source != null) && (target != null)) {
    105         target.HiveExperimentId = source.Id; target.Description = source.Description; target.Name = source.Name; target.RootJobId = source.RootJobId; target.UserId = source.UserId; target.DateCreated = source.DateCreated;
     105        target.HiveExperimentId = source.Id; target.Description = source.Description; target.Name = source.Name; target.RootJobId = source.RootJobId; target.UserId = source.UserId; target.DateCreated = source.DateCreated; target.ResourceIds = source.ResourceNames;
    106106      }
    107107    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs

    r5405 r5458  
    103103      }
    104104    }
    105    
    106     public PluginData GetConfigurationFile() {
    107       using (trans.OpenTransaction()) {
    108         //TODO: move filename to app.config
    109         PluginData configFile = dao.GetPluginDatas(x => x.FileName == "HeuristicLab 3.3.exe.config").SingleOrDefault();
    110         if (configFile == null) {
    111           //TODO: error handling
    112           return null;
    113         } else {
    114           return configFile;
    115         }
    116       }
    117     }
    118105
    119106    #endregion
     
    300287    }
    301288
     289    public Guid GetResourceId(string resourceName) {
     290      using (trans.OpenTransaction()) {
     291        var resource = dao.GetResources(x => x.Name == resourceName).FirstOrDefault();
     292        if (resource != null) {
     293          return resource.Id;
     294        } else {
     295          return Guid.Empty;
     296        }
     297      }
     298    }
    302299    #endregion
    303300
     
    322319    #endregion
    323320
     321
    324322  }
    325323}
Note: See TracChangeset for help on using the changeset viewer.