Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/14/12 18:58:15 (12 years ago)
Author:
gkronber
Message:

#1847 merged r8205:8635 from trunk into branch

Location:
branches/GP-MoveOperators
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GP-MoveOperators

  • branches/GP-MoveOperators/HeuristicLab.Clients.Hive.Slave/3.3/Manager/PluginManager.cs

    r7259 r8660  
    2727using System.Runtime.Serialization.Formatters.Binary;
    2828using System.Threading;
    29 using HeuristicLab.Clients.Hive.SlaveCore.Properties;
    3029using HeuristicLab.Core;
     30using CoreProperties = HeuristicLab.Clients.Hive.SlaveCore.Properties;
    3131
    3232namespace HeuristicLab.Clients.Hive.SlaveCore {
    3333  public class PluginManager {
    3434    private static object locker = new object();
    35     private string lastUsedFileName = Settings.Default.LastUsedFileName;
     35    private string lastUsedFileName = CoreProperties.Settings.Default.LastUsedFileName;
    3636    //maximum number of days after which a plugin gets deleted if not used
    37     private int pluginLifetime = Settings.Default.PluginLifetime;
     37    private int pluginLifetime = CoreProperties.Settings.Default.PluginLifetime;
    3838
    3939    private string PluginCacheDir { get; set; }
     
    4646      this.pluginService = pluginService;
    4747      this.log = log;
    48       PluginCacheDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.PluginCacheDir);
    49       PluginTempBaseDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.PluginTempBaseDir);
     48      CheckWorkingDirectories();
     49      PluginCacheDir = CoreProperties.Settings.Default.PluginCacheDir;
     50      PluginTempBaseDir = CoreProperties.Settings.Default.PluginTempBaseDir;
    5051      DoUpdateRun();
     52    }
     53
     54    /// <summary>
     55    /// Normally the configuration file just contains the folder names of the PluginCache and the AppDomain working directory.
     56    /// This means that these folders are created in the current directory which is ok for the console client and the windows service.
     57    /// For the HL client we can't do that because the plugin infrastructure gets confused when starting HeuristicLab.
     58    /// Therefore if there is only a relative path in the config, we change that to the temp path.
     59    /// </summary>
     60    private void CheckWorkingDirectories() {
     61      if (!Path.IsPathRooted(CoreProperties.Settings.Default.PluginCacheDir)) {
     62        CoreProperties.Settings.Default.PluginCacheDir = Path.Combine(Path.GetTempPath(), CoreProperties.Settings.Default.PluginCacheDir);
     63        CoreProperties.Settings.Default.Save();
     64      }
     65
     66      if (!Path.IsPathRooted(CoreProperties.Settings.Default.PluginTempBaseDir)) {
     67        CoreProperties.Settings.Default.PluginTempBaseDir = Path.Combine(Path.GetTempPath(), CoreProperties.Settings.Default.PluginTempBaseDir);
     68        CoreProperties.Settings.Default.Save();
     69      }
    5170    }
    5271
     
    85104        }
    86105
    87         if (requestedPlugin.Name == Settings.Default.ConfigurationName) {
     106        if (requestedPlugin.Name == CoreProperties.Settings.Default.ConfigurationName) {
    88107          // configuration plugin consists only of 1 file (usually the "HeuristicLab X.X.exe.config")
    89108          configFileName = Path.Combine(targetDir, Path.GetFileName(filePaths.SingleOrDefault()));
     
    93112      // copy files from PluginInfrastructure (which are not declared in any plugins)
    94113      string baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    95       CopyFile(baseDir, targetDir, Settings.Default.PluginInfrastructureDll);
    96       CopyFile(baseDir, targetDir, Settings.Default.SharpZipLibDll);
    97       CopyFile(baseDir, targetDir, Settings.Default.SharpZipLibLicense);
     114      CopyFile(baseDir, targetDir, CoreProperties.Settings.Default.PluginInfrastructureDll);
     115      CopyFile(baseDir, targetDir, CoreProperties.Settings.Default.SharpZipLibDll);
     116      CopyFile(baseDir, targetDir, CoreProperties.Settings.Default.SharpZipLibLicense);
    98117
    99118      // copy slave plugins, otherwise its not possible to register the UnhandledException handler to the appdomain       
    100       CopyFile(baseDir, targetDir, Settings.Default.ClientsHiveSlaveCoreDll);
    101       CopyFile(baseDir, targetDir, Settings.Default.ClientsHiveDll);
    102       CopyFile(baseDir, targetDir, Settings.Default.HiveDll);
    103       CopyFile(baseDir, targetDir, Settings.Default.ClientsCommonDll);
     119      CopyFile(baseDir, targetDir, CoreProperties.Settings.Default.ClientsHiveSlaveCoreDll);
     120      CopyFile(baseDir, targetDir, CoreProperties.Settings.Default.ClientsHiveDll);
     121      CopyFile(baseDir, targetDir, CoreProperties.Settings.Default.HiveDll);
     122      CopyFile(baseDir, targetDir, CoreProperties.Settings.Default.ClientsCommonDll);
    104123    }
    105124
     
    109128      di.Refresh();
    110129      while (di.Exists) {
    111         Thread.Sleep(Settings.Default.DirOpSleepTime);
     130        Thread.Sleep(CoreProperties.Settings.Default.DirOpSleepTime);
    112131        di.Refresh();
    113132      }
     
    120139        di = Directory.CreateDirectory(targetDir);
    121140        while (!di.Exists) {
    122           Thread.Sleep(Settings.Default.DirOpSleepTime);
     141          Thread.Sleep(CoreProperties.Settings.Default.DirOpSleepTime);
    123142          di.Refresh();
    124143        }
     
    279298      try {
    280299        log.LogMessage("Deleting plugins...");
    281         int tries = Settings.Default.PluginDeletionRetries;
     300        int tries = CoreProperties.Settings.Default.PluginDeletionRetries;
    282301        string path = Path.Combine(PluginTempBaseDir, id.ToString());
    283302        while (tries > 0) {
     
    287306          }
    288307          catch (Exception) {
    289             Thread.Sleep(Settings.Default.PluginDeletionTimeout);
     308            Thread.Sleep(CoreProperties.Settings.Default.PluginDeletionTimeout);
    290309            tries--;
    291310            if (tries == 0) throw;
Note: See TracChangeset for help on using the changeset viewer.