Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6107


Ignore:
Timestamp:
05/03/11 15:45:04 (13 years ago)
Author:
ascheibe
Message:

#1233

  • simplify PreparePlugins
  • send more exceptions to ExperimentManager
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.4/SlaveItem.cs

    r6004 r6107  
    7878      }
    7979      catch (Exception) {
    80         OnMessageLogged("Couldn't connect to Slave core. Is it possible that the Slave Core isn't running?" + Environment.NewLine);
     80        OnMessageLogged("Couldn't connect to Slave core. Is it possible that the core isn't running?");
    8181        return false;
    8282      }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs

    r6101 r6107  
    177177              // handle exception of task
    178178              clientCom.LogMessage(t.Exception.ToString());
     179              wcfService.UpdateJobState(container.JobId, JobState.Failed, t.Exception.ToString());
     180              SlaveStatusInfo.JobsAborted++;
    179181            }, TaskContinuationOptions.OnlyOnFaulted);
    180182            break;
     
    474476        catch (Exception exception) {
    475477          clientCom.LogMessage(string.Format("Copying plugins for job {0} failed: {1}", myJob.Id, exception));
     478          wcfService.UpdateJobState(myJob.Id, JobState.Failed, exception.ToString());
     479          SlaveStatusInfo.JobsAborted++;
     480
    476481          lock (engines) {
    477482            if (jobs.ContainsKey(myJob.Id)) {
     
    501506            clientCom.LogMessage("Creating the Appdomain and loading the job failed for job " + myJob.Id);
    502507            clientCom.LogMessage("Error thrown is: " + exception.ToString());
     508
     509            if (engines.ContainsKey(myJob.Id) && engines[myJob.Id].CurrentException != string.Empty) {
     510              wcfService.UpdateJobState(myJob.Id, JobState.Failed, engines[myJob.Id].CurrentException);
     511            } else {
     512              wcfService.UpdateJobState(myJob.Id, JobState.Failed, exception.ToString());
     513            }
     514            SlaveStatusInfo.JobsAborted++;
     515
    503516            KillAppDomain(myJob.Id);
    504517          }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/PluginCache.cs

    r6101 r6107  
    6060    }
    6161
     62    /// <summary>
     63    /// Returns the last directory of a path
     64    /// </summary>   
    6265    private string GetFilenameFromPath(string path) {
    6366      string[] dirParts = path.Split(Path.DirectorySeparatorChar);
     
    7275      SafelyCreateDirectory(PluginCacheDir);
    7376      foreach (string dir in Directory.EnumerateDirectories(PluginCacheDir)) {
    74         cachedPluginsGuids.Add(Guid.Parse(GetFilenameFromPath(dir))); // Todo: cleaner solution to getFilenameFromPath
     77        cachedPluginsGuids.Add(Guid.Parse(GetFilenameFromPath(dir)));
    7578      }
    7679    }
     
    137140    }
    138141
    139     [MethodImpl(MethodImplOptions.Synchronized)]
     142    /// <summary>
     143    /// Updates the plugin cache with missing plugins and
     144    /// then copies the required plugins for the job.
     145    /// </summary>       
    140146    internal void PreparePlugins(Job myJob, out string configFileName) {
    141147      lock (locker) {
    142         SlaveClientCom.Instance.ClientCom.LogMessage("Fetching plugins for job");
    143 
    144         List<Plugin> requiredPlugins = new List<Plugin>();
     148        SlaveClientCom.Instance.ClientCom.LogMessage("Fetching plugins for job " + myJob.Id);
     149
     150        List<Guid> missingGuids = new List<Guid>();
     151        List<Plugin> neededPlugins = new List<Plugin>();
    145152        foreach (Guid pluginId in myJob.PluginsNeededIds) {
    146           //TODO: rewrite, GetPlugin(..) should be the last thing to do after checking the local plugins
    147153          Plugin plugin = WcfService.Instance.GetPlugin(pluginId);
    148           if (plugin != null)
    149             requiredPlugins.Add(plugin);
    150         }
    151 
    152         List<Plugin> localPlugins = new List<Plugin>();
    153         List<Plugin> missingPlugins = new List<Plugin>();
    154         List<Guid> missingGuids = new List<Guid>();
    155         bool found = false;
    156 
    157         foreach (Plugin info in requiredPlugins) {
    158           foreach (Guid cachedPlugin in cachedPluginsGuids) {
    159             if (info.Id == cachedPlugin) {
    160               localPlugins.Add(new Plugin() { Id = cachedPlugin, Name = info.Name, Version = info.Version });
    161               found = true;
    162 
    163               break;
    164             }
    165           }
    166           if (!found) {
    167             SlaveClientCom.Instance.ClientCom.LogMessage("Plugin NOT found " + info.Name + ", " + info.Version);
    168             missingPlugins.Add(info);
    169             missingGuids.Add(info.Id);
    170           }
    171           found = false;
    172         }
    173 
    174         SlaveClientCom.Instance.ClientCom.LogMessage("First run - Update the plugins in the cache");
    175         localPlugins.AddRange(missingPlugins);
     154          if (plugin != null) {
     155            neededPlugins.Add(plugin);
     156          }
     157
     158          if (!cachedPluginsGuids.Contains(pluginId)) {
     159            missingGuids.Add(pluginId);
     160          }
     161        }
    176162
    177163        IEnumerable<PluginData> pluginDatas = WcfService.Instance.GetPluginDatas(missingGuids);
     
    187173
    188174          DoUpdateRun();
    189           CopyPluginsForJob(requiredPlugins, myJob.Id, out configFileName);
     175          CopyPluginsForJob(neededPlugins, myJob.Id, out configFileName);
    190176        } else {
    191177          configFileName = "";
    192178        }
     179
     180        SlaveClientCom.Instance.ClientCom.LogMessage("Fetched " + missingGuids.Count + " plugins for job " + myJob.Id);
    193181      }
    194182    }
Note: See TracChangeset for help on using the changeset viewer.