Changeset 3220 for trunk/sources/HeuristicLab.Hive.Server.Core
- Timestamp:
- 03/25/10 19:57:44 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Hive.Server.Core/3.2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs
r3203 r3220 41 41 using Linq = HeuristicLab.Hive.Server.LINQDataAccess; 42 42 using System.Transactions; 43 using HeuristicLab.Hive.Server.LINQDataAccess; 43 44 44 45 namespace HeuristicLab.Hive.Server.Core { … … 107 108 " wasn't offline but hasn't sent heartbeats - Resetting all his jobs"); 108 109 foreach (JobDto job in DaoLocator.JobDao.FindActiveJobsOfClient(client)) { 109 jobManager.ResetJobsDependingOnResults(job); 110 //maybe implementa n additional Watchdog? Till then, just set them offline.. 111 DaoLocator.JobDao.SetJobOffline(job); 112 //jobManager.ResetJobsDependingOnResults(job); 110 113 } 111 114 } else { … … 193 196 heartbeatLock.ExitWriteLock(); 194 197 198 ClientDto dbClient = DaoLocator.ClientDao.FindById(clientInfo.Id); 199 200 //Really set offline? 201 //Reconnect issues with the currently calculating jobs 195 202 clientInfo.State = State.idle; 196 197 if (DaoLocator.ClientDao.FindById(clientInfo.Id) == null) 203 clientInfo.CalendarSyncStatus = dbClient != null ? dbClient.CalendarSyncStatus : CalendarState.NotAllowedToFetch; 204 205 if (dbClient == null) 198 206 DaoLocator.ClientDao.Insert(clientInfo); 199 207 else … … 336 344 private void processJobProcess(HeartBeatData hbData, ResponseHB response) { 337 345 HiveLogger.Info(this.ToString() + " processJobProcess: Started for Client " + hbData.ClientId); 338 339 if (hbData.JobProgress != null && hbData.JobProgress.Count > 0) { 340 List<JobDto> jobsOfClient = new List<JobDto>(DaoLocator.JobDao.FindActiveJobsOfClient(DaoLocator.ClientDao.FindById(hbData.ClientId))); 346 List<JobDto> jobsOfClient = new List<JobDto>(DaoLocator.JobDao.FindActiveJobsOfClient(DaoLocator.ClientDao.FindById(hbData.ClientId))); 347 if (hbData.JobProgress != null && hbData.JobProgress.Count > 0) { 341 348 if (jobsOfClient == null || jobsOfClient.Count == 0) { 342 349 response.Success = false; … … 369 376 DaoLocator.JobDao.Update(curJob); 370 377 } 371 foreach (JobDto currJob in jobsOfClient) { 372 bool found = false; 378 } 379 foreach (JobDto currJob in jobsOfClient) { 380 bool found = false; 381 if(hbData.JobProgress != null) { 373 382 foreach (Guid jobId in hbData.JobProgress.Keys) { 374 383 if (jobId == currJob.Id) { … … 377 386 } 378 387 } 379 if (!found) { 380 lock (newAssignedJobs) { 381 if (newAssignedJobs.ContainsKey(currJob.Id)) { 382 newAssignedJobs[currJob.Id]--; 383 HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL Reduced by one for job: " + currJob + "and is now: " + newAssignedJobs[currJob.Id] + ". User that sucks: " + currJob.Client); 384 if (newAssignedJobs[currJob.Id] <= 0) { 385 HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL reached Zero, Job gets removed: " + currJob + " and set back to offline. User that sucks: " + currJob.Client); 386 387 currJob.State = State.offline; 388 DaoLocator.JobDao.Update(currJob); 389 390 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, currJob.Id)); 391 392 newAssignedJobs.Remove(currJob.Id); 393 } 394 } else { 395 HiveLogger.Error(this.ToString() + " processJobProcess: Job ID wasn't with the heartbeats: " + currJob); 388 } 389 if (!found) { 390 lock (newAssignedJobs) { 391 if (newAssignedJobs.ContainsKey(currJob.Id)) { 392 newAssignedJobs[currJob.Id]--; 393 HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL Reduced by one for job: " + currJob + "and is now: " + newAssignedJobs[currJob.Id] + ". User that sucks: " + currJob.Client); 394 if (newAssignedJobs[currJob.Id] <= 0) { 395 HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL reached Zero, Job gets removed: " + currJob + " and set back to offline. User that sucks: " + currJob.Client); 396 396 397 currJob.State = State.offline; 397 398 DaoLocator.JobDao.Update(currJob); 398 } 399 } // lock 400 } else { 401 lock (newAssignedJobs) { 402 403 if (newAssignedJobs.ContainsKey(currJob.Id)) { 404 HiveLogger.Info(this.ToString() + " processJobProcess: Job is sending a heart beat, removing it from the newAssignedJobList: " + currJob); 399 400 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, currJob.Id)); 401 405 402 newAssignedJobs.Remove(currJob.Id); 406 403 } 404 } else { 405 HiveLogger.Error(this.ToString() + " processJobProcess: Job ID wasn't with the heartbeats: " + currJob); 406 currJob.State = State.offline; 407 DaoLocator.JobDao.Update(currJob); 408 } 409 } // lock 410 } else { 411 lock (newAssignedJobs) { 412 413 if (newAssignedJobs.ContainsKey(currJob.Id)) { 414 HiveLogger.Info(this.ToString() + " processJobProcess: Job is sending a heart beat, removing it from the newAssignedJobList: " + currJob); 415 newAssignedJobs.Remove(currJob.Id); 407 416 } 408 417 } -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientFacade.cs
r3203 r3220 32 32 using System.ServiceModel; 33 33 using HeuristicLab.Hive.Server.Core.InternalInterfaces; 34 using System.Transactions; 34 35 35 36 namespace HeuristicLab.Hive.Server.Core { … … 103 104 new MultiStream(); 104 105 105 ResponseJob job = 106 this.SendJob(clientId); 106 ResponseJob job = null; 107 108 job = this.SendJob(clientId); 107 109 108 110 //first send response … … 114 116 115 117 //second stream the job binary data 116 stream.AddStream( 117 ((IInternalJobManager)(jobManager)). 118 GetJobStreamById( 119 job.Job.Id)); 120 118 119 if(job.Job != null) 120 stream.AddStream( 121 ((IInternalJobManager) (jobManager)). 122 GetJobStreamById( 123 job.Job.Id)); 124 121 125 OperationContext clientContext = OperationContext.Current; 122 126 clientContext.OperationCompleted += new EventHandler(delegate(object sender, EventArgs args) { -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/DbTestApp.cs
r3011 r3220 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Data.SqlClient; 24 25 using System.Text; 25 26 using HeuristicLab.PluginInfrastructure; … … 35 36 using HeuristicLab.Core; 36 37 using HeuristicLab.Hive.Server.LINQDataAccess; 38 using System.Transactions; 37 39 38 40 namespace HeuristicLab.Hive.Server { 39 41 [Application("Hive DB Test App", "Test Application for the Hive DataAccess Layer")] 40 42 class HiveDbTestApplication : ApplicationBase { 41 /* private void TestClientAdapter() { 42 IClientAdapter clientAdapter = 43 ServiceLocator.GetClientAdapter(); 44 45 ClientInfo client = new ClientInfo(); 46 client.Login = DateTime.Now; 47 clientAdapter.Update(client); 48 49 ClientInfo clientRead = 50 clientAdapter.GetById(client.Id); 51 Debug.Assert( 52 clientRead != null && 53 client.Id == clientRead.Id); 54 55 client.CpuSpeedPerCore = 2000; 56 clientAdapter.Update(client); 57 clientRead = 58 clientAdapter.GetById(client.Id); 59 Debug.Assert( 60 clientRead != null && 61 client.Id == clientRead.Id && 62 clientRead.CpuSpeedPerCore == 2000); 63 64 ICollection<ClientInfo> clients = 65 clientAdapter.GetAll(); 66 int count = clients.Count; 67 68 clientAdapter.Delete(client); 69 70 clients = clientAdapter.GetAll(); 71 Debug.Assert(count - 1 == clients.Count); 72 } 73 74 private void TestClientGroupAdapter() { 75 ISessionFactory factory = 76 ServiceLocator.GetSessionFactory(); 77 78 ISession session = 79 factory.GetSessionForCurrentThread(); 80 81 ITransaction trans = null; 82 83 try { 84 IClientGroupAdapter clientGroupAdapter = 85 session.GetDataAdapter<ClientGroup, IClientGroupAdapter>(); 86 87 trans = 88 session.BeginTransaction(); 89 90 ClientInfo client = 91 new ClientInfo(); 92 client.Name = "Stefan"; 93 client.Login = DateTime.Now; 94 95 ClientInfo client2 = 96 new ClientInfo(); 97 client2.Name = "Martin"; 98 client2.Login = DateTime.Now; 99 100 ClientInfo client3 = 101 new ClientInfo(); 102 client3.Name = "Heinz"; 103 client3.Login = DateTime.Now; 104 105 ClientGroup group = 106 new ClientGroup(); 107 108 ClientGroup subGroup = 109 new ClientGroup(); 110 subGroup.Resources.Add(client); 111 112 group.Resources.Add(client3); 113 group.Resources.Add(client2); 114 group.Resources.Add(subGroup); 115 116 clientGroupAdapter.Update(group); 117 118 ClientGroup read = 119 clientGroupAdapter.GetById(group.Id); 120 121 ICollection<ClientGroup> clientGroups = 122 clientGroupAdapter.GetAll(); 123 124 IClientAdapter clientAdapter = 125 session.GetDataAdapter<ClientInfo, IClientAdapter>(); 126 127 clientAdapter.Delete(client3); 128 129 read = 130 clientGroupAdapter.GetById(group.Id); 131 132 clientGroupAdapter.Delete(subGroup); 133 134 read = 135 clientGroupAdapter.GetById(group.Id); 136 137 clientGroups = 138 clientGroupAdapter.GetAll(); 139 140 clientGroupAdapter.Delete(group); 141 142 clientGroups = 143 clientGroupAdapter.GetAll(); 144 145 clientAdapter.Delete(client); 146 clientAdapter.Delete(client2); 147 } 148 finally { 149 if (trans != null) 150 trans.Rollback(); 151 152 session.EndSession(); 153 } 154 } 155 156 private void InsertTestClientGroups() { 157 ISessionFactory factory = 158 ServiceLocator.GetSessionFactory(); 159 160 ISession session = 161 factory.GetSessionForCurrentThread(); 162 163 ITransaction trans = null; 164 165 try { 166 IClientGroupAdapter clientGroupAdapter = 167 session.GetDataAdapter<ClientGroup, IClientGroupAdapter>(); 168 169 trans = 170 session.BeginTransaction(); 171 172 ClientInfo client = 173 new ClientInfo(); 174 client.Name = "Stefan"; 175 client.Login = DateTime.Now; 176 177 ClientInfo client2 = 178 new ClientInfo(); 179 client2.Name = "Martin"; 180 client2.Login = DateTime.Now; 181 182 ClientGroup group = 183 new ClientGroup(); 184 group.Name = "Gruppe1"; 185 186 ClientGroup subGroup = 187 new ClientGroup(); 188 subGroup.Name = "Untergruppe1"; 189 subGroup.Resources.Add(client); 190 191 group.Resources.Add(client2); 192 group.Resources.Add(subGroup); 193 194 clientGroupAdapter.Update(group); 195 196 trans.Commit(); 197 } 198 finally { 199 session.EndSession(); 200 } 201 } 202 203 private void TestJobAdapter() { 204 IJobAdapter jobAdapter = 205 ServiceLocator.GetJobAdapter(); 206 IClientAdapter clientAdapter = 207 ServiceLocator.GetClientAdapter(); 208 209 Job job = new Job(); 210 211 ClientInfo client = new ClientInfo(); 212 client.Login = DateTime.Now; 213 214 job.Client = client; 215 jobAdapter.Update(job); 216 217 ICollection<Job> jobs = jobAdapter.GetAll(); 218 219 jobAdapter.Delete(job); 220 clientAdapter.Delete(client); 221 222 jobs = jobAdapter.GetAll(); 223 } 224 225 private void TestJobResultsAdapter() { 226 Job job = new Job(); 227 228 ClientInfo client = new ClientInfo(); 229 client.Login = DateTime.Now; 230 231 job.Client = client; 232 233 IJobResultsAdapter resultsAdapter = 234 ServiceLocator.GetJobResultsAdapter(); 235 236 byte[] resultByte = {0x0f, 0x1f, 0x2f, 0x3f, 0x4f}; 237 238 JobResult result = new JobResult(); 239 result.Client = client; 240 result.Job = job; 241 result.Result = resultByte; 242 243 resultsAdapter.Update(result); 244 245 JobResult read = 246 resultsAdapter.GetById(result.Id); 247 Debug.Assert( 248 read.Id == result.Id && 249 result.Client.Id == read.Client.Id && 250 result.Job.Id == read.Job.Id && 251 result.Result == result.Result); 252 253 int count = 254 resultsAdapter.GetAll().Count; 255 256 resultsAdapter.Delete(result); 257 258 ICollection<JobResult> allResults = 259 resultsAdapter.GetAll(); 260 261 Debug.Assert(allResults.Count == count - 1); 262 263 IJobAdapter jboAdapter = 264 ServiceLocator.GetJobAdapter(); 265 jboAdapter.Delete(job); 266 IClientAdapter clientAdapter = 267 ServiceLocator.GetClientAdapter(); 268 clientAdapter.Delete(client); 269 } 270 271 private void TestTransaction() { 272 ISessionFactory factory = 273 ServiceLocator.GetSessionFactory(); 274 275 ISession session = 276 factory.GetSessionForCurrentThread(); 277 278 IClientAdapter clientAdapter = 279 session.GetDataAdapter<ClientInfo, IClientAdapter>(); 280 281 ITransaction trans = 282 session.BeginTransaction(); 283 284 ClientInfo client = new ClientInfo(); 285 client.Login = DateTime.Now; 286 clientAdapter.Update(client); 287 288 trans.Rollback(); 289 290 session.EndSession(); 291 } */ 292 293 private void TestJobStreaming() { 43 /*private void TestJobStreaming() { 294 44 ISessionFactory factory = 295 45 ServiceLocator.GetSessionFactory(); … … 489 239 490 240 //SpeedTest(); 491 TestJobBytearrFetching(); 492 241 //TestJobBytearrFetching(); 242 TestJobStreamFetching(); 243 244 } 245 246 private void TestJobStreamFetching() { 247 //using (TransactionScope scope = new TransactionScope()) { 248 HiveDataContext context = ContextFactory.Context; 249 250 ContextFactory.Context.Connection.Open(); 251 ContextFactory.Context.Transaction = ContextFactory.Context.Connection.BeginTransaction(); 252 253 ClientFacade facade = new ClientFacade(); 254 Stream stream = facade.SendStreamedJob(new Guid("F5CFB334-66A0-417C-A585-71711BA21D3F")); 255 256 byte[] buffer = new byte[3024]; 257 int read = 0; 258 259 while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) {} 260 261 stream.Close(); 262 263 //Stream stream = DaoLocator.JobDao.GetSerializedJobStream(new Guid("bbb51f87-4e2f-4499-a9b6-884e589c78b6")); 264 //} 493 265 } 494 266 -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ExecutionEngineFacade.cs
r3011 r3220 44 44 } 45 45 46 public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) { 47 return jobManager.AddJobWithGroupStrings(job, resources); 48 } 49 46 50 public Response RequestSnapshot(Guid jobId) { 47 51 return jobManager.RequestSnapshot(jobId); -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/JobManager.cs
r3018 r3220 34 34 using HeuristicLab.Tracing; 35 35 using System.Transactions; 36 using HeuristicLab.Hive.Server.LINQDataAccess; 36 37 37 38 namespace HeuristicLab.Hive.Server.Core { … … 149 150 } 150 151 } */ 152 153 public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) { 154 IClientGroupDao cgd = DaoLocator.ClientGroupDao; 155 foreach (string res in resources) { 156 foreach(ClientGroupDto cg in cgd.FindByName(res)) { 157 job.JobInfo.AssignedResourceIds.Add(cg.Id); 158 } 159 } 160 return AddNewJob(job); 161 } 151 162 152 163 /// <summary> -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs
r3203 r3220 180 180 } 181 181 182 public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) { 183 return jobManager.AddJobWithGroupStrings(job, resources); 184 } 182 185 } 183 186 }
Note: See TracChangeset
for help on using the changeset viewer.