- Timestamp:
- 03/08/11 14:54:17 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs
r5599 r5636 140 140 switch (container.Message) { 141 141 case MessageContainer.MessageType.CalculateJob: 142 Job myJob = wcfService.GetJob(container.JobId);143 //TODO: handle in own thread!!144 JobData jobData = wcfService.GetJobData(myJob.Id);145 StartJobInAppDomain( myJob, jobData);142 Job job = wcfService.GetJob(container.JobId); 143 JobData jobData = wcfService.GetJobData(job.Id); 144 job = wcfService.UpdateJobState(job.Id, JobState.Calculating, null); 145 StartJobInAppDomain(job, jobData); 146 146 break; 147 147 case MessageContainer.MessageType.ShutdownSlave: … … 181 181 } 182 182 183 private void DoPauseJob(Guid guid) {184 Job job = Jobs[ guid];183 private void DoPauseJob(Guid jobId) { 184 Job job = Jobs[jobId]; 185 185 186 186 if (job != null) { … … 192 192 try { 193 193 ClientCom.LogMessage("Sending the paused job with id: " + job.Id); 194 wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id );194 wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id, JobState.Paused); 195 195 SlaveStatusInfo.JobsProcessed++; //TODO: count or not count, thats the question 196 196 } … … 215 215 try { 216 216 ClientCom.LogMessage("Sending the stoppped job with id: " + job.Id); 217 wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id );217 wcfService.UpdateJobData(job, sJob, ConfigManager.Instance.GetClientInfo().Id, JobState.Paused); 218 218 SlaveStatusInfo.JobsProcessed++; //TODO: count or not count, thats the question 219 219 } … … 347 347 } else { 348 348 Job job = Jobs[data.JobId]; 349 job.SetState(JobState.Transferring); 350 wcfService.UpdateJobData(job, data, ConfigManager.Instance.GetClientInfo().Id); 351 job.SetState(JobState.Waiting); // todo: what if it was a ResumeOnChildJobsFinished job before? maybe look into StateLog 349 wcfService.UpdateJobData(job, data, ConfigManager.Instance.GetClientInfo().Id, JobState.Paused); 350 job.SetState(JobState.Waiting); 352 351 wcfService.UpdateJob(job); 353 352 } … … 373 372 } 374 373 Job cJob = jobs[jobId]; 375 cJob.State = JobState.Finished; // TODO: what if failed?376 374 cJob.ExecutionTime = engines[jobId].ExecutionTime; 377 375 … … 382 380 try { 383 381 ClientCom.LogMessage("Sending the finished job with id: " + jobId); 384 wcfService.UpdateJobData(cJob, sJob, ConfigManager.Instance.GetClientInfo().Id );382 wcfService.UpdateJobData(cJob, sJob, ConfigManager.Instance.GetClientInfo().Id, JobState.Finished); 385 383 SlaveStatusInfo.JobsProcessed++; 386 384 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/WcfService.cs
r5599 r5636 49 49 public NetworkEnum.WcfConnState ConnState { get; private set; } 50 50 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 51 124 public event EventHandler Connected; 52 125 private void OnConnected() { … … 60 133 if (handler != null) handler(this, new EventArgs<Exception>(e)); 61 134 } 135 #endregion 62 136 63 /// <summary> 64 /// Constructor 65 /// </summary> 66 private WcfService() { 67 ConnState = NetworkEnum.WcfConnState.Disconnected; 68 } 69 137 #region Helpers 70 138 /// <summary> 71 139 /// Connects with the Server, registers the events and fires the Connected (and quiet possibly the ConnectionRestored) Event. … … 99 167 } 100 168 101 /// <summary>102 /// Get a Job from the Server103 /// </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 results118 /// </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 167 169 public void CallHiveService(Action<IHiveService> call) { 168 170 try { … … 183 185 } 184 186 } 187 #endregion 185 188 } 186 189 }
Note: See TracChangeset
for help on using the changeset viewer.