Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/28/10 17:48:10 (14 years ago)
Author:
cneumuel
Message:

HiveExperiment is now able to send IOptimizers of an Experiment and receive the calculated result (#1115)

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

Legend:

Unmodified
Added
Removed
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Client.Communication/3.3/WcfService.cs

    r4107 r4119  
    262262        Logger.Debug("STARTED: Sending back the finished job results");
    263263        Logger.Debug("Building stream");
    264         Stream stream =
    265           GetStreamedJobResult(clientId, jobId, result, percentage, exception);
     264        Stream stream = GetStreamedJobResult(clientId, jobId, result, percentage, exception);
    266265        Logger.Debug("Builded stream");
    267266        Logger.Debug("Making the call");
     
    269268      }
    270269    }
     270
    271271    private void proxy_StoreFinishedJobResultStreamedCompleted(object sender, StoreFinishedJobResultStreamedCompletedEventArgs e) {
    272272      Logger.Debug("Finished storing the job");
    273       Stream stream =
    274         (Stream)e.UserState;
     273      Stream stream = (Stream)e.UserState;
    275274      if (stream != null) {
    276275        Logger.Debug("Stream not null, disposing it");
     
    278277      }
    279278      if (e.Error == null) {
    280         StoreFinishedJobResultCompletedEventArgs args =
    281           new StoreFinishedJobResultCompletedEventArgs(
    282             new object[] { e.Result }, e.Error, e.Cancelled, e.UserState);
     279        StoreFinishedJobResultCompletedEventArgs args = new StoreFinishedJobResultCompletedEventArgs(new object[] { e.Result }, e.Error, e.Cancelled, e.UserState);
    283280        Logger.Debug("calling the Finished Job Event");
    284281        StoreFinishedJobResultCompleted(sender, args);
    285282        Logger.Debug("ENDED: Sending back the finished job results");
    286       } else
     283      } else {
    287284        HandleNetworkError(e.Error);
     285      }
    288286    }
    289287
     
    300298      }
    301299    }
     300
    302301    void proxy_ProcessSnapshotStreamedCompleted(object sender, ProcessSnapshotStreamedCompletedEventArgs e) {
    303302      Stream stream =
     
    350349    /// </summary>
    351350    private Stream GetStreamedJobResult(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception) {
    352       JobResult jobResult =
    353           new JobResult();
     351      JobResult jobResult = new JobResult();
    354352      jobResult.ClientId = clientId;
    355353      jobResult.JobId = jobId;
     
    357355      jobResult.Exception = exception;
    358356
    359       MultiStream stream =
    360               new MultiStream();
     357      MultiStream stream = new MultiStream();
    361358
    362359      //first send result
    363       stream.AddStream(
    364         new StreamedObject<JobResult>(jobResult));
     360      stream.AddStream(new StreamedObject<JobResult>(jobResult));
    365361
    366362      //second stream the job binary data
    367       MemoryStream memStream =
    368         new MemoryStream(result, false);
     363      MemoryStream memStream = new MemoryStream(result, false);
    369364      stream.AddStream(memStream);
    370365
     
    373368
    374369    public ResponseResultReceived StoreFinishedJobResultsSync(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception, bool finished) {
    375       return proxy.StoreFinishedJobResultStreamed(
    376         GetStreamedJobResult(clientId, jobId, result, percentage, exception));
     370      return proxy.StoreFinishedJobResultStreamed(GetStreamedJobResult(clientId, jobId, result, percentage, exception));
    377371    }
    378372
     
    387381        return null;
    388382      }
    389 
    390383    }
    391384
    392385    public ResponseResultReceived ProcessSnapshotSync(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception) {
    393386      try {
    394         return proxy.ProcessSnapshotStreamed(
    395           GetStreamedJobResult(clientId, jobId, result, percentage, exception));
     387        return proxy.ProcessSnapshotStreamed(GetStreamedJobResult(clientId, jobId, result, percentage, exception));
    396388      } catch (Exception e) {
    397389        HandleNetworkError(e);
     
    453445      }
    454446    }
    455 
    456447  }
    457448}
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Client.Core/3.3/Core.cs

    r4107 r4119  
    4545using HeuristicLab.Hive.Client.Core.JobStorage;
    4646using HeuristicLab.Tracing;
     47using HeuristicLab.Core;
    4748
    4849namespace HeuristicLab.Hive.Client.Core {
     
    9899      if (cc.IPAdress != String.Empty && cc.Port != 0)
    99100        wcfService.SetIPAndPort(cc.IPAdress, cc.Port);
    100 
    101       if (!UptimeManager.Instance.CalendarAvailable || UptimeManager.Instance.IsOnline())
    102         wcfService.Connect();
    103101
    104102      //Initialize the heartbeat
     
    249247        if (WcfService.Instance.ConnState == NetworkEnum.WcfConnState.Loggedin) {
    250248          Logger.Info("Sending the finished job with id: " + jId);
    251           wcfService.StoreFinishedJobResultAsync(ConfigManager.Instance.GetClientInfo().Id,
    252             jId,
    253             sJob,
    254             1,
    255             null,
    256             true);
     249          wcfService.StoreFinishedJobResultAsync(ConfigManager.Instance.GetClientInfo().Id, jId, sJob, 1.0, null, true);
    257250        } else {
    258251          Logger.Info("Storing the finished job with id: " + jId + " to hdd");
     
    465458
    466459      foreach (KeyValuePair<Guid, Executor> execKVP in engines) {
    467         if (!execKVP.Value.Running && execKVP.Value.CurrentMessage == MessageContainer.MessageType.NoMessage) {
     460        if (execKVP.Value.ExecutionState != ExecutionState.Started && execKVP.Value.CurrentMessage == MessageContainer.MessageType.NoMessage) {
    468461          Logger.Info("Checking for JobId: " + execKVP.Value.JobId);
    469462          Thread finThread = new Thread(new ParameterizedThreadStart(GetFinishedJob));
     
    513506  }
    514507
    515  
     508
    516509}
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Client.Core/3.3/Heartbeat.cs

    r4060 r4119  
    4343    private bool offline;
    4444
    45     public double Interval { get; set; }   
     45    public double Interval { get; set; }
    4646    private Timer heartbeatTimer = null;
    47        
     47
     48    private static object locker = new object();
     49
    4850    public Heartbeat() {
    4951      Interval = 100;
     
    5153
    5254    public Heartbeat(double interval) {
    53       Interval = interval;     
     55      Interval = interval;
    5456    }
    5557
     
    7476    /// <param name="sender"></param>
    7577    /// <param name="e"></param>
    76     void heartbeatTimer_Elapsed(object sender, ElapsedEventArgs e) {     
    77       ClientDto info = ConfigManager.Instance.GetClientInfo();     
     78    void heartbeatTimer_Elapsed(object sender, ElapsedEventArgs e) {
     79      lock (locker) {
     80        // check if cwfService is disconnected for any reason (should happen at first heartbeat)
     81        // [chn] TODO: Client should always send heartbeats. when calendar disallows he should tell the server he does not want to compute anything
     82        if (wcfService.ConnState == NetworkEnum.WcfConnState.Disconnected &&
     83          (!UptimeManager.Instance.CalendarAvailable || UptimeManager.Instance.IsOnline())) {
     84          wcfService.Connect();
     85        }
    7886
    79       PerformanceCounter counter = new PerformanceCounter("Memory", "Available Bytes", true);
    80       int mb = (int)(counter.NextValue() / 1024 / 1024);
     87        ClientDto info = ConfigManager.Instance.GetClientInfo();
    8188
    82       HeartBeatData heartBeatData = new HeartBeatData {
    83         ClientId = info.Id,
    84         FreeCores = info.NrOfCores - ConfigManager.Instance.GetUsedCores(),
    85         FreeMemory = mb,
    86         JobProgress = ConfigManager.Instance.GetProgressOfAllJobs()     
    87       };
    88        
    89       DateTime lastFullHour = DateTime.Parse(DateTime.Now.Hour.ToString() + ":00");
    90       TimeSpan span = DateTime.Now - lastFullHour;
    91       if (span.TotalSeconds < (Interval/1000)) {
    92         if (UptimeManager.Instance.IsOnline() && UptimeManager.Instance.CalendarAvailable) {
    93           //That's quiet simple: Just reconnect and you're good for new jobs
    94           if (wcfService.ConnState != NetworkEnum.WcfConnState.Loggedin) {
    95             Logger.Info("Client goes online according to timetable");
    96             wcfService.Connect();
     89        PerformanceCounter counter = new PerformanceCounter("Memory", "Available Bytes", true);
     90        int mb = (int)(counter.NextValue() / 1024 / 1024);
     91
     92        HeartBeatData heartBeatData = new HeartBeatData {
     93          ClientId = info.Id,
     94          FreeCores = info.NrOfCores - ConfigManager.Instance.GetUsedCores(),
     95          FreeMemory = mb,
     96          JobProgress = ConfigManager.Instance.GetProgressOfAllJobs()
     97        };
     98
     99        DateTime lastFullHour = DateTime.Parse(DateTime.Now.Hour.ToString() + ":00");
     100        TimeSpan span = DateTime.Now - lastFullHour;
     101        if (span.TotalSeconds < (Interval / 1000)) {
     102          if (UptimeManager.Instance.IsOnline() && UptimeManager.Instance.CalendarAvailable) {
     103            //That's quiet simple: Just reconnect and you're good for new jobs
     104            if (wcfService.ConnState != NetworkEnum.WcfConnState.Loggedin) {
     105              Logger.Info("Client goes online according to timetable");
     106              wcfService.Connect();
     107            }
     108          } else {
     109            //We have quit a lot of work to do here: snapshot all jobs, submit them back, then disconnect and then pray to god that nothing goes wrong
     110            MessageQueue.GetInstance().AddMessage(MessageContainer.MessageType.UptimeLimitDisconnect);
    97111          }
    98         } else {
    99           //We have quit a lot of work to do here: snapshot all jobs, submit them back, then disconnect and then pray to god that nothing goes wrong
    100           MessageQueue.GetInstance().AddMessage(MessageContainer.MessageType.UptimeLimitDisconnect);                 
    101         }       
    102       }
    103       if (wcfService.ConnState == NetworkEnum.WcfConnState.Failed) {
    104         wcfService.Connect();
    105       } else if (wcfService.ConnState == NetworkEnum.WcfConnState.Loggedin) {
    106         Logger.Debug("Sending Heartbeat: " + heartBeatData);       
    107         wcfService.ProcessHeartBeatAsync(heartBeatData);
     112        }
     113        if (wcfService.ConnState == NetworkEnum.WcfConnState.Failed) {
     114          wcfService.Connect();
     115        } else if (wcfService.ConnState == NetworkEnum.WcfConnState.Loggedin) {
     116          Logger.Debug("Sending Heartbeat: " + heartBeatData);
     117          wcfService.ProcessHeartBeatAsync(heartBeatData);
     118        }
    108119      }
    109120    }
     
    111122    void wcfService_ProcessHeartBeatCompleted(object sender, ProcessHeartBeatCompletedEventArgs e) {
    112123      Logger.Debug("Heartbeat received");
    113       e.Result.ActionRequest.ForEach(mc => MessageQueue.GetInstance().AddMessage(mc));     
     124      e.Result.ActionRequest.ForEach(mc => MessageQueue.GetInstance().AddMessage(mc));
    114125    }
    115126
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Client.Core/3.3/HeuristicLab.Hive.Client.Core-3.3.csproj

    r4107 r4119  
    7676  </PropertyGroup>
    7777  <ItemGroup>
     78    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    7879    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
    7980      <HintPath>..\..\..\..\..\..\..\..\..\Programme\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Client.Core/3.3/PluginCache.cs

    r4060 r4119  
    4242        //we MAY run in problems here - if there is a plugin twice in requests, there may be added two different versions of the plugin
    4343        foreach (CachedHivePluginInfoDto cache in pluginCache) {
    44           if (info.Name.Equals(cache.Name) && info.Version.Equals(cache.Version) && info.BuildDate <= cache.BuildDate) {
     44          if (info.Name.Equals(cache.Name) && info.Version.Equals(cache.Version)) {
    4545            Logger.Debug("Found plugin " + info.Name + ", " + info.Version);
    4646            neededPlugins.Add(cache);
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Client.Core/3.3/Properties/AssemblyInfo.cs

    r4116 r4119  
    5757// by using the '*' as shown below:
    5858// [assembly: AssemblyVersion("1.0.*")]
    59 [assembly: AssemblyVersion("3.3.0.4111")]
    60 [assembly: AssemblyFileVersion("3.3.0.4111")]
    61 [assembly: AssemblyBuildDate("2010/07/27 18:31:47")]
     59[assembly: AssemblyVersion("3.3.0.4116")]
     60[assembly: AssemblyFileVersion("3.3.0.4116")]
     61[assembly: AssemblyBuildDate("2010/07/28 17:42:03")]
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Client.ExecutionEngine/3.3/Executor.cs

    r4111 r4119  
    2929using HeuristicLab.Persistence.Default.Xml;
    3030using System.IO;
     31using HeuristicLab.Core;
    3132
    3233namespace HeuristicLab.Hive.Client.ExecutionEngine {
     
    3940    public bool JobIsFinished { get; set; }
    4041
    41     public bool Running {
     42    public ExecutionState ExecutionState {
    4243      get {
    43         return Job.Running;
     44        return Job.ExecutionState;
    4445      }
    4546    }
     
    8889    public byte[] GetSnapshot() {
    8990      //if the job is still running, something went VERY bad.
    90       if (Job.Running) {
     91      if (Job.ExecutionState == Core.ExecutionState.Started) {
    9192        return null;
    9293      } else {
     
    103104    public byte[] GetFinishedJob() {
    104105      //Job isn't finished!
    105       if (Job.Running) {
     106      if (Job.ExecutionState == Core.ExecutionState.Started) {
    106107        throw new InvalidStateException("Job is still running");
    107108      } else {
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Client.ExecutionEngine/3.3/HeuristicLab.Hive.Client.ExecutionEngine-3.3.csproj

    r4107 r4119  
    7979      <HintPath>..\..\..\..\..\..\..\..\..\Programme\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
    8080    </Reference>
     81    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    8182    <Reference Include="HeuristicLab.Persistence-3.3">
    8283      <HintPath>..\..\..\..\..\..\..\..\..\Programme\HeuristicLab 3.3\HeuristicLab.Persistence-3.3.dll</HintPath>
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Contracts/3.3/BusinessObjects/HivePluginInfoDto.cs

    r4042 r4119  
    3939    public Version Version { get; set; }
    4040
    41     [DataMember]
    42     public DateTime BuildDate { get; set; }
    4341  }
    4442}
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Engine/3.3/HeuristicLab.Hive.Engine-3.3.csproj

    r4111 r4119  
    128128  </ItemGroup>
    129129  <ItemGroup>
    130     <Compile Include="Job.cs" />
    131130    <Compile Include="HeuristicLabHiveEnginePlugin.cs" />
    132     <Compile Include="HiveEngine.cs" />
    133131    <Compile Include="Properties\AssemblyInfo.cs" />
    134132    <Compile Include="ServiceLocator.cs" />
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Engine/3.3/HiveEngine.cs

    r4116 r4119  
    177177        select new HivePluginInfoDto() {
    178178          Name = p.Name,
    179           Version = p.Version,
    180           BuildDate = p.BuildDate,
     179          Version = p.Version
    181180        }).ToList();
    182181
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment.Views/3.3/HeuristicLab.Hive.Experiment.Views-3.3.csproj

    r4116 r4119  
    3939    <PlatformTarget>AnyCPU</PlatformTarget>
    4040    <OutputPath>bin\Debug\</OutputPath>
     41    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    4142  </PropertyGroup>
    4243  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
     
    4647  <PropertyGroup>
    4748    <StartupObject />
     49  </PropertyGroup>
     50  <PropertyGroup>
     51    <SignAssembly>true</SignAssembly>
     52  </PropertyGroup>
     53  <PropertyGroup>
     54    <AssemblyOriginatorKeyFile>HeuristicLab.snk</AssemblyOriginatorKeyFile>
    4855  </PropertyGroup>
    4956  <ItemGroup>
     
    109116  </ItemGroup>
    110117  <ItemGroup>
     118    <None Include="HeuristicLab.snk" />
    111119    <None Include="Properties\AssemblyInfo.frame" />
    112120  </ItemGroup>
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment.Views/3.3/HiveExperimentView.cs

    r4116 r4119  
    7575      base.OnContentChanged();
    7676      if (Content == null) {
    77         executionTimeTextBox.Text = "-";
     77        executionTimeTextBox.Text = string.Empty;
    7878      } else {
    7979        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
     80        resourceIdsTextBox.Text = Content.ResourceIds;
     81        serverUrlTextBox.Text = Content.ServerUrl;
     82        experimentNamedItemView.Content = Content.Experiment;
    8083      }
    8184    }
     
    8487      base.SetEnabledStateOfControls();
    8588      executionTimeTextBox.Enabled = Content != null;
     89      if (Content != null) {
     90        openExperimentButton.Enabled = Content.Experiment != null;
     91        experimentNamedItemView.Locked = Content.Experiment == null;
     92      }
    8693      SetEnabledStateOfExecutableButtons();
    8794    }
     
    94101    private void Content_ExperimentChanged(object sender, EventArgs e) {
    95102      experimentNamedItemView.Content = Content.Experiment;
     103      if (Content.Experiment != null) {
     104        Content.Prepare();
     105      }
    96106      SetEnabledStateOfExecutableButtons();
    97107    }
     
    179189        stopButton.Enabled = (Content.ExecutionState == ExecutionState.Started) || (Content.ExecutionState == ExecutionState.Paused);
    180190        resetButton.Enabled = Content.ExecutionState != ExecutionState.Started;
    181         openExperimentButton.Enabled = Content.Experiment != null;
    182         experimentNamedItemView.Locked = Content.Experiment == null;
    183191      }
    184192    }
     
    200208
    201209    private void resourceIdsTextBox_Validated(object sender, EventArgs e) {
    202       Content.ResourceIds = resourceIdsLabel.Text;
     210      Content.ResourceIds = resourceIdsTextBox.Text;
    203211    }
    204212
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment.Views/3.3/Properties/AssemblyInfo.cs

    r4116 r4119  
    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.4111")]
    58 [assembly: AssemblyFileVersion("3.3.0.4111")]
    59 [assembly: AssemblyBuildDate("2010/07/27 18:32:02")]
     57[assembly: AssemblyVersion("3.3.0.4116")]
     58[assembly: AssemblyFileVersion("3.3.0.4116")]
     59[assembly: AssemblyBuildDate("2010/07/28 17:42:56")]
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/HeuristicLab.Hive.Experiment-3.3.csproj

    r4116 r4119  
    4242    <PlatformTarget>AnyCPU</PlatformTarget>
    4343    <OutputPath>bin\Debug\</OutputPath>
     44    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    4445  </PropertyGroup>
    4546  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
    4647    <PlatformTarget>AnyCPU</PlatformTarget>
    4748    <OutputPath>bin\Release\</OutputPath>
     49  </PropertyGroup>
     50  <PropertyGroup>
     51    <SignAssembly>true</SignAssembly>
     52  </PropertyGroup>
     53  <PropertyGroup>
     54    <AssemblyOriginatorKeyFile>HeuristicLab.snk</AssemblyOriginatorKeyFile>
    4855  </PropertyGroup>
    4956  <ItemGroup>
     
    8996  </ItemGroup>
    9097  <ItemGroup>
     98    <Compile Include="OptimizerJob.cs" />
    9199    <Compile Include="HeuristicLabHiveExperimentPlugin.cs" />
    92100    <Compile Include="HiveExperiment.cs" />
     
    102110  <ItemGroup>
    103111    <None Include="app.config" />
     112    <None Include="HeuristicLab.snk" />
    104113    <None Include="Properties\AssemblyInfo.frame" />
    105114    <None Include="Properties\Settings.settings">
     
    112121      <Project>{134F93D7-E7C8-4ECD-9923-7F63259A60D8}</Project>
    113122      <Name>HeuristicLab.Hive.Contracts-3.3</Name>
     123    </ProjectReference>
     124    <ProjectReference Include="..\..\HeuristicLab.Hive.JobBase\3.3\HeuristicLab.Hive.JobBase-3.3.csproj">
     125      <Project>{21187322-52DD-4243-80A4-A85F0263E63B}</Project>
     126      <Name>HeuristicLab.Hive.JobBase-3.3</Name>
    114127    </ProjectReference>
    115128  </ItemGroup>
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/HiveExperiment.cs

    r4116 r4119  
    3838using System.Threading;
    3939using HeuristicLab.Tracing;
     40using HeuristicLab.Hive.JobBase;
     41using System.Diagnostics;
     42using System.Collections;
    4043
    4144namespace HeuristicLab.Hive.Experiment {
     
    5053    private const string itemDescription = "An experiment which contains multiple batch runs of algorithms which are executed in the Hive.";
    5154    private const int resultPollingIntervalMs = 10000;
     55
    5256    private const int maxSnapshotRetries = 20;
    5357
    54     private IDictionary<Guid, SerializedJob> jobs = null;
     58    [Storable]
     59    private IDictionary<Guid, IOptimizer> sentOptimizers = null;
     60
    5561    private object locker = new object();
    56 
     62    private DateTime startTime;
     63
     64    [Storable]
    5765    private string serverUrl;
    5866    public string ServerUrl {
     
    6068      set { serverUrl = value; OnServerUrlChanged(); }
    6169    }
    62     public event EventHandler ServerUrlChanged;
    63     protected virtual void OnServerUrlChanged() {
    64       EventHandler handler = ServerUrlChanged;
    65       if (handler != null) handler(this, EventArgs.Empty);
    66     }
    67 
     70
     71    [Storable]
    6872    private string resourceIds;
    6973    public string ResourceIds {
     
    7175      set { resourceIds = value; OnResourceIdsChanged(); }
    7276    }
    73     public event EventHandler ResourceIdsChanged;
    74     protected virtual void OnResourceIdsChanged() {
    75       EventHandler handler = ResourceIdsChanged;
    76       if (handler != null) handler(this, EventArgs.Empty);
     77
     78    [Storable]
     79    private HeuristicLab.Optimization.Experiment experiment;
     80    public HeuristicLab.Optimization.Experiment Experiment {
     81      get { return experiment; }
     82      set { experiment = value; OnExperimentChanged(); }
     83    }
     84
     85    [StorableConstructor]
     86    public HiveExperiment(bool deserializing)
     87      : base(deserializing) {
     88    }
     89
     90    public HiveExperiment()
     91      : base(itemName, itemDescription) {
     92      this.ServerUrl = HeuristicLab.Hive.Experiment.Properties.Settings.Default.HiveServerUrl;
     93      this.ResourceIds = HeuristicLab.Hive.Experiment.Properties.Settings.Default.ResourceIds;
     94    }
     95
     96    public override IDeepCloneable Clone(Cloner cloner) {
     97      HiveExperiment clone = (HiveExperiment)base.Clone(cloner);
     98      clone.resourceIds = this.resourceIds;
     99      clone.serverUrl = this.serverUrl;
     100      clone.experiment = (HeuristicLab.Optimization.Experiment)cloner.Clone(experiment);
     101      clone.executionState = this.executionState;
     102      clone.executionTime = this.executionTime;
     103      clone.sentOptimizers = new Dictionary<Guid, IOptimizer>();
     104      foreach (var pair in this.sentOptimizers)
     105        clone.sentOptimizers[pair.Key] = (IOptimizer)cloner.Clone(pair.Value);
     106      return clone;
    77107    }
    78108
     
    86116      }
    87117    }
    88 
    89     private HeuristicLab.Optimization.Experiment experiment;
    90     public HeuristicLab.Optimization.Experiment Experiment {
    91       get { return experiment; }
    92       set { experiment = value; OnExperimentChanged(); }
    93     }
    94     public event EventHandler ExperimentChanged;
    95     protected virtual void OnExperimentChanged() {
    96       EventHandler handler = ExperimentChanged;
    97       if (handler != null) handler(this, EventArgs.Empty);
    98     }
    99 
    100     public HiveExperiment()
    101       : base(itemName, itemDescription) {
    102       this.ServerUrl = HeuristicLab.Hive.Experiment.Properties.Settings.Default.HiveServerUrl;
    103       this.ResourceIds = HeuristicLab.Hive.Experiment.Properties.Settings.Default.ResourceIds;
    104     }
    105 
    106118    #region IExecutable Members
    107119
    108     public event EventHandler<EventArgs<Exception>> ExceptionOccurred;
    109 
     120    [Storable]
     121    private Core.ExecutionState executionState;
    110122    public ExecutionState ExecutionState {
    111       get { return Core.ExecutionState.Stopped; } // [chn] todo
    112     }
    113 
    114     public event EventHandler ExecutionStateChanged;
    115 
     123      get { return executionState; }
     124      private set {
     125        if (executionState != value) {
     126          executionState = value;
     127          OnExecutionStateChanged();
     128        }
     129      }
     130    }
     131
     132    [Storable]
     133    private TimeSpan executionTime;
    116134    public TimeSpan ExecutionTime {
    117       get { return new TimeSpan(); } // [chn] todo
    118     }
    119 
    120     public event EventHandler ExecutionTimeChanged;
     135      get { return executionTime; }
     136      private set {
     137        executionTime = value;
     138        OnExecutionTimeChanged();
     139      }
     140    }
    121141
    122142    public void Pause() {
     
    124144    }
    125145
    126     public event EventHandler Paused;
    127 
    128146    public void Prepare() {
    129 
    130     }
    131 
    132     public event EventHandler Prepared;
     147      // [chn] needed?
     148      if (experiment != null) {
     149        experiment.Prepare();
     150        OnPrepared();
     151      }
     152    }
    133153
    134154    public void Start() {
     155      this.startTime = DateTime.Now;
     156      this.ExecutionState = Core.ExecutionState.Started;
    135157      IExecutionEngineFacade executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(ServerUrl);
    136158
    137       IList<SerializedJob> serializedJobs = new List<SerializedJob>();
     159      sentOptimizers = new Dictionary<Guid, IOptimizer>();
     160      IEnumerable<string> groups = ResourceGroups;
     161
    138162      foreach (IOptimizer optimizer in Experiment.Optimizers) {
    139         serializedJobs.Add(CreateJob(optimizer));
    140       }
    141 
    142       jobs = new Dictionary<Guid, SerializedJob>();
    143 
    144       IEnumerable<string> groups = ResourceGroups;
    145       foreach (SerializedJob job in serializedJobs) {
    146         ResponseObject<JobDto> response = executionEngineFacade.AddJobWithGroupStrings(job, groups);
    147        
    148         jobs.Add(response.Obj.Id, job);
     163        SerializedJob serializedJob = CreateSerializedJob(optimizer);
     164        ResponseObject<JobDto> response = executionEngineFacade.AddJobWithGroupStrings(serializedJob, groups);
     165        sentOptimizers.Add(response.Obj.Id, optimizer);
    149166        StartResultPollingThread(response.Obj);
    150167      }
    151168    }
    152 
    153     public event EventHandler Started;
    154169
    155170    public void Stop() {
     
    157172    }
    158173
    159     public event EventHandler Stopped;
    160174    private bool abortRequested;
    161175
    162176    #endregion
    163177
    164     private SerializedJob CreateJob(IOptimizer optimizer) {
    165       // serialize optimizer
     178    private SerializedJob CreateSerializedJob(IOptimizer optimizer) {
     179      IJob job = new OptimizerJob() {
     180        Optimizer = optimizer
     181      };
     182
     183      // serialize job
    166184      MemoryStream memStream = new MemoryStream();
    167       XmlGenerator.Serialize(optimizer, memStream);
     185      XmlGenerator.Serialize(job, memStream);
     186      byte[] jobByteArray = memStream.ToArray();
     187      memStream.Dispose();
    168188
    169189      // find out which which plugins are needed for the given object
     
    172192        select new HivePluginInfoDto() {
    173193          Name = p.Name,
    174           Version = p.Version,
    175           BuildDate = p.BuildDate,
     194          Version = p.Version
    176195        }).ToList();
    177196
     
    186205      SerializedJob serializedJob = new SerializedJob() {
    187206        JobInfo = jobDto,
    188         SerializedJobData = memStream.ToArray()
     207        SerializedJobData = jobByteArray
    189208      };
    190       memStream.Dispose();
    191209
    192210      return serializedJob;
     
    196214      Thread t = new Thread(() => {
    197215        IExecutionEngineFacade executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(ServerUrl);
    198         IOptimizer restoredObject = null;
     216        IJob restoredObject = null;
    199217
    200218        do {
     
    211229            // 4. the result that we get from the server is a snapshot and not the final result
    212230            if (response.Success && response.Obj != null && response.StatusMessage != ApplicationConstants.RESPONSE_JOB_RESULT_NOT_YET_HERE) {
    213              
     231
    214232              // [chn] todo: deserialization into interface is not possible! how to find out correct static type?
    215               restoredObject = XmlParser.Deserialize<IOptimizer>(new MemoryStream(response.Obj.SerializedJobData));
     233              restoredObject = XmlParser.Deserialize<IJob>(new MemoryStream(response.Obj.SerializedJobData));
    216234            }
    217235          }
    218         } while (restoredObject == null || restoredObject.ExecutionState == Core.ExecutionState.Stopped);
     236        } while (restoredObject == null || restoredObject.ExecutionState != Core.ExecutionState.Stopped);
    219237
    220238        // job retrieved... replace the existing optimizers with the finished one
    221         // todo
     239        IOptimizer originalOptimizer = sentOptimizers[job.Id];
     240        IOptimizer restoredOptimizer = ((OptimizerJob)restoredObject).Optimizer;
     241
     242        int originalOptimizerIndex = experiment.Optimizers.IndexOf(originalOptimizer);
     243        experiment.Optimizers[originalOptimizerIndex] = restoredOptimizer;
     244        sentOptimizers.Remove(job.Id);
     245
     246        if (sentOptimizers.Count == 0) {
     247          // finished
     248          this.ExecutionState = Core.ExecutionState.Stopped;
     249          OnStopped();
     250        }
    222251      });
    223      
     252
    224253      Logger.Debug("HiveEngine: Starting results-polling thread");
    225254      t.Start();
    226255    }
     256
    227257
    228258    #region Required Plugin Search
     
    310340    }
    311341    #endregion
     342
     343    #region Eventhandler
     344
     345    public event EventHandler ExecutionTimeChanged;
     346    private void OnExecutionTimeChanged() {
     347      EventHandler handler = ExecutionTimeChanged;
     348      if (handler != null) handler(this, EventArgs.Empty);
     349    }
     350
     351    public event EventHandler ExecutionStateChanged;
     352    private void OnExecutionStateChanged() {
     353      EventHandler handler = ExecutionStateChanged;
     354      if (handler != null) handler(this, EventArgs.Empty);
     355    }
     356
     357    public event EventHandler<EventArgs<Exception>> ExceptionOccurred;
     358
     359    public event EventHandler Started;
     360    private void OnStarted() {
     361      EventHandler handler = Started;
     362      if (handler != null) handler(this, EventArgs.Empty);
     363    }
     364
     365    public event EventHandler Stopped;
     366    private void OnStopped() {
     367      EventHandler handler = Stopped;
     368      if (handler != null) handler(this, EventArgs.Empty);
     369    }
     370
     371    public event EventHandler Paused;
     372    private void OnPaused() {
     373      EventHandler handler = Paused;
     374      if (handler != null) handler(this, EventArgs.Empty);
     375    }
     376
     377    public event EventHandler Prepared;
     378    protected virtual void OnPrepared() {
     379      EventHandler handler = Prepared;
     380      if (handler != null) handler(this, EventArgs.Empty);
     381    }
     382
     383    public event EventHandler ResourceIdsChanged;
     384    protected virtual void OnResourceIdsChanged() {
     385      EventHandler handler = ResourceIdsChanged;
     386      if (handler != null) handler(this, EventArgs.Empty);
     387    }
     388
     389    public event EventHandler ExperimentChanged;
     390    protected virtual void OnExperimentChanged() {
     391      EventHandler handler = ExperimentChanged;
     392      if (handler != null) handler(this, EventArgs.Empty);
     393    }
     394
     395    public event EventHandler ServerUrlChanged;
     396    protected virtual void OnServerUrlChanged() {
     397      EventHandler handler = ServerUrlChanged;
     398      if (handler != null) handler(this, EventArgs.Empty);
     399    }
     400
     401
     402    #endregion
    312403  }
    313404}
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/Properties/AssemblyInfo.cs

    r4116 r4119  
    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.4111")]
    58 [assembly: AssemblyFileVersion("3.3.0.4111")]
    59 [assembly: AssemblyBuildDate("2010/07/27 18:31:34")]
     57[assembly: AssemblyVersion("3.3.0.4116")]
     58[assembly: AssemblyFileVersion("3.3.0.4116")]
     59[assembly: AssemblyBuildDate("2010/07/28 17:42:02")]
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.JobBase/3.3/Interfaces/IJob.cs

    r4111 r4119  
    66  public interface IJob {
    77    long JobId { get; set; }
    8     bool Running { get; set; }
     8    ExecutionState ExecutionState { get; }
    99    double Progress { get; }
     10
    1011    void Run();
    1112    void Prepare(IOperation initialOperation);
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/ClientCommunicator.cs

    r4116 r4119  
    691691      ResponsePlugin response = new ResponsePlugin();
    692692      foreach (HivePluginInfoDto pluginInfo in pluginList) {
    693         // TODO: BuildDate deleted, not needed???
    694693        // TODO: Split version to major, minor and revision number
    695694        foreach (IPluginDescription currPlugin in ApplicationManager.Manager.Plugins) {
     
    698697            CachedHivePluginInfoDto currCachedPlugin = new CachedHivePluginInfoDto {
    699698              Name = currPlugin.Name,
    700               Version = currPlugin.Version,
    701               BuildDate = currPlugin.BuildDate
     699              Version = currPlugin.Version
    702700            };
    703701
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/JobManager.cs

    r4116 r4119  
    223223
    224224    public ResponseObject<JobDto> GetLastJobResultOf(Guid jobId) {
    225       ResponseObject<JobDto> result =
    226         new ResponseObject<JobDto>();
    227 
    228       result.Obj =
    229         GetLastJobResult(jobId);
    230       result.Success =
    231         result.Obj != null;
     225      ResponseObject<JobDto> result = new ResponseObject<JobDto>();
     226
     227      result.Obj = GetLastJobResult(jobId);
     228      result.Success = result.Obj != null;
    232229
    233230      return result;
     
    263260      response.Obj.JobInfo = job;
    264261
    265       response.Obj.SerializedJobData =
    266         DaoLocator.JobDao.GetBinaryJobFile(jobId);
     262      response.Obj.SerializedJobData = DaoLocator.JobDao.GetBinaryJobFile(jobId);
    267263
    268264      return response;
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Properties/AssemblyInfo.cs

    r4116 r4119  
    5555// by using the '*' as shown below:
    5656// [assembly: AssemblyVersion("1.0.*")]
    57 [assembly: AssemblyVersion("3.3.0.4111")]
    58 [assembly: AssemblyFileVersion("3.3.0.4111")]
    59 [assembly: AssemblyBuildDate("2010/07/27 18:31:46")]
     57[assembly: AssemblyVersion("3.3.0.4116")]
     58[assembly: AssemblyFileVersion("3.3.0.4116")]
     59[assembly: AssemblyBuildDate("2010/07/28 17:42:06")]
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.LINQDataAccess/3.3/JobDao.cs

    r4116 r4119  
    2626
    2727    public IEnumerable<JobDto> FindWithLimitations(State jobState, int offset, int count) {
    28 
    2928      IQueryable<JobDto> query = null;
    3029      if (jobState == State.Finished) {
     
    8079      job.JobInfo.Id = j.JobId;
    8180      return job;
    82 
    8381    }
    8482
     
    104102              select EntityToDto(j, null)).ToList();
    105103    }
     104
    106105    public IEnumerable<JobDto> FindFittingJobsForClient(State state, int freeCores, int freeMemory, Guid clientId) {
    107106      ClientGroupDao cgd = new ClientGroupDao();
     
    119118               select EntityToDto(ar.Job, null));
    120119      return q.ToList();
    121      
    122120    }
    123121
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.LINQDataAccess/3.3/PluginInfoDao.cs

    r4042 r4119  
    4848        if (dbpi == null) {
    4949          dbpi = new PluginInfo {
    50                                   BuildDate = info.BuildDate.ToString(),
    5150                                  Name = info.Name,
    5251                                  Version = info.Version.ToString()
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive/3.3/Files.txt

    r4111 r4119  
    66HeuristicLab.DataAccess\3.3:HeuristicLab.DataAccess-3.3.dll
    77HeuristicLab.DataAccess.ADOHelper\3.3:HeuristicLab.DataAccess.ADOHelper-3.3.dll
     8
     9HeuristicLab.Hive\3.3:HeuristicLab.Hive.log4net.xml
    810
    911HeuristicLab.Hive.Client.Common\3.3:HeuristicLab.Hive.Client.Common-3.3.dll
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive/3.3/HeuristicLab 3.3.exe.config

    r4071 r4119  
    111111    <HeuristicLab.Tracing.Properties.Settings>
    112112      <setting name="TracingLog4netConfigFile" serializeAs="String">
    113         <value />
     113        <value>HeuristicLab.Hive.log4net.xml</value>
    114114      </setting>
    115115    </HeuristicLab.Tracing.Properties.Settings>
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive/3.3/HeuristicLab.Hive-3.3.csproj

    r4091 r4119  
    7474    <Content Include="Files.x64.txt" />
    7575    <Content Include="Files.x86.txt" />
     76    <Content Include="HeuristicLab.Hive.log4net.xml">
     77      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     78    </Content>
    7679    <Content Include="HeuristicLab.ico" />
    7780  </ItemGroup>
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive/3.3/Properties/AssemblyInfo.cs

    r4116 r4119  
    5151//      Revision
    5252//
    53 [assembly: AssemblyVersion("3.3.0.4111")]
    54 [assembly: AssemblyFileVersion("3.3.0.4111")]
     53[assembly: AssemblyVersion("3.3.0.4116")]
     54[assembly: AssemblyFileVersion("3.3.0.4116")]
Note: See TracChangeset for help on using the changeset viewer.