Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/08/11 14:54:17 (13 years ago)
Author:
cneumuel
Message:

#1233

  • updated jobstates documentation
  • enhanced ganttChart
  • fixed setting of jobstates
  • added option to force lifecycle-trigger (mainly for testing purposes)
File:
1 edited

Legend:

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

    r5599 r5636  
    4949    public NetworkEnum.WcfConnState ConnState { get; private set; }
    5050
     51    private WcfService() {
     52      ConnState = NetworkEnum.WcfConnState.Disconnected;
     53    }
     54
     55    #region Job Methods
     56    public Job GetJob(Guid jobId) {
     57      return CallHiveService(s => s.GetJob(jobId));
     58    }
     59
     60    public void UpdateJob(Job job) {
     61      CallHiveService(s => s.UpdateJob(job));
     62    }
     63
     64    public Guid AddChildJob(Guid parentJobId, Job job, JobData jobData) {
     65      return CallHiveService(s => s.AddChildJob(parentJobId, job, jobData));
     66    }
     67
     68    public IEnumerable<JobData> GetChildJobs(Guid? parentJobId) {
     69      return CallHiveService(service => {
     70        IEnumerable<LightweightJob> msg = service.GetLightweightChildJobs(parentJobId, false, false);
     71
     72        List<JobData> jobs = new List<JobData>();
     73        foreach (LightweightJob ljob in msg)
     74          jobs.Add(service.GetJobData(ljob.Id));
     75
     76        return jobs;
     77      });
     78    }
     79
     80    public void DeleteChildJobs(Guid jobId) {
     81      CallHiveService(s => s.DeleteChildJobs(jobId));
     82    }
     83    #endregion
     84
     85    #region JobData Methods
     86    public JobData GetJobData(Guid jobId) {
     87      return CallHiveService(s => s.GetJobData(jobId));
     88    }
     89
     90    /// <summary>
     91    /// Uploads the JobData and sets a new jobState (while correctly setting Transferring state)
     92    /// </summary>
     93    public void UpdateJobData(Job job, JobData jobData, Guid slaveId, JobState state) {
     94      CallHiveService(service => {
     95        service.UpdateJob(job);
     96        job = service.UpdateJobState(job.Id, JobState.Transferring, slaveId, null, null);
     97        service.UpdateJobData(job, jobData);
     98        service.UpdateJobState(job.Id, state, slaveId, null, null);
     99      });
     100    }
     101
     102    public Job UpdateJobState(Guid jobId, JobState jobState, string exception) {
     103      return CallHiveService(s => s.UpdateJobState(jobId, jobState, ConfigManager.GetUniqueMachineId(), null, exception));
     104    }
     105    #endregion
     106
     107    #region Heartbeat Methods
     108    public List<MessageContainer> SendHeartbeat(Heartbeat heartbeat) {
     109      return CallHiveService(s => s.Heartbeat(heartbeat));
     110    }
     111    #endregion
     112
     113    #region Plugin Methods
     114    public IEnumerable<Plugin> GetPlugins() {
     115      return CallHiveService(s => s.GetPlugins());
     116    }
     117
     118    public IEnumerable<PluginData> GetPluginDatas(List<Guid> pluginIds) {
     119      return CallHiveService(s => s.GetPluginDatas(pluginIds));
     120    }
     121    #endregion
     122
     123    #region Events
    51124    public event EventHandler Connected;
    52125    private void OnConnected() {
     
    60133      if (handler != null) handler(this, new EventArgs<Exception>(e));
    61134    }
     135    #endregion
    62136
    63     /// <summary>
    64     /// Constructor
    65     /// </summary>
    66     private WcfService() {
    67       ConnState = NetworkEnum.WcfConnState.Disconnected;
    68     }
    69 
     137    #region Helpers
    70138    /// <summary>
    71139    /// Connects with the Server, registers the events and fires the Connected (and quiet possibly the ConnectionRestored) Event.
     
    99167    }
    100168
    101     /// <summary>
    102     /// Get a Job from the Server
    103     /// </summary>
    104     public Job GetJob(Guid jobId) {
    105       return CallHiveService(s => s.GetJob(jobId));
    106     }
    107 
    108     public JobData GetJobData(Guid jobId) {
    109       return CallHiveService(s => s.GetJobData(jobId));
    110     }
    111 
    112     public void UpdateJob(Job job) {
    113       CallHiveService(s => s.UpdateJob(job));
    114     }
    115 
    116     /// <summary>
    117     /// used on pause or if job finished to upload the job results
    118     /// </summary>
    119     /// <param name="job"></param>
    120     /// <param name="jobData"></param>   
    121     public void UpdateJobData(Job job, JobData jobData, Guid slaveId) {
    122       CallHiveService(service => {
    123         JobState before = job.State;
    124         job.SetState(JobState.Transferring, slaveId, "");
    125 
    126         service.UpdateJob(job);
    127 
    128         service.UpdateJobData(job, jobData);
    129 
    130         job.SetState(before, slaveId, "");
    131         service.UpdateJob(job);
    132       });
    133     }
    134 
    135     public List<MessageContainer> SendHeartbeat(Heartbeat heartbeat) {
    136       return CallHiveService(s => s.Heartbeat(heartbeat));
    137     }
    138 
    139     public IEnumerable<PluginData> GetPluginDatas(List<Guid> pluginIds) {
    140       return CallHiveService(s => s.GetPluginDatas(pluginIds));
    141     }
    142 
    143     public IEnumerable<Plugin> GetPlugins() {
    144       return CallHiveService(s => s.GetPlugins());
    145     }
    146 
    147     public Guid AddChildJob(Guid parentJobId, Job job, JobData jobData) {
    148       return CallHiveService(s => s.AddChildJob(parentJobId, job, jobData));
    149     }
    150 
    151     public IEnumerable<JobData> GetChildJobs(Guid? parentJobId) {
    152       return CallHiveService(service => {
    153         IEnumerable<LightweightJob> msg = service.GetLightweightChildJobs(parentJobId, false, false);
    154 
    155         List<JobData> jobs = new List<JobData>();
    156         foreach (LightweightJob ljob in msg)
    157           jobs.Add(service.GetJobData(ljob.Id));
    158 
    159         return jobs;
    160       });
    161     }
    162 
    163     public void DeleteChildJobs(Guid jobId) {
    164       CallHiveService(s => s.DeleteChildJobs(jobId));
    165     }
    166 
    167169    public void CallHiveService(Action<IHiveService> call) {
    168170      try {
     
    183185      }
    184186    }
     187    #endregion
    185188  }
    186189}
Note: See TracChangeset for help on using the changeset viewer.