Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5469 for branches


Ignore:
Timestamp:
02/15/11 15:16:10 (14 years ago)
Author:
ascheibe
Message:

#1233 don't kill appdomain before it is finished starting

Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Calendar/3.3/HeuristicLabCalendarPlugin.cs

    r5457 r5469  
    2424
    2525namespace HeuristicLab.Calendar {
    26   [Plugin("HeuristicLab.Calendar", "3.3.3.0")]
     26  [Plugin("HeuristicLab.Calendar", "3.3.3.5457")]
    2727  [PluginFile("HeuristicLab.Calendar-3.3.dll", PluginFileType.Assembly)]
    2828  [PluginFile("DayView License.txt", PluginFileType.License)]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Calendar/3.3/Properties/AssemblyInfo.cs

    r5457 r5469  
    5656// by using the '*' as shown below:
    5757[assembly: AssemblyVersion("3.3.0.0")]
    58 [assembly: AssemblyFileVersion("3.3.0.0")]
     58[assembly: AssemblyFileVersion("3.3.0.5457")]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs

    r5458 r5469  
    357357    /// <param name="jobId"></param>
    358358    [MethodImpl(MethodImplOptions.Synchronized)]
    359     public void SendFinishedJob(object jobId) {
     359    public void SendFinishedJob(Guid jobId) {
    360360      try {
    361         Guid jId = (Guid)jobId;
    362         ClientCom.LogMessage("Getting the finished job with id: " + jId);
    363         if (!engines.ContainsKey(jId)) {
     361        ClientCom.LogMessage("Getting the finished job with id: " + jobId);
     362        if (!engines.ContainsKey(jobId)) {
    364363          ClientCom.LogMessage("Engine doesn't exist");
    365364          return;
    366365        }
    367         if (!jobs.ContainsKey(jId)) {
     366        if (!jobs.ContainsKey(jobId)) {
    368367          ClientCom.LogMessage("Job doesn't exist");
    369368          return;
    370369        }
    371         Job cJob = jobs[jId];
    372 
    373         JobData sJob = engines[jId].GetFinishedJob();
    374         cJob.Exception = engines[jId].CurrentException;
    375         cJob.ExecutionTime = engines[jId].ExecutionTime;
     370        Job cJob = jobs[jobId];
     371        cJob.JobState = JobState.Finished;//TODO: what if failed?
     372        cJob.ExecutionTime = engines[jobId].ExecutionTime;
     373
     374        JobData sJob = engines[jobId].GetFinishedJob();
     375        cJob.Exception = engines[jobId].CurrentException;
     376        cJob.ExecutionTime = engines[jobId].ExecutionTime;
    376377
    377378        try {
    378           ClientCom.LogMessage("Sending the finished job with id: " + jId);
     379          ClientCom.LogMessage("Sending the finished job with id: " + jobId);
    379380          wcfService.UpdateJob(cJob, sJob);
    380381          SlaveStatusInfo.JobsProcessed++;
    381382        }
    382383        catch (Exception e) {
    383           ClientCom.LogMessage("Transmitting to server failed. Storing the finished job with id: " + jId + " to hdd (" + e.ToString() + ")");
     384          ClientCom.LogMessage("Transmitting to server failed. Storing the finished job with id: " + jobId + " to hdd (" + e.ToString() + ")");
    384385        }
    385386        finally {
    386           KillAppDomain(jId); // kill app-domain in every case
     387          KillAppDomain(jobId); // kill app-domain in every case
    387388          heartbeatManager.AwakeHeartBeatThread();
    388389        }
     
    464465    /// <param name="parameter"></param>
    465466    /// <returns>true if the calling method can continue execution, else false</returns>
    466     private bool EnqueueExecutorMessage<T>(Action<T> action, T parameter) {
     467    public void EnqueueExecutorMessage<T>(Action<T> action, T parameter) {
     468      ExecutorMessageContainer<T> container = new ExecutorMessageContainer<T>();
     469      container.Callback = action;
     470      container.CallbackParameter = parameter;
     471      MessageQueue.GetInstance().AddMessage(container);
     472    }
     473
     474    /// <summary>
     475    /// Kill a appdomain with a specific id.
     476    /// </summary>
     477    /// <param name="id">the GUID of the job</param>
     478    //[MethodImpl(MethodImplOptions.Synchronized)]
     479    public void KillAppDomain(Guid id) {
    467480      if (Thread.CurrentThread.ManagedThreadId != this.coreThreadId) {
    468         ExecutorMessageContainer<T> container = new ExecutorMessageContainer<T>();
    469         container.Callback = action;
    470         container.CallbackParameter = parameter;
    471         MessageQueue.GetInstance().AddMessage(container);
    472         return false;
    473       } else {
    474         return true;
    475       }
    476     }
    477 
    478     /// <summary>
    479     /// Kill a appdomain with a specific id.
    480     /// </summary>
    481     /// <param name="id">the GUID of the job</param>
    482     [MethodImpl(MethodImplOptions.Synchronized)]
    483     public void KillAppDomain(Guid id) {
    484       if (EnqueueExecutorMessage<Guid>(KillAppDomain, id)) {
    485         ClientCom.LogMessage("Shutting down Appdomain for Job " + id);
    486         lock (engines) {
    487           try {
    488             if (engines.ContainsKey(id)) {
    489               engines[id].Dispose();
    490               engines.Remove(id);
    491             }
    492 
    493             if (appDomains.ContainsKey(id)) {
    494               appDomains[id].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException);
    495 
    496               int repeat = 5;
    497               while (repeat > 0) {
    498                 try {
    499                   AppDomain.Unload(appDomains[id]);
    500                   repeat = 0;
    501                 }
    502                 catch (CannotUnloadAppDomainException) {
    503                   ClientCom.LogMessage("Could not unload AppDomain, will try again in 1 sec.");
    504                   Thread.Sleep(1000);
    505                   repeat--;
    506                   if (repeat == 0) {
    507                     throw; // rethrow and let app crash
    508                   }
     481        EnqueueExecutorMessage<Guid>(KillAppDomain, id);
     482        return;
     483      }
     484
     485      ClientCom.LogMessage("Shutting down Appdomain for Job " + id);
     486      lock (engines) {
     487        try {
     488          if (engines.ContainsKey(id)) {
     489            engines[id].Dispose();
     490            engines.Remove(id);
     491          }
     492
     493          if (appDomains.ContainsKey(id)) {
     494            appDomains[id].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException);
     495
     496            int repeat = 5;
     497            while (repeat > 0) {
     498              try {
     499                AppDomain.Unload(appDomains[id]);
     500                repeat = 0;
     501              }
     502              catch (CannotUnloadAppDomainException) {
     503                ClientCom.LogMessage("Could not unload AppDomain, will try again in 1 sec.");
     504                Thread.Sleep(1000);
     505                repeat--;
     506                if (repeat == 0) {
     507                  throw; // rethrow and let app crash
    509508                }
    510509              }
    511               appDomains.Remove(id);
    512510            }
    513 
    514             jobs.Remove(id);
    515             PluginCache.Instance.DeletePluginsForJob(id);
    516             GC.Collect();
     511            appDomains.Remove(id);
    517512          }
    518           catch (Exception ex) {
    519             ClientCom.LogMessage("Exception when unloading the appdomain: " + ex.ToString());
    520           }
    521         }
    522         GC.Collect();
    523       }
     513
     514          jobs.Remove(id);
     515          PluginCache.Instance.DeletePluginsForJob(id);
     516          GC.Collect();
     517        }
     518        catch (Exception ex) {
     519          ClientCom.LogMessage("Exception when unloading the appdomain: " + ex.ToString());
     520        }
     521      }
     522      GC.Collect();
    524523    }
    525524  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Executor.cs

    r5450 r5469  
    8686    public void Pause() {
    8787      Job.Pause();
    88      
     88
    8989    }
    9090
     
    156156      HeuristicLab.Common.EventArgs<Exception> ex = (HeuristicLab.Common.EventArgs<Exception>)e;
    157157      currentException = ex.Value;
    158       Core.SendFinishedJob(JobId);
     158      Core.EnqueueExecutorMessage(Core.SendFinishedJob, JobId);
    159159    }
    160160
    161161    private void Job_JobStopped(object sender, EventArgs e) {
    162162      if (wasJobAborted) {
    163         Core.KillAppDomain(JobId);
     163        Core.EnqueueExecutorMessage(Core.KillAppDomain, JobId);
    164164      } else {
    165         Core.SendFinishedJob(JobId);
     165        Core.EnqueueExecutorMessage(Core.SendFinishedJob, JobId);
    166166      }
    167167    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/PluginCache.cs

    r5458 r5469  
    265265            tries = 0;
    266266          }
    267           catch {
     267          catch (Exception e) {
    268268            Thread.Sleep(1000);
    269269            tries--;
    270             if (tries == 0) throw;
     270            if (tries == 0) throw;// TODO: don't know what do do
    271271          }
    272272        }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/Administration/HiveAdministrationView.Designer.cs

    r5457 r5469  
    4747      this.tabAdmin = new System.Windows.Forms.TabControl();
    4848      this.tabSlaves = new System.Windows.Forms.TabPage();
    49       this.tabUsers = new System.Windows.Forms.TabPage();
     49      this.splitSlaves = new System.Windows.Forms.SplitContainer();
    5050      this.treeSlaveGroup = new System.Windows.Forms.TreeView();
    5151      this.tabSlaveGroup = new System.Windows.Forms.TabControl();
     
    5353      this.tabSchedule = new System.Windows.Forms.TabPage();
    5454      this.tabJobs = new System.Windows.Forms.TabPage();
    55       this.splitSlaves = new System.Windows.Forms.SplitContainer();
     55      this.tabUsers = new System.Windows.Forms.TabPage();
     56      this.splitUsers = new System.Windows.Forms.SplitContainer();
     57      this.lstUsers = new System.Windows.Forms.ListView();
     58      this.grpUsersInfo = new System.Windows.Forms.GroupBox();
    5659      this.scheduleControl1 = new HeuristicLab.Clients.Hive.Views.Administration.ScheduleControl();
     60      this.hiveJobListViewSlaves = new HeuristicLab.Clients.Hive.Views.HiveJobListView();
    5761      this.tabAdmin.SuspendLayout();
    5862      this.tabSlaves.SuspendLayout();
    59       this.tabSlaveGroup.SuspendLayout();
    60       this.tabSchedule.SuspendLayout();
    6163      ((System.ComponentModel.ISupportInitialize)(this.splitSlaves)).BeginInit();
    6264      this.splitSlaves.Panel1.SuspendLayout();
    6365      this.splitSlaves.Panel2.SuspendLayout();
    6466      this.splitSlaves.SuspendLayout();
     67      this.tabSlaveGroup.SuspendLayout();
     68      this.tabSchedule.SuspendLayout();
     69      this.tabJobs.SuspendLayout();
     70      this.tabUsers.SuspendLayout();
     71      ((System.ComponentModel.ISupportInitialize)(this.splitUsers)).BeginInit();
     72      this.splitUsers.Panel1.SuspendLayout();
     73      this.splitUsers.Panel2.SuspendLayout();
     74      this.splitUsers.SuspendLayout();
    6575      this.SuspendLayout();
    6676      //
     
    8999      this.tabSlaves.UseVisualStyleBackColor = true;
    90100      //
    91       // tabUsers
    92       //
    93       this.tabUsers.Location = new System.Drawing.Point(4, 22);
    94       this.tabUsers.Name = "tabUsers";
    95       this.tabUsers.Padding = new System.Windows.Forms.Padding(3);
    96       this.tabUsers.Size = new System.Drawing.Size(734, 520);
    97       this.tabUsers.TabIndex = 1;
    98       this.tabUsers.Text = "Users";
    99       this.tabUsers.UseVisualStyleBackColor = true;
     101      // splitSlaves
     102      //
     103      this.splitSlaves.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     104                  | System.Windows.Forms.AnchorStyles.Left)
     105                  | System.Windows.Forms.AnchorStyles.Right)));
     106      this.splitSlaves.Location = new System.Drawing.Point(3, 6);
     107      this.splitSlaves.Name = "splitSlaves";
     108      //
     109      // splitSlaves.Panel1
     110      //
     111      this.splitSlaves.Panel1.Controls.Add(this.treeSlaveGroup);
     112      //
     113      // splitSlaves.Panel2
     114      //
     115      this.splitSlaves.Panel2.Controls.Add(this.tabSlaveGroup);
     116      this.splitSlaves.Size = new System.Drawing.Size(725, 508);
     117      this.splitSlaves.SplitterDistance = 215;
     118      this.splitSlaves.TabIndex = 2;
    100119      //
    101120      // treeSlaveGroup
     
    146165      // tabJobs
    147166      //
     167      this.tabJobs.Controls.Add(this.hiveJobListViewSlaves);
    148168      this.tabJobs.Location = new System.Drawing.Point(4, 22);
    149169      this.tabJobs.Name = "tabJobs";
     
    154174      this.tabJobs.UseVisualStyleBackColor = true;
    155175      //
    156       // splitSlaves
    157       //
    158       this.splitSlaves.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    159                   | System.Windows.Forms.AnchorStyles.Left)
    160                   | System.Windows.Forms.AnchorStyles.Right)));
    161       this.splitSlaves.Location = new System.Drawing.Point(3, 6);
    162       this.splitSlaves.Name = "splitSlaves";
    163       //
    164       // splitSlaves.Panel1
    165       //
    166       this.splitSlaves.Panel1.Controls.Add(this.treeSlaveGroup);
    167       //
    168       // splitSlaves.Panel2
    169       //
    170       this.splitSlaves.Panel2.Controls.Add(this.tabSlaveGroup);
    171       this.splitSlaves.Size = new System.Drawing.Size(725, 508);
    172       this.splitSlaves.SplitterDistance = 215;
    173       this.splitSlaves.TabIndex = 2;
     176      // tabUsers
     177      //
     178      this.tabUsers.Controls.Add(this.splitUsers);
     179      this.tabUsers.Location = new System.Drawing.Point(4, 22);
     180      this.tabUsers.Name = "tabUsers";
     181      this.tabUsers.Padding = new System.Windows.Forms.Padding(3);
     182      this.tabUsers.Size = new System.Drawing.Size(734, 520);
     183      this.tabUsers.TabIndex = 1;
     184      this.tabUsers.Text = "Users";
     185      this.tabUsers.UseVisualStyleBackColor = true;
     186      //
     187      // splitUsers
     188      //
     189      this.splitUsers.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     190                  | System.Windows.Forms.AnchorStyles.Left)
     191                  | System.Windows.Forms.AnchorStyles.Right)));
     192      this.splitUsers.Location = new System.Drawing.Point(6, 6);
     193      this.splitUsers.Name = "splitUsers";
     194      //
     195      // splitUsers.Panel1
     196      //
     197      this.splitUsers.Panel1.Controls.Add(this.lstUsers);
     198      //
     199      // splitUsers.Panel2
     200      //
     201      this.splitUsers.Panel2.Controls.Add(this.grpUsersInfo);
     202      this.splitUsers.Size = new System.Drawing.Size(722, 508);
     203      this.splitUsers.SplitterDistance = 240;
     204      this.splitUsers.TabIndex = 0;
     205      //
     206      // lstUsers
     207      //
     208      this.lstUsers.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     209                  | System.Windows.Forms.AnchorStyles.Left)
     210                  | System.Windows.Forms.AnchorStyles.Right)));
     211      this.lstUsers.Location = new System.Drawing.Point(3, 3);
     212      this.lstUsers.Name = "lstUsers";
     213      this.lstUsers.Size = new System.Drawing.Size(234, 502);
     214      this.lstUsers.TabIndex = 0;
     215      this.lstUsers.UseCompatibleStateImageBehavior = false;
     216      //
     217      // grpUsersInfo
     218      //
     219      this.grpUsersInfo.Location = new System.Drawing.Point(4, 4);
     220      this.grpUsersInfo.Name = "grpUsersInfo";
     221      this.grpUsersInfo.Size = new System.Drawing.Size(474, 504);
     222      this.grpUsersInfo.TabIndex = 0;
     223      this.grpUsersInfo.TabStop = false;
     224      this.grpUsersInfo.Text = "User Information";
    174225      //
    175226      // scheduleControl1
     
    179230      this.scheduleControl1.Size = new System.Drawing.Size(862, 562);
    180231      this.scheduleControl1.TabIndex = 0;
     232      //
     233      // hiveJobListViewSlaves
     234      //
     235      this.hiveJobListViewSlaves.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     236                  | System.Windows.Forms.AnchorStyles.Left)
     237                  | System.Windows.Forms.AnchorStyles.Right)));
     238      this.hiveJobListViewSlaves.Caption = "JobItemList View";
     239      this.hiveJobListViewSlaves.Content = null;
     240      this.hiveJobListViewSlaves.Location = new System.Drawing.Point(7, 7);
     241      this.hiveJobListViewSlaves.Name = "hiveJobListViewSlaves";
     242      this.hiveJobListViewSlaves.ReadOnly = false;
     243      this.hiveJobListViewSlaves.Size = new System.Drawing.Size(499, 463);
     244      this.hiveJobListViewSlaves.TabIndex = 0;
    181245      //
    182246      // HiveAdministrationView
     
    189253      this.tabAdmin.ResumeLayout(false);
    190254      this.tabSlaves.ResumeLayout(false);
    191       this.tabSlaveGroup.ResumeLayout(false);
    192       this.tabSchedule.ResumeLayout(false);
    193255      this.splitSlaves.Panel1.ResumeLayout(false);
    194256      this.splitSlaves.Panel2.ResumeLayout(false);
    195257      ((System.ComponentModel.ISupportInitialize)(this.splitSlaves)).EndInit();
    196258      this.splitSlaves.ResumeLayout(false);
     259      this.tabSlaveGroup.ResumeLayout(false);
     260      this.tabSchedule.ResumeLayout(false);
     261      this.tabJobs.ResumeLayout(false);
     262      this.tabUsers.ResumeLayout(false);
     263      this.splitUsers.Panel1.ResumeLayout(false);
     264      this.splitUsers.Panel2.ResumeLayout(false);
     265      ((System.ComponentModel.ISupportInitialize)(this.splitUsers)).EndInit();
     266      this.splitUsers.ResumeLayout(false);
    197267      this.ResumeLayout(false);
    198268
     
    211281    private System.Windows.Forms.SplitContainer splitSlaves;
    212282    private ScheduleControl scheduleControl1;
     283    private System.Windows.Forms.SplitContainer splitUsers;
     284    private System.Windows.Forms.ListView lstUsers;
     285    private System.Windows.Forms.GroupBox grpUsersInfo;
     286    private HiveJobListView hiveJobListViewSlaves;
    213287  }
    214288}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/Administration/MenuItems/AdministrationMenuItem.cs

    r5457 r5469  
    2727  public class AdministrationMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
    2828    public override string Name {
    29       get { return "&Hive Administration 3.4"; }
     29      get { return "& Administration"; }
    3030    }
    3131    public override IEnumerable<string> Structure {
Note: See TracChangeset for help on using the changeset viewer.