Changeset 1096
- Timestamp:
- 01/08/09 16:22:59 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Contracts/ApplicationConstants.cs
r1086 r1096 47 47 public static string RESPONSE_COMMUNICATOR_NO_JO_WITH_THIS_ID = "Communicator.NoJobWithThisId"; 48 48 public static string RESPONSE_COMMUNICATOR_WRONG_JOB_STATE = "Communicator.WrongJobState"; 49 public static string RESPONSE_COMMUNICATOR_USER_NOT_LOGGED_IN = "Communicator.UserNotLoggedIn"; 49 50 50 51 public static string RESPONSE_JOB_ALL_JOBS = "Job.AllJobs"; -
trunk/sources/HeuristicLab.Hive.Contracts/HiveServerMessages.resx
r1024 r1096 226 226 <value>The state of the job must be offline</value> 227 227 </data> 228 <data name="Communicator.UserNotLoggedIn" xml:space="preserve"> 229 <value>User is not logged in, you must login before sending Heartbeats</value> 230 </data> 228 231 </root> -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/CachedDataAdapter.cs
r1095 r1096 42 42 new List<ICachedDataAdapter>(); 43 43 44 private DataTable temp = new DataTable(); 45 44 46 protected CachedDataAdapter() { 45 47 FillCache(); … … 127 129 [MethodImpl(MethodImplOptions.Synchronized)] 128 130 protected abstract RowT FindCachedById(long id); 129 130 protected abstract DataTable GetDataTable();131 131 132 132 [MethodImpl(MethodImplOptions.Synchronized)] … … 191 191 !PutInCache(obj)) { 192 192 //remove from cache 193 GetDataTable().ImportRow(row);193 temp.ImportRow(row); 194 194 195 195 UpdateRow(row); -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ClientAdapter.cs
r1094 r1096 202 202 } 203 203 204 protected override System.Data.DataTable GetDataTable() {205 return data;206 }207 204 #endregion 208 205 … … 214 211 ClientInfo found = GetById(client.ClientId); 215 212 if (found != null) 216 client = found;213 client.Id = found.Id; 217 214 } 218 215 -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/JobAdapter.cs
r1094 r1096 188 188 new Selector(adapter.GetData), 189 189 new Selector(cache.AsEnumerable<dsHiveServer.JobRow>)); 190 }191 192 protected override System.Data.DataTable GetDataTable() {193 return data;194 190 } 195 191 -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ResourceAdapter.cs
r1094 r1096 127 127 } 128 128 129 protected override System.Data.DataTable GetDataTable() {130 return data;131 }132 129 #endregion 133 130 -
trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs
r1088 r1096 11 11 using System.Reflection; 12 12 using HeuristicLab.Hive.JobBase; 13 using System.Runtime.CompilerServices; 13 14 14 15 namespace HeuristicLab.Hive.Server.Core { … … 44 45 } 45 46 47 [MethodImpl(MethodImplOptions.Synchronized)] 46 48 void lifecycleManager_OnServerHeartbeat(object sender, EventArgs e) { 47 49 List<ClientInfo> allClients = new List<ClientInfo>(clientAdapter.GetAll()); 50 List<Job> allJobs = new List<Job>(jobAdapter.GetAll()); 48 51 49 52 foreach (ClientInfo client in allClients) { 50 53 if (client.State != State.offline && client.State != State.nullState) { 54 if (!lastHeartbeats.ContainsKey(client.ClientId)) { 55 client.State = State.offline; 56 clientAdapter.Update(client); 57 } else { 58 DateTime lastHbOfClient = lastHeartbeats[client.ClientId]; 59 int diff = lastHbOfClient.CompareTo(DateTime.Now); 60 Console.WriteLine(diff); 61 } 62 } else { 63 if (lastHeartbeats.ContainsKey(client.ClientId)) 64 lastHeartbeats.Remove(client.ClientId); 65 } 51 66 } 52 67 } … … 54 69 #region IClientCommunicator Members 55 70 71 [MethodImpl(MethodImplOptions.Synchronized)] 56 72 public Response Login(ClientInfo clientInfo) { 57 73 Response response = new Response(); 58 74 75 if (lastHeartbeats.ContainsKey(clientInfo.ClientId)) { 76 lastHeartbeats[clientInfo.ClientId] = DateTime.Now; 77 } else { 78 lastHeartbeats.Add(clientInfo.ClientId, DateTime.Now); 79 } 80 59 81 ICollection<ClientInfo> allClients = clientAdapter.GetAll(); 60 82 ClientInfo client = clientAdapter.GetById(clientInfo.ClientId); 61 if (client != null && client.State != State.offline ) {83 if (client != null && client.State != State.offline && client.State != State.nullState) { 62 84 response.Success = false; 63 85 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_LOGIN_USER_ALLREADY_ONLINE; 64 86 return response; 65 87 } 88 clientInfo.State = State.idle; 66 89 clientAdapter.Update(clientInfo); 67 90 response.Success = true; … … 71 94 } 72 95 96 [MethodImpl(MethodImplOptions.Synchronized)] 73 97 public ResponseHB SendHeartBeat(HeartBeatData hbData) { 74 98 ResponseHB response = new ResponseHB(); 99 100 response.ActionRequest = new List<MessageContainer>(); 101 if (clientAdapter.GetById(hbData.ClientId).State == State.offline || 102 clientAdapter.GetById(hbData.ClientId).State == State.nullState) { 103 response.Success = false; 104 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_USER_NOT_LOGGED_IN; 105 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.NoMessage)); 106 return response; 107 } 75 108 76 109 if (lastHeartbeats.ContainsKey(hbData.ClientId)) { … … 82 115 response.Success = true; 83 116 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_HARDBEAT_RECEIVED; 84 response.ActionRequest = new List<MessageContainer>();85 117 List<Job> allOfflineJobs = new List<Job>(jobAdapter.GetJobsByState(State.offline)); 86 118 if (allOfflineJobs.Count > 0 && hbData.freeCores > 0) … … 146 178 return response; 147 179 } 148 180 181 [MethodImpl(MethodImplOptions.Synchronized)] 149 182 public Response Logout(Guid clientId) { 150 183 Response response = new Response(); 151 184 185 if (lastHeartbeats.ContainsKey(clientId)) 186 lastHeartbeats.Remove(clientId); 187 152 188 ClientInfo client = clientAdapter.GetById(clientId); 153 189 if (client == null) {
Note: See TracChangeset
for help on using the changeset viewer.