Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/10/11 17:58:59 (13 years ago)
Author:
cneumuel
Message:

#1233

  • added semaphores to ensure an appdomain is never unloaded when the start method has not finished
  • HiveEngine uploading and downloading of jobs works and is displayed in the view
Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4
Files:
3 edited

Legend:

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

    r6175 r6178  
    4747    private Dictionary<Guid, Executor> executors = new Dictionary<Guid, Executor>();
    4848    private Dictionary<Guid, AppDomain> appDomains = new Dictionary<Guid, AppDomain>();
     49
     50    // signalizes if the Executor.Start method has properly finished. only then the appdomain may be unloaded
     51    private Dictionary<Guid, Semaphore> semaphores = new Dictionary<Guid, Semaphore>();
    4952
    5053    private WcfService wcfService;
     
    484487            executor.MemoryNeeded = job.MemoryNeeded;
    485488            clientCom.LogMessage("Starting Executor for job " + job.Id);
    486             executor.Start(jobData.Data);
    487489            lock (executors) {
    488490              executors.Add(job.Id, executor);
    489491            }
     492            semaphores[job.Id] = new Semaphore(0, 1);
     493            executor.Start(jobData.Data);
     494            semaphores[job.Id].Release();
    490495          }
    491496          catch (Exception exception) {
     
    535540    /// Kill a appdomain with a specific id.
    536541    /// </summary>
    537     /// <param name="id">the GUID of the job</param>   
    538     public void KillAppDomain(Guid id) {
     542    /// <param name="jobId">the GUID of the job</param>   
     543    public void KillAppDomain(Guid jobId) {
    539544      if (Thread.CurrentThread.ManagedThreadId != this.coreThreadId) {
    540         EnqueueExecutorMessage<Guid>(KillAppDomain, id);
     545        EnqueueExecutorMessage<Guid>(KillAppDomain, jobId);
    541546        return;
    542547      }
    543548
    544       clientCom.LogMessage("Shutting down Appdomain for Job " + id);
     549      clientCom.LogMessage("Shutting down Appdomain for Job " + jobId);
    545550      lock (executors) {
    546551        try {
    547           if (executors.ContainsKey(id)) {
    548             executors[id].Dispose();
    549             executors.Remove(id);
    550           }
    551 
    552           if (appDomains.ContainsKey(id)) {
    553             appDomains[id].UnhandledException -= new UnhandledExceptionEventHandler(AppDomain_UnhandledException);
    554 
     552          if (executors.ContainsKey(jobId)) {
     553            executors[jobId].Dispose();
     554            executors.Remove(jobId);
     555          }
     556
     557          if (appDomains.ContainsKey(jobId)) {
     558            appDomains[jobId].UnhandledException -= new UnhandledExceptionEventHandler(AppDomain_UnhandledException);
    555559            int repeat = 5;
    556560            while (repeat > 0) {
    557561              try {
    558                 AppDomain.Unload(appDomains[id]);
     562                semaphores[jobId].WaitOne();
     563                AppDomain.Unload(appDomains[jobId]);
     564                semaphores[jobId].Dispose();
     565                semaphores.Remove(jobId);
    559566                repeat = 0;
    560567              }
     
    569576              }
    570577            }
    571             appDomains.Remove(id);
    572           }
    573 
    574           PluginCache.Instance.DeletePluginsForJob(id);
     578            appDomains.Remove(jobId);
     579          }
     580
     581          PluginCache.Instance.DeletePluginsForJob(jobId);
    575582          GC.Collect();
    576583        }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Executor.cs

    r6168 r6178  
    8989        } else {
    9090          Job.Start();
    91           startJobSem.WaitOne();
     91          if (!startJobSem.WaitOne(TimeSpan.FromSeconds(15))) {
     92            throw new TimeoutException("Timeout when starting the job. JobStarted event was not fired.");
     93          }
    9294        }
    9395      }
    9496      catch (Exception e) {
    9597        this.currentException = e;
    96         Job_JobFailed(this, new HeuristicLab.Common.EventArgs<Exception>(e));
     98        Job_JobFailed(this, new EventArgs<Exception>(e));
    9799      }
    98100    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/PluginCache.cs

    r6107 r6178  
    278278    internal void DeletePluginsForJob(Guid id) {
    279279      try {
    280         SlaveClientCom.Instance.ClientCom.LogMessage("unloading...");
     280        SlaveClientCom.Instance.ClientCom.LogMessage("Deleting plugins...");
    281281        int tries = 5;
    282282        while (tries > 0) {
Note: See TracChangeset for help on using the changeset viewer.