Changeset 5062


Ignore:
Timestamp:
12/07/10 16:11:14 (11 years ago)
Author:
cneumuel
Message:

#1233

  • implemented MockService, MockJob, MockServiceLocator
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
4 added
2 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources

    • Property svn:ignore
      •  

        old new  
        11HeuristicLab.Hive-3.4.suo
         2TestResults
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Tests-3.4/HeuristicLab.Clients.Hive.Slave.Tests-3.4.csproj

    r5056 r5062  
    297297      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    298298    </Reference>
     299    <Reference Include="System.Drawing" />
    299300    <Reference Include="WeifenLuo.WinFormsUI.Docking-2.3.1">
    300301      <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\WeifenLuo.WinFormsUI.Docking-2.3.1.dll</HintPath>
     
    307308  </ItemGroup>
    308309  <ItemGroup>
    309     <Compile Include="Mocks\HiveServiceMock.cs" />
     310    <Compile Include="Mocks\MockHiveService.cs" />
     311    <Compile Include="Mocks\MockJob.cs" />
    310312    <Compile Include="PluginLoader.cs" />
    311313    <Compile Include="Properties\AssemblyInfo.cs" />
    312     <Compile Include="Mocks\ServiceLocatorMock.cs" />
     314    <Compile Include="Mocks\MockServiceLocator.cs" />
    313315    <Compile Include="SlaveTest.cs" />
    314316  </ItemGroup>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Tests-3.4/SlaveTest.cs

    r5055 r5062  
    1313    public static void MyClassInitialize(TestContext testContext) {
    1414      PluginLoader.pluginAssemblies.Any();
    15       ServiceLocator.Instance = new ServiceLocatorMock();
     15      ServiceLocator.Instance = new MockServiceLocator();
    1616    }
    1717
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/SlaveDummy.cs

    r5055 r5062  
    66namespace HeuristicLab.Clients.Hive.Slave {
    77  public class SlaveDummy {
     8
    89    public void SayHello() {
    910      using (var service = ServiceLocator.Instance.GetService()) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HeuristicLab.Clients.Hive-3.4.csproj

    r5055 r5062  
    8383    <Compile Include="Exceptions\JobResultPollingException.cs" />
    8484    <Compile Include="Exceptions\OptimizerNotFoundException.cs" />
    85     <Compile Include="HiveExperiment\PluginClient.cs" />
     85    <Compile Include="ExperimentManager\PluginClient.cs" />
    8686    <Compile Include="IServiceLocator.cs" />
    8787    <Compile Include="Jobs\OptimizerJob.cs" />
    8888    <Compile Include="HeuristicLabClientsHivePlugin.cs" />
    89     <Compile Include="HiveExperiment\HiveExperimentManagerClient.cs" />
    90     <Compile Include="HiveExperiment\HiveJobClient.cs" />
    91     <Compile Include="HiveExperiment\HiveExperimentClient.cs" />
    92     <Compile Include="HiveExperiment\JobResultPoller.cs" />
     89    <Compile Include="ExperimentManager\HiveExperimentManagerClient.cs" />
     90    <Compile Include="ExperimentManager\HiveJobClient.cs" />
     91    <Compile Include="ExperimentManager\HiveExperimentClient.cs" />
     92    <Compile Include="ExperimentManager\JobResultPoller.cs" />
    9393    <Compile Include="Progress\IProgress.cs" />
    9494    <Compile Include="Progress\IProgressReporter.cs" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/Jobs/OptimizerJob.cs

    r4796 r5062  
    3232  [StorableClass]
    3333  public class OptimizerJob : DeepCloneable, IJob {
     34    public virtual bool IsParallelizable {
     35      get { return this.Optimizer is Optimization.Experiment || this.Optimizer is BatchRun; }
     36    }
     37
    3438    [Storable]
    3539    protected IOptimizer optimizer;
     
    8185      this.log = new Log();
    8286    }
    83     public OptimizerJob(IOptimizer optimizer)
    84       : this() {
     87    public OptimizerJob(IOptimizer optimizer) : this() {
    8588      this.Optimizer = optimizer;
    8689
     
    9598    [StorableConstructor]
    9699    protected OptimizerJob(bool deserializing) { }
    97     protected OptimizerJob(OptimizerJob original, Cloner cloner)
    98       : base(original, cloner) {
     100    protected OptimizerJob(OptimizerJob original, Cloner cloner) : base(original, cloner) {
    99101      this.Optimizer = cloner.Clone(original.Optimizer);
    100102      this.log = cloner.Clone(original.Log);
     
    135137    public TimeSpan ExecutionTime {
    136138      get { return optimizer.ExecutionTime; }
    137     }
    138 
    139     public virtual void Run() {
    140       throw new NotSupportedException();
    141139    }
    142140
     
    152150        optimizer.Start();
    153151      }
     152    }
     153
     154    public void Pause() {
     155      throw new NotImplementedException();
    154156    }
    155157
     
    301303      if (handler != null) handler(this, new CancelEventArgs<string>(value, cancel));
    302304    }
     305    public event EventHandler ExecutionTimeChanged;
     306    protected virtual void OnExecutionTimeChanged() {
     307      EventHandler handler = ExecutionTimeChanged;
     308      if (handler != null) handler(this, EventArgs.Empty);
     309    }
     310    public event EventHandler ExecutionStateChanged;
     311    protected virtual void OnExecutionStateChanged() {
     312      EventHandler handler = ExecutionStateChanged;
     313      if (handler != null) handler(this, EventArgs.Empty);
     314    }
    303315    #endregion
    304316
     
    330342      return Name;
    331343    }
    332 
    333     public virtual bool IsParallelizable {
    334       get { return this.Optimizer is Optimization.Experiment || this.Optimizer is BatchRun; }
    335     }
    336 
    337344  }
    338345}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Hive-3.4.sln

    r5053 r5062  
    5252  EndProjectSection
    5353EndProject
    54 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Clients.Hive.Slave.Tests-3.4", "HeuristicLab.Clients.Hive.Slave.Tests-3.4\HeuristicLab.Clients.Hive.Slave.Tests-3.4.csproj", "{C4CBD11E-1B83-464A-B0AD-0DC0FF7E57AA}"
     54Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Clients.Hive.Slave.Tests-3.4", "HeuristicLab.Clients.Hive.Slave.Tests\HeuristicLab.Clients.Hive.Slave.Tests-3.4.csproj", "{C4CBD11E-1B83-464A-B0AD-0DC0FF7E57AA}"
    5555EndProject
    5656Global
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Hive/3.4/IJob.cs

    r4593 r5062  
    2727namespace HeuristicLab.Hive {
    2828  public interface IJob : INamedItem {
     29
    2930    TimeSpan ExecutionTime { get; }
    3031
     
    4142    /// </summary>
    4243    bool ComputeInParallel { get; set; }
     44
     45    /// <summary>
     46    /// If this is set to true, the job should be Resumed with the child-jobs attatched instead of Started
     47    /// </summary>
     48    bool CollectChildJobs { get; set; }
     49   
     50    void Prepare();
     51
     52    void Start();
     53
     54    void Pause();
     55
     56    void Stop();
     57
     58    void Resume(IEnumerable<IJob> childJobs);
     59
    4360    event EventHandler ComputeInParallelChanged;
    4461
    45     void Run();
    46     void Prepare();
    47     void Start();
    48     void Stop();
    49     void Resume(IEnumerable<IJob> childJobs);
     62    event EventHandler ExecutionTimeChanged;
    5063
    51     event EventHandler JobStopped;
    52     event EventHandler JobFailed;
    53 
     64    event EventHandler ExecutionStateChanged;
     65       
    5466    /// <summary>
    5567    /// When this event occurs the job wants to sleep until all his child jobs are finished
     
    6779    event EventHandler DeleteChildJobs;
    6880   
    69     /// <summary>
    70     /// If this is set to true, the job should be Resumed with the child-jobs attatched instead of Started
    71     /// </summary>
    72     bool CollectChildJobs { get; set; }
     81
    7382  }
    7483}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/ServiceContracts/IHiveService.cs

    r5053 r5062  
    3535    JobData GetJobData(Guid jobId);
    3636
    37     //[OperationContract]
    38     //Stream GetJobDataStreamed(Guid jobId);
    39 
    4037    [OperationContract]
    4138    void UpdateJob(Job jobDto, JobData jobDataDto);
    42        
    43     //[OperationContract] // formerly StoreFinishedJobResultStreamed
    44     //void UpdateJobDataStreamed(Stream stream);
    4539
    4640    [OperationContract]
     
    4943    [OperationContract] // new method: appropriate job is choosen and set to 'calculating'. the slave is responsible for requesting the jobData. Server should wait some timeout until he redistributes the job
    5044    Job AquireJob(Guid slaveId);
    51 
    52     //[OperationContract] // dump?
    53     //Job GetJobByIdWithDetails(Guid jobId);
    54 
    55     //[OperationContract] dump?
    56     //Job AddNewJob(JobData job);
    57 
    58     //[OperationContract]
    59     //void RemoveJob(Guid jobId);
    60 
    61     //[OperationContract] // GetJobForCalculation (was this used?
    62     //Job GetJob(Guid slaveId);
    63 
    64     //[OperationContract] --> replaced by UpdateJob
    65     //void StoreFinishedJobResult(Guid slaveId, Guid jobId, byte[] result, TimeSpan executionTime, string exception);
    66 
    67     //[OperationContract] dump this! a slave should just check if job is still offline, if so it can submit the finished job, otherwise throw away! its a rare case that a slave reawakes with a finished job
    68     //void IsJobStillNeeded(Guid jobId);
    69 
    70     //[OperationContract] // dump?
    71     //Job AddJobWithGroupStrings(JobData jobObj, IEnumerable<string> groups);
    7245    #endregion
    7346
     
    7750
    7851    [OperationContract]
    79     Job PauseJob(Guid jobId);
     52    void PauseJob(Guid jobId);
    8053    #endregion
    8154
     
    10174
    10275    #region Login Methods
    103     // rename "Login"-methods to "Register" or "SayHello", since its only purpose is to send Slave-Info (is Login() should not be used anymore)
    104     /// <summary>
    105     /// Method can be used to check if security credentials are valid, but it does not do anything
    106     /// </summary>
    107     /// <returns></returns>
    108     //[OperationContract]
    109     //void Login();
    110     ///// <summary>
    111     ///// This method registers the slave and marks it as online
    112     ///// </summary>
    113     //[OperationContract]
    114     //void Login(Slave slave);
    115     //[OperationContract]
    116     //void Logout(Guid clientId);
    117 
    11876    [OperationContract]
    11977    void Hello(Guid slaveId, string name, int cores, int memory);
     
    13694    IEnumerable<PluginData> GetPluginDatas(List<Guid> pluginIds);
    13795    #endregion
    138 
    139     // slave should be unaware of calendar. only server decides based on calendar if slave gets jobs
    140     //#region Calendar Methods
    141     //[OperationContract]
    142     //IEnumerable<Appointment> GetCalendar(Guid slaveId);
    143     //[OperationContract]
    144     //void SetCalendarStatus(Guid clientId, CalendarState state);
    145     //[OperationContract]
    146     //IEnumerable<Appointment> GetUptimeCalendarForResource(Guid guid);
    147     //[OperationContract]
    148     //void SetUptimeCalendarForResource(Guid guid, IEnumerable<Appointment> appointments, bool isForced);
    149     //#endregion
    150 
     96   
    15197    #region Slave Methods
    15298    [OperationContract]
     
    160106   
    161107    [OperationContract]
    162     //[ServiceKnownType(typeof(Resource))] - not sure about those
    163     //[ServiceKnownType(typeof(Slave))]
    164     //[ServiceKnownType(typeof(SlaveGroup))]
     108    [ServiceKnownType(typeof(Resource))]
     109    [ServiceKnownType(typeof(Slave))]
     110    [ServiceKnownType(typeof(SlaveGroup))]
    165111    IEnumerable<SlaveGroup> GetSlaveGroups();
    166112
     
    169115
    170116    [OperationContract]
    171     //[ServiceKnownType(typeof(Resource))]
    172     //[ServiceKnownType(typeof(Slave))]
    173     //[ServiceKnownType(typeof(SlaveGroup))]
     117    [ServiceKnownType(typeof(Resource))]
     118    [ServiceKnownType(typeof(Slave))]
     119    [ServiceKnownType(typeof(SlaveGroup))]
    174120    void AddResourceToGroup(Guid slaveGroupId, Resource resource);
    175121
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs

    r5055 r5062  
    119119      }
    120120    }
    121     public Job PauseJob(Guid jobId) {
     121    public void PauseJob(Guid jobId) {
    122122      using (trans.OpenTransaction()) {
    123123        throw new NotImplementedException();
Note: See TracChangeset for help on using the changeset viewer.