Changeset 1369
- Timestamp:
- 03/19/09 17:09:32 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Contracts/ApplicationConstants.cs
r1272 r1369 73 73 public static string RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED = "Communicator.JobIsNotBeenigCalculated"; 74 74 public static string RESPONSE_COMMUNICATOR_WRONG_CLIENT_FOR_JOB = "Communicator.WrongClientForJob"; 75 public static string RESPONSE_COMMUNICATOR_JOB_ALLREADY_FINISHED = "Job allready finished. Not needed anymore"; 76 public static string RESPONSE_COMMUNICATOR_JOB_DOESNT_EXIST = "No job exists with this id"; 77 public static string RESPONSE_COMMUNICATOR_SEND_JOBRESULT = "Please send the Jobresult to the server"; 75 78 76 79 public static string RESPONSE_JOB_ALL_JOBS = "Job.AllJobs"; -
trunk/sources/HeuristicLab.Hive.Contracts/HeuristicLab.Hive.Contracts.csproj
r1175 r1369 103 103 <Compile Include="ResponseHB.cs" /> 104 104 <Compile Include="ResponseList.cs" /> 105 <Compile Include="ResponsePlugin.cs" /> 105 106 <Compile Include="ResponseResultReceived.cs" /> 106 107 </ItemGroup> -
trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/IClientCommunicator.cs
r1365 r1369 48 48 [OperationContract] 49 49 Response Logout(Guid clientId); 50 [OperationContract] 51 Response IsJobStillNeeded(long jobId); 52 [OperationContract] 53 ResponsePlugin SendPlugins(List<String> pluginList); 50 54 } 51 55 } -
trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs
r1368 r1369 46 46 new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); 47 47 48 // todo: access modifier! 49 IClientAdapter clientAdapter; 50 IJobAdapter jobAdapter; 51 IJobResultsAdapter jobResultAdapter; 52 ILifecycleManager lifecycleManager; 53 IInternalJobManager jobManager; 54 IScheduler scheduler; 48 private IClientAdapter clientAdapter; 49 private IJobAdapter jobAdapter; 50 private IJobResultsAdapter jobResultAdapter; 51 private ILifecycleManager lifecycleManager; 52 private IInternalJobManager jobManager; 53 private IScheduler scheduler; 55 54 56 55 /// <summary> … … 145 144 146 145 // todo: allClients legacy ? 147 ICollection<ClientInfo> allClients = clientAdapter.GetAll();148 146 ClientInfo client = clientAdapter.GetById(clientInfo.ClientId); 149 147 if (client != null && client.State != State.offline && client.State != State.nullState) { … … 167 165 /// <param name="hbData"></param> 168 166 /// <returns></returns> 169 // todo: new name for "SendHeartBeat" e.g. ProcessHeartBeat170 167 public ResponseHB ProcessHeartBeat(HeartBeatData hbData) { 171 168 ResponseHB response = new ResponseHB(); 172 169 170 // check if the client is logged in 173 171 response.ActionRequest = new List<MessageContainer>(); 174 172 if (clientAdapter.GetById(hbData.ClientId).State == State.offline || … … 180 178 } 181 179 180 // save timestamp of this heartbeat 182 181 heartbeatLock.EnterWriteLock(); 183 182 if (lastHeartbeats.ContainsKey(hbData.ClientId)) { … … 190 189 response.Success = true; 191 190 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_HEARTBEAT_RECEIVED; 191 // check if client has a free core for a new job 192 // if true, ask scheduler for a new job for this client 192 193 if (hbData.FreeCores > 0 && scheduler.ExistsJobForClient(hbData)) 193 194 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.FetchJob)); … … 208 209 response.Success = false; 209 210 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED; 211 } else if(curJob.State == State.finished) { 212 // another client has finished this job allready 213 // the client can abort it 214 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id)); 210 215 } else { 216 // save job progress 211 217 curJob.Percentage = jobProgress.Value; 212 218 jobAdapter.Update(curJob); … … 279 285 return response; 280 286 } 287 if (job.State == State.finished) { 288 response.Success = true; 289 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOBRESULT_RECEIVED; 290 return response; 291 } 281 292 if (job.State != State.calculating) { 282 293 response.Success = false; … … 358 369 } 359 370 371 /// <summary> 372 /// If a client goes offline and restores a job he was calculating 373 /// he can ask the client if he still needs the job result 374 /// </summary> 375 /// <param name="jobId"></param> 376 /// <returns></returns> 377 public Response IsJobStillNeeded(long jobId) { 378 Response response = new Response(); 379 Job job = jobAdapter.GetById(jobId); 380 if (job == null) { 381 response.Success = false; 382 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_DOESNT_EXIST; 383 return response; 384 } 385 if (job.State == State.finished) { 386 response.Success = true; 387 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_ALLREADY_FINISHED; 388 return response; 389 } 390 job.State = State.finished; 391 jobAdapter.Update(job); 392 393 response.Success = true; 394 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_SEND_JOBRESULT; 395 return response; 396 } 397 398 public ResponsePlugin SendPlugins(List<string> pluginList) { 399 throw new NotImplementedException(); 400 } 401 360 402 #endregion 361 403 } -
trunk/sources/HeuristicLab.Hive.Server.Core/ClientFacade.cs
r1365 r1369 61 61 } 62 62 63 public Response IsJobStillNeeded(long jobId) { 64 return clientCommunicator.IsJobStillNeeded(jobId); 65 } 66 67 public ResponsePlugin SendPlugins(List<string> pluginList) { 68 return clientCommunicator.SendPlugins(pluginList); 69 } 70 63 71 #endregion 64 72 }
Note: See TracChangeset
for help on using the changeset viewer.