Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/30/10 13:56:28 (14 years ago)
Author:
cneumuel
Message:

Stabilization of Hive, Improvement HiveExperiment GUI (#1115)

Location:
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/HeuristicLabHiveExperimentPlugin.cs

    r4116 r4121  
    3131  [Plugin("HeuristicLab.Hive.Experiment", "3.3")]
    3232  [PluginFile("HeuristicLab.Hive.Experiment-3.3.dll", PluginFileType.Assembly)]
     33  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3334  [PluginDependency("HeuristicLab.Common", "3.3")]
     35  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
    3436  [PluginDependency("HeuristicLab.Core", "3.3")]
    3537  [PluginDependency("HeuristicLab.Core.Views", "3.3")]
     38  [PluginDependency("HeuristicLab.Data", "3.3")]
     39  [PluginDependency("HeuristicLab.DataAccess", "3.3")]
     40  [PluginDependency("HeuristicLab.Hive.Contracts", "3.3")]
     41  [PluginDependency("HeuristicLab.Hive.JobBase", "3.3")]
    3642  [PluginDependency("HeuristicLab.Optimization", "3.3")]
    3743  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    38   [PluginDependency("HeuristicLab.Hive.Contracts", "3.3")]
    39   [PluginDependency("HeuristicLab.Hive.JobBase", "3.3")]
     44  [PluginDependency("HeuristicLab.Tracing", "3.3")]
    4045  public class HeuristicLabHiveExperimentPlugin : PluginBase {
    4146
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/HiveExperiment.cs

    r4120 r4121  
    5252    private const string itemName = "Hive Experiment";
    5353    private const string itemDescription = "An experiment which contains multiple batch runs of algorithms which are executed in the Hive.";
    54     private const int resultPollingIntervalMs = 10000;
     54    private const int resultPollingIntervalMs = 15000;
    5555
    5656    private object locker = new object();
     
    128128
    129129    public override IDeepCloneable Clone(Cloner cloner) {
    130       log.LogMessage("I am beeing cloned");
     130      LogMessage("I am beeing cloned");
    131131      HiveExperiment clone = (HiveExperiment)base.Clone(cloner);
    132132      clone.resourceIds = this.resourceIds;
     
    148148    private void AfterDeserialization() {
    149149      InitTimer();
    150       log.LogMessage("I was deserialized.");
     150      LogMessage("I was deserialized.");
    151151    }
    152152
     
    224224          ResponseObject<JobDto> response = executionEngineFacade.AddJobWithGroupStrings(serializedJob, groups);
    225225          pendingOptimizers.Add(response.Obj.Id, optimizer);
    226           StartResultPollingThread(response.Obj);
    227226
    228227          JobItem jobItem = new JobItem() {
     
    236235          jobItems.Add(jobItem);
    237236
    238           log.LogMessage("Sent job to server (jobId: " + response.Obj.Id + ")");
     237          LogMessage("Sent job to server (jobId: " + response.Obj.Id + ")");
     238        }
     239
     240        // start results polling after sending sending the jobs to the server (to avoid race conflicts at the optimizers-collection)
     241        foreach (JobItem jobItem in jobItems) {
     242          StartResultPollingThread(jobItem.JobDto);
    239243        }
    240244      });
     
    256260
    257261    private void ReplaceOptimizer(IOptimizer originalOptimizer, IOptimizer newOptimizer) {
    258       int originalOptimizerIndex = experiment.Optimizers.IndexOf(originalOptimizer);
    259       experiment.Optimizers[originalOptimizerIndex] = newOptimizer;
     262      lock (locker) {
     263        int originalOptimizerIndex = experiment.Optimizers.IndexOf(originalOptimizer);
     264        experiment.Optimizers[originalOptimizerIndex] = newOptimizer;
     265      }
    260266    }
    261267
     
    308314        do {
    309315          Thread.Sleep(resultPollingIntervalMs);
    310           lock (locker) {
     316          //lock (locker) { [chn] try without locking for better performance
    311317            if (stopPending) return;
    312            
    313             ResponseObject<SerializedJob> response = executionEngineFacade.GetLastSerializedResult(job.Id, false, false);
    314             log.LogMessage("Received response for job: " + response.StatusMessage + " (jobId: " + job.Id + ")");
    315            
     318
     319            ResponseObject<JobDto> response = executionEngineFacade.GetJobById(job.Id);
     320            LogMessage("Response: " + response.StatusMessage + " (jobId: " + job.Id + ")");
     321
     322            if (response.Obj != null) {
     323              UpdateJobItem(response.Obj);
     324            }
    316325           
    317326            // loop while
     
    320329            // 3. no result for the job is available yet (response.Obj==null)
    321330            // 4. the result that we get from the server is a snapshot and not the final result
    322             if (response.Success && response.Obj != null && response.StatusMessage != ApplicationConstants.RESPONSE_JOB_RESULT_NOT_YET_HERE) {
    323               restoredObject = XmlParser.Deserialize<IJob>(new MemoryStream(response.Obj.SerializedJobData));
     331            if (response.Success && response.Obj != null && response.Obj.State == State.Finished) {
     332              ResponseObject<SerializedJob> jobResponse = executionEngineFacade.GetLastSerializedResult(job.Id, false, false);
     333              restoredObject = XmlParser.Deserialize<IJob>(new MemoryStream(jobResponse.Obj.SerializedJobData));
     334              UpdateSnapshot(jobResponse);
    324335            }
    325           }
     336          //}
    326337        } while (restoredObject == null || restoredObject.ExecutionState != Core.ExecutionState.Stopped);
    327338
    328         log.LogMessage("Job finished (jobId: " + job.Id + ")");
     339        LogMessage("Job finished (jobId: " + job.Id + ")");
    329340        // job retrieved... replace the existing optimizers with the finished one
    330341        IOptimizer originalOptimizer = pendingOptimizers[job.Id];
     
    340351        }
    341352      });
    342 
    343       Logger.Debug("HiveEngine: Starting results-polling thread");
    344353      t.Start();
     354    }
     355
     356    private void UpdateJobItem(JobDto jobDto) {
     357      JobItem jobItem = jobItems.Single(x => x.JobDto.Id == jobDto.Id);
     358      jobItem.JobDto = jobDto;
     359    }
     360
     361    private void UpdateSnapshot(ResponseObject<SerializedJob> response) {
     362      JobItem jobItem = jobItems.Single(x => x.JobDto.Id == response.Obj.JobInfo.Id);
     363      jobItem.LatestSnapshot = response;
     364    }
     365
     366    private void LogMessage(string message) {
     367      // HeuristicLab.Log is not Thread-Safe, so lock every call
     368      lock (locker) {
     369        log.LogMessage(message);
     370      }
    345371    }
    346372   
     
    440466    public event EventHandler ExecutionStateChanged;
    441467    private void OnExecutionStateChanged() {
    442       log.LogMessage("ExecutionState changed to " + executionState.ToString());
     468      LogMessage("ExecutionState changed to " + executionState.ToString());
    443469      EventHandler handler = ExecutionStateChanged;
    444470      if (handler != null) handler(this, EventArgs.Empty);
     
    449475    public event EventHandler Started;
    450476    private void OnStarted() {
    451       log.LogMessage("Started");
     477      LogMessage("Started");
    452478      timer.Start();
    453479      EventHandler handler = Started;
     
    458484    private void OnStopped() {
    459485      timer.Stop();
    460       log.LogMessage("Stopped");
     486      LogMessage("Stopped");
    461487      EventHandler handler = Stopped;
    462488      if (handler != null) handler(this, EventArgs.Empty);
     
    466492    private void OnPaused() {
    467493      timer.Stop();
    468       log.LogMessage("Paused");
     494      LogMessage("Paused");
    469495      EventHandler handler = Paused;
    470496      if (handler != null) handler(this, EventArgs.Empty);
     
    473499    public event EventHandler Prepared;
    474500    protected virtual void OnPrepared() {
    475       log.LogMessage("Prepared");
     501      LogMessage("Prepared");
    476502      EventHandler handler = Prepared;
    477503      if (handler != null) handler(this, EventArgs.Empty);
     
    486512    public event EventHandler ExperimentChanged;
    487513    protected virtual void OnExperimentChanged() {
    488       log.LogMessage("Experiment changed");
     514      LogMessage("Experiment changed");
    489515      EventHandler handler = ExperimentChanged;
    490516      if (handler != null) handler(this, EventArgs.Empty);
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/JobItem.cs

    r4120 r4121  
    77using HeuristicLab.Hive.Contracts.BusinessObjects;
    88using HeuristicLab.Hive.Contracts;
     9using System.Drawing;
    910
    1011namespace HeuristicLab.Hive.Experiment {
    1112  public class JobItem : Item {
     13    public override Image ItemImage {
     14      get {
     15        if (jobDto.State == State.Offline) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStopped;
     16        else if (jobDto.State == State.Idle) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStopped;
     17        else if (jobDto.State == State.Calculating) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStarted;
     18        else if (jobDto.State == State.Offline) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStopped;
     19        else return HeuristicLab.Common.Resources.VS2008ImageLibrary.Event;
     20      }
     21    }
     22
    1223    [Storable]
    1324    private JobDto jobDto;
     
    1728        if (jobDto != value) {
    1829          jobDto = value;
     30          OnJobDtoChanged();
    1931          OnToStringChanged();
     32          OnItemImageChanged();
    2033        }
    2134      }
     
    4154    }
    4255
     56    [Storable]
     57    private ILog log;
     58    public ILog Log {
     59      get { return log; }
     60    }
     61
    4362    public JobItem() {
     63      log = new Log();
    4464    }
    4565
     
    5777      if (handler != null) handler(this, EventArgs.Empty);
    5878    }
     79
     80    public event EventHandler JobDtoChanged;
     81    private void OnJobDtoChanged() {
     82      EventHandler handler = JobDtoChanged;
     83      if (handler != null) handler(this, EventArgs.Empty);
     84    }
    5985  }
    6086}
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/Properties/AssemblyInfo.cs

    r4120 r4121  
    5555// You can specify all the values or you can default the Revision and Build Numbers
    5656// by using the '*' as shown below:
    57 [assembly: AssemblyVersion("3.3.0.4119")]
    58 [assembly: AssemblyFileVersion("3.3.0.4119")]
    59 [assembly: AssemblyBuildDate("2010/07/29 16:49:01")]
     57[assembly: AssemblyVersion("3.3.0.4120")]
     58[assembly: AssemblyFileVersion("3.3.0.4120")]
     59[assembly: AssemblyBuildDate("2010/07/30 13:39:10")]
Note: See TracChangeset for help on using the changeset viewer.