- Timestamp:
- 01/14/09 16:16:21 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs
r1120 r1121 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 18 39 /// </summary> 19 40 public class ClientCommunicator: IClientCommunicator { 20 int nrOfJobs = 0;21 41 Dictionary<Guid, DateTime> lastHeartbeats = 22 42 new Dictionary<Guid,DateTime>(); … … 27 47 ILifecycleManager lifecycleManager; 28 48 49 /// <summary> 50 /// Initialization of the Adapters to the database 51 /// Initialization of Eventhandler for the lifecycle management 52 /// Initialization of lastHearbeats Dictionary 53 /// </summary> 29 54 public ClientCommunicator() { 30 55 clientAdapter = ServiceLocator.GetClientAdapter(); … … 36 61 new EventHandler(lifecycleManager_OnServerHeartbeat); 37 62 38 for (int i = 0; i < nrOfJobs; i++) {39 Job job = new Job();40 job.Id = i;41 job.State = State.offline;42 jobAdapter.Update(job);43 }44 63 lastHeartbeats = new Dictionary<Guid, DateTime>(); 45 46 } 47 64 } 65 66 /// <summary> 67 /// Check if online clients send their hearbeats 68 /// if not -> set them offline and check if they where calculating a job 69 /// </summary> 70 /// <param name="sender"></param> 71 /// <param name="e"></param> 48 72 [MethodImpl(MethodImplOptions.Synchronized)] 49 73 void lifecycleManager_OnServerHeartbeat(object sender, EventArgs e) { … … 89 113 #region IClientCommunicator Members 90 114 115 /// <summary> 116 /// Login process for the client 117 /// A hearbeat entry is created as well (login is the first hearbeat) 118 /// </summary> 119 /// <param name="clientInfo"></param> 120 /// <returns></returns> 91 121 [MethodImpl(MethodImplOptions.Synchronized)] 92 122 public Response Login(ClientInfo clientInfo) { … … 114 144 } 115 145 146 /// <summary> 147 /// The client has to send regulary heartbeats 148 /// this hearbeats will be stored in the heartbeats dictionary 149 /// check if there is work for the client and send the client a response if he should pull a job 150 /// </summary> 151 /// <param name="hbData"></param> 152 /// <returns></returns> 116 153 [MethodImpl(MethodImplOptions.Synchronized)] 117 154 public ResponseHB SendHeartBeat(HeartBeatData hbData) { … … 143 180 return response; 144 181 } 145 182 183 /// <summary> 184 /// if the client asked to pull a job he calls this method 185 /// the server selects a job and sends it to the client 186 /// </summary> 187 /// <param name="clientId"></param> 188 /// <returns></returns> 146 189 [MethodImpl(MethodImplOptions.Synchronized)] 147 190 public ResponseJob PullJob(Guid clientId) { … … 164 207 } 165 208 209 /// <summary> 210 /// the client can send job results during calculating 211 /// and will send a final job result when he finished calculating 212 /// these job results will be stored in the database 213 /// </summary> 214 /// <param name="clientId"></param> 215 /// <param name="jobId"></param> 216 /// <param name="result"></param> 217 /// <param name="exception"></param> 218 /// <param name="finished"></param> 219 /// <returns></returns> 166 220 [MethodImpl(MethodImplOptions.Synchronized)] 167 221 public ResponseResultReceived SendJobResult(Guid clientId, … … 211 265 } 212 266 267 /// <summary> 268 /// when a client logs out the state will be set 269 /// and the entry in the last hearbeats dictionary will be removed 270 /// </summary> 271 /// <param name="clientId"></param> 272 /// <returns></returns> 213 273 [MethodImpl(MethodImplOptions.Synchronized)] 214 274 public Response Logout(Guid clientId) {
Note: See TracChangeset
for help on using the changeset viewer.