Changeset 2082
- Timestamp:
- 06/23/09 11:35:41 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/sources/HeuristicLab.DataAccess.ADOHelper/3.2/DataAdapterBase.cs ¶
r2004 r2082 82 82 83 83 protected delegate IEnumerable<RowT> Selector(); 84 protected delegate object TransactionalAction(); 84 85 85 86 protected ObjT Convert(RowT row, ObjT obj) { … … 109 110 110 111 protected ObjT FindSingle(Selector selector) { 111 ITransaction trans = 112 session.GetCurrentTransaction(); 113 bool transactionExists = trans != null; 114 if (!transactionExists) { 115 trans = session.BeginTransaction(); 116 } 117 118 try { 119 RowT row = FindSingleRow(selector); 120 121 ObjT result; 122 if (row != null) { 123 ObjT obj = new ObjT(); 124 obj = Convert(row, obj); 125 126 result = obj; 127 } else { 128 result = default(ObjT); 129 } 130 131 return result; 132 } 133 finally { 134 if (!transactionExists && trans != null) { 135 trans.Commit(); 136 } 137 } 112 return 113 (ObjT)doInTransaction( 114 delegate() { 115 RowT row = FindSingleRow(selector); 116 117 ObjT result; 118 if (row != null) { 119 ObjT obj = new ObjT(); 120 obj = Convert(row, obj); 121 122 result = obj; 123 } else { 124 result = default(ObjT); 125 } 126 127 return result; 128 }); 138 129 } 139 130 140 131 private ICollection<ObjT> FindMultiple(Selector selector, 141 132 int from, int size) { 142 ITransaction trans = 143 session.GetCurrentTransaction(); 144 bool transactionExists = trans != null; 145 if (!transactionExists) { 146 trans = session.BeginTransaction(); 147 } 148 149 try { 150 IEnumerable<RowT> found = 151 selector(); 152 153 if (from > 0 && size > 0) 154 found = found.Skip<RowT>(from).Take<RowT>(size); 155 156 IList<ObjT> result = 157 new List<ObjT>(); 158 159 foreach (RowT row in found) { 160 ObjT obj = new ObjT(); 161 obj = Convert(row, obj); 162 if (obj != null) 163 result.Add(obj); 164 } 165 166 return result; 167 } 168 finally { 169 if (!transactionExists && trans != null) { 170 trans.Commit(); 171 } 172 } 133 return (ICollection<ObjT>)doInTransaction( 134 delegate() { 135 IEnumerable<RowT> found = 136 selector(); 137 138 if (from > 0 && size > 0) 139 found = found.Skip<RowT>(from).Take<RowT>(size); 140 141 IList<ObjT> result = 142 new List<ObjT>(); 143 144 foreach (RowT row in found) { 145 ObjT obj = new ObjT(); 146 obj = Convert(row, obj); 147 if (obj != null) 148 result.Add(obj); 149 } 150 151 return result; 152 }); 173 153 } 174 154 … … 185 165 } 186 166 187 protected virtual void doUpdate(ObjT obj) { 188 if (obj != null) { 189 RowT row = null; 190 191 if (obj.Id != Guid.Empty) { 192 row = GetRowById(obj.Id); 193 } else { 194 obj.Id = Guid.NewGuid(); 195 } 196 197 if (row == null) { 198 row = dataAdapter.InsertNewRow(obj); 199 } 200 201 ConvertObj(obj, row); 202 dataAdapter.UpdateRow(row); 203 } 204 } 205 206 public void Update(ObjT obj) { 167 protected object doInTransaction(TransactionalAction action) { 207 168 ITransaction trans = 208 169 session.GetCurrentTransaction(); … … 213 174 214 175 try { 215 doUpdate(obj); 176 bool result = (bool)action(); 177 178 if (!transactionExists && trans != null) { 179 trans.Commit(); 180 } 181 182 return result; 183 } 184 catch (Exception e) { 185 if (!transactionExists && trans != null) { 186 trans.Rollback(); 187 } 188 189 throw e; 190 } 191 } 192 193 protected virtual void doUpdate(ObjT obj) { 194 if (obj != null) { 195 RowT row = null; 196 197 if (obj.Id != Guid.Empty) { 198 row = GetRowById(obj.Id); 199 } else { 200 obj.Id = Guid.NewGuid(); 201 } 202 203 if (row == null) { 204 row = dataAdapter.InsertNewRow(obj); 205 } 206 207 ConvertObj(obj, row); 208 dataAdapter.UpdateRow(row); 209 } 210 } 211 212 public void Update(ObjT obj) { 213 try { 214 doInTransaction( 215 delegate() { 216 doUpdate(obj); 217 return true; 218 }); 216 219 } 217 220 catch (DBConcurrencyException ex) { … … 234 237 //otherwise: row was deleted in the meantime - nothing to do 235 238 } 236 finally {237 if (!transactionExists && trans != null) {238 trans.Commit();239 }240 }241 239 } 242 240 … … 282 280 283 281 public bool Delete(ObjT obj) { 284 ITransaction trans =285 session.GetCurrentTransaction();286 bool transactionExists = trans != null;287 if (!transactionExists) {288 trans = session.BeginTransaction();289 }290 291 282 try { 292 return doDelete(obj); 283 return (bool)doInTransaction( 284 delegate() { 285 return doDelete(obj); 286 }); 293 287 } 294 288 catch (DBConcurrencyException) { … … 303 297 } 304 298 } 305 finally {306 if (!transactionExists && trans != null) {307 trans.Commit();308 }309 }310 299 } 311 300 } -
TabularUnified trunk/sources/HeuristicLab.Grid.HiveBridge/3.2/HiveGridServerWrapper.cs ¶
r2078 r2082 89 89 } 90 90 91 private HeuristicLab.Hive.Contracts.BusinessObjects. Job CreateJobObj(byte[] serializedEngine) {91 private HeuristicLab.Hive.Contracts.BusinessObjects.ComputableJob CreateJobObj(byte[] serializedEngine) { 92 92 HeuristicLab.Hive.Contracts.BusinessObjects.Job jobObj = new HeuristicLab.Hive.Contracts.BusinessObjects.Job(); 93 93 … … 111 111 stream.Close(); 112 112 113 jobObj.SerializedJob = memStream.ToArray(); 113 ComputableJob computableJob = 114 new ComputableJob(); 115 computableJob.SerializedJob = memStream.ToArray(); 114 116 jobObj.CoresNeeded = 1; 115 117 jobObj.PluginsNeeded = requiredPlugins; 116 118 jobObj.State = HeuristicLab.Hive.Contracts.BusinessObjects.State.offline; 117 return jobObj; 119 120 computableJob.JobInfo = jobObj; 121 122 return computableJob; 118 123 } 119 124 -
TabularUnified trunk/sources/HeuristicLab.Hive.Client.Core/3.2/Core.cs ¶
r2068 r2082 297 297 bool sandboxed = false; 298 298 List<byte[]> files = new List<byte[]>(); 299 foreach (CachedHivePluginInfo plugininfo in PluginCache.Instance.GetPlugins(e.Result.Job. PluginsNeeded))299 foreach (CachedHivePluginInfo plugininfo in PluginCache.Instance.GetPlugins(e.Result.Job.JobInfo.PluginsNeeded)) 300 300 files.AddRange(plugininfo.PluginFiles); 301 302 AppDomain appDomain = PluginManager.Manager.CreateAndInitAppDomainWithSandbox(e.Result.Job. Id.ToString(), sandboxed, null, files);301 302 AppDomain appDomain = PluginManager.Manager.CreateAndInitAppDomainWithSandbox(e.Result.Job.JobInfo.Id.ToString(), sandboxed, null, files); 303 303 appDomain.UnhandledException += new UnhandledExceptionEventHandler(appDomain_UnhandledException); 304 lock (engines) { 305 if (!jobs.ContainsKey(e.Result.Job. Id)) {306 jobs.Add(e.Result.Job. Id, e.Result.Job);307 appDomains.Add(e.Result.Job. Id, appDomain);304 lock (engines) { 305 if (!jobs.ContainsKey(e.Result.Job.JobInfo.Id)) { 306 jobs.Add(e.Result.Job.JobInfo.Id, e.Result.Job.JobInfo); 307 appDomains.Add(e.Result.Job.JobInfo.Id, appDomain); 308 308 309 309 Executor engine = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName); 310 engine.JobId = e.Result.Job. Id;310 engine.JobId = e.Result.Job.JobInfo.Id; 311 311 engine.Queue = MessageQueue.GetInstance(); 312 312 engine.Start(e.Result.Job.SerializedJob); 313 engines.Add(e.Result.Job. Id, engine);313 engines.Add(e.Result.Job.JobInfo.Id, engine); 314 314 315 315 ClientStatusInfo.JobsFetched++; -
TabularUnified trunk/sources/HeuristicLab.Hive.Contracts/3.2/BusinessObjects/Job.cs ¶
r1951 r2082 44 44 public double Percentage { get; set; } 45 45 [DataMember] 46 public byte[] SerializedJob { get; set; }47 [DataMember]48 46 public DateTime DateCreated { get; set; } 49 47 [DataMember] -
TabularUnified trunk/sources/HeuristicLab.Hive.Contracts/3.2/HeuristicLab.Hive.Contracts-3.2.csproj ¶
r1939 r2082 89 89 <Compile Include="BusinessObjects\CachedHivePluginInfo.cs" /> 90 90 <Compile Include="BusinessObjects\ClientGroup.cs" /> 91 <Compile Include="BusinessObjects\ComputableJob.cs" /> 91 92 <Compile Include="BusinessObjects\Project.cs" /> 92 93 <Compile Include="BusinessObjects\HivePluginInfo.cs" /> -
TabularUnified trunk/sources/HeuristicLab.Hive.Contracts/3.2/Interfaces/IExecutionEngineFacade.cs ¶
r1509 r2082 31 31 public interface IExecutionEngineFacade { 32 32 [OperationContract] 33 ResponseObject<Job> AddJob( Job job);33 ResponseObject<Job> AddJob(ComputableJob job); 34 34 [OperationContract] 35 35 Response RequestSnapshot(Guid jobId); -
TabularUnified trunk/sources/HeuristicLab.Hive.Contracts/3.2/Interfaces/IJobManager.cs ¶
r2005 r2082 38 38 ResponseObject<Job> GetJobById(Guid jobId); 39 39 [OperationContract] 40 ResponseObject<Job> AddNewJob( Job job);40 ResponseObject<Job> AddNewJob(ComputableJob job); 41 41 [OperationContract] 42 42 Response RemoveJob(Guid jobId); -
TabularUnified trunk/sources/HeuristicLab.Hive.Contracts/3.2/ResponseJob.cs ¶
r1939 r2082 37 37 public class ResponseJob : Response { 38 38 [DataMember] 39 public Job Job { get; set; }39 public ComputableJob Job { get; set; } 40 40 } 41 41 } -
TabularUnified trunk/sources/HeuristicLab.Hive.Contracts/3.2/WcfSettings.cs ¶
r2071 r2082 25 25 NetTcpBinding binding = new NetTcpBinding(); 26 26 #endif 27 binding.MaxBufferSize = int.MaxValue;27 /*binding.MaxBufferSize = int.MaxValue; 28 28 binding.MaxReceivedMessageSize = int.MaxValue; 29 29 binding.ReaderQuotas.MaxArrayLength = int.MaxValue; 30 binding.ReaderQuotas.MaxStringContentLength = int.MaxValue; 30 binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;*/ 31 31 binding.CloseTimeout = new TimeSpan(0, 5, 0); 32 32 binding.ReceiveTimeout = new TimeSpan(0, 5, 0); -
TabularUnified trunk/sources/HeuristicLab.Hive.Engine/3.2/HiveEngine.cs ¶
r2032 r2082 193 193 } 194 194 195 private HeuristicLab.Hive.Contracts.BusinessObjects.Job CreateJobObj() { 196 HeuristicLab.Hive.Contracts.BusinessObjects.Job jobObj = new HeuristicLab.Hive.Contracts.BusinessObjects.Job(); 195 private HeuristicLab.Hive.Contracts.BusinessObjects.ComputableJob CreateJobObj() { 196 HeuristicLab.Hive.Contracts.BusinessObjects.Job jobObj = 197 new HeuristicLab.Hive.Contracts.BusinessObjects.Job(); 197 198 198 199 MemoryStream memStream = new MemoryStream(); … … 205 206 document.Save(stream); 206 207 stream.Close(); 207 jobObj.SerializedJob = memStream.ToArray(); 208 209 HeuristicLab.Hive.Contracts.BusinessObjects.ComputableJob executableJobObj = 210 new HeuristicLab.Hive.Contracts.BusinessObjects.ComputableJob(); 211 executableJobObj.JobInfo = jobObj; 212 executableJobObj.SerializedJob = memStream.ToArray(); 208 213 209 214 DiscoveryService service = new DiscoveryService(); … … 234 239 jobObj.PluginsNeeded = pluginsNeeded; 235 240 jobObj.State = HeuristicLab.Hive.Contracts.BusinessObjects.State.offline; 236 return jobObj;241 return executableJobObj; 237 242 } 238 243 -
TabularUnified trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/ClientAdapter.cs ¶
r1999 r2082 189 189 190 190 public ClientInfo GetByName(string name) { 191 ClientInfo client = new ClientInfo(); 192 Resource res = 193 ResAdapter.GetByName(name); 194 195 return GetById(res.Id); 191 return (ClientInfo) 192 base.doInTransaction( 193 delegate() { 194 ClientInfo client = new ClientInfo(); 195 Resource res = 196 ResAdapter.GetByName(name); 197 198 return GetById(res.Id); 199 }); 196 200 } 197 201 198 202 protected override bool doDelete(ClientInfo client) { 199 bool success = false; 200 201 if (client != null) { 202 dsHiveServer.ClientRow row = 203 GetRowById(client.Id); 204 205 if (row != null) { 206 success = base.doDelete(client) && 207 ResAdapter.Delete(client); 208 } 209 } 210 211 return success; 203 return (bool)base.doInTransaction( 204 delegate() { 205 bool success = false; 206 207 if (client != null) { 208 dsHiveServer.ClientRow row = 209 GetRowById(client.Id); 210 211 if (row != null) { 212 success = base.doDelete(client) && 213 ResAdapter.Delete(client); 214 } 215 } 216 217 return success; 218 }); 212 219 } 213 220 -
TabularUnified trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/JobAdapter.cs ¶
r2066 r2082 166 166 job.Percentage = 0.0; 167 167 168 if (!row.IsSerializedJobNull())169 job.SerializedJob = row.SerializedJob;170 else171 job.SerializedJob = null;172 173 168 if (!row.IsDateCreatedNull()) 174 169 job.DateCreated = row.DateCreated; … … 255 250 256 251 row.Percentage = job.Percentage; 257 258 row.SerializedJob = job.SerializedJob;259 252 260 253 if (job.DateCreated != DateTime.MinValue) … … 422 415 } 423 416 417 /// <summary> 418 /// Gets the computable job with the secified jobId 419 /// </summary> 420 /// <param name="jobId"></param> 421 /// <returns></returns> 422 public ComputableJob GetComputableJob(Guid jobId) { 423 return (ComputableJob)base.doInTransaction( 424 delegate() { 425 ComputableJob job = 426 new ComputableJob(); 427 428 job.JobInfo = GetById(jobId); 429 dsHiveServer.JobRow row 430 = GetRowById(jobId); 431 432 if (job.JobInfo != null && row != null && 433 !row.IsSerializedJobNull()) { 434 435 job.SerializedJob = 436 row.SerializedJob; 437 438 return job; 439 } else { 440 return null; 441 } 442 }); 443 } 444 445 /// <summary> 446 /// Saves or update the computable job 447 /// </summary> 448 /// <param name="jobId"></param> 449 public void UpdateComputableJob(ComputableJob job) { 450 if(job != null && 451 job.JobInfo != null) { 452 base.doInTransaction( 453 delegate() { 454 dsHiveServer.JobRow row 455 = GetRowById(job.JobInfo.Id); 456 457 if (row != null) { 458 Update(job.JobInfo); 459 row.SerializedJob = 460 job.SerializedJob; 461 462 base.Adapter.Update(row); 463 } 464 465 return true; 466 }); 467 } 468 469 } 470 424 471 #endregion 425 472 } -
TabularUnified trunk/sources/HeuristicLab.Hive.Server.Console/3.2/AddJobForm.cs ¶
r2026 r2082 128 128 job.AssignedResourceIds = groupsToCalculate; 129 129 } 130 job.SerializedJob = PersistenceManager.SaveToGZip(new TestJob()); 131 Response resp = jobManager.AddNewJob(job); 130 131 ComputableJob computableJob = 132 new ComputableJob(); 133 computableJob.JobInfo = job; 134 computableJob.SerializedJob = PersistenceManager.SaveToGZip(new TestJob()); 135 Response resp = jobManager.AddNewJob(computableJob); 132 136 } 133 137 if (addJobEvent != null) { -
TabularUnified trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs ¶
r2022 r2082 371 371 /// <returns></returns> 372 372 public ResponseJob SendJob(Guid clientId) { 373 ResponseJob response = new ResponseJob(); 374 375 Job job2Calculate = scheduler.GetNextJobForClient(clientId); 376 if (job2Calculate != null) { 377 response.Job = job2Calculate; 378 response.Success = true; 379 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED; 380 lock (newAssignedJobs) { 381 newAssignedJobs.Add(job2Calculate.Id, ApplicationConstants.JOB_TIME_TO_LIVE); 382 } 383 } else { 384 response.Success = false; 385 response.Job = null; 386 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT; 387 } 388 return response; 373 ISession session = factory.GetSessionForCurrentThread(); 374 ITransaction tx = null; 375 376 try { 377 IJobAdapter jobAdapter = 378 session.GetDataAdapter<Job, IJobAdapter>(); 379 380 tx = session.BeginTransaction(); 381 382 ResponseJob response = new ResponseJob(); 383 384 Job job2Calculate = scheduler.GetNextJobForClient(clientId); 385 if (job2Calculate != null) { 386 ComputableJob computableJob = 387 jobAdapter.GetComputableJob(job2Calculate.Id); 388 389 response.Job = computableJob; 390 response.Success = true; 391 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED; 392 lock (newAssignedJobs) { 393 newAssignedJobs.Add(job2Calculate.Id, ApplicationConstants.JOB_TIME_TO_LIVE); 394 } 395 } else { 396 response.Success = false; 397 response.Job = null; 398 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT; 399 } 400 401 return response; 402 } 403 catch (Exception ex) { 404 if (tx != null) 405 tx.Rollback(); 406 throw ex; 407 } 408 finally { 409 if (session != null) 410 session.EndSession(); 411 } 389 412 } 390 413 … … 412 435 clientAdapter.GetById(clientId); 413 436 414 Job job = 415 jobAdapter.GetById(jobId); 437 ComputableJob job = 438 new ComputableJob(); 439 440 if (job != null) { 441 job.JobInfo = 442 jobAdapter.GetById(jobId); 443 } 416 444 417 if (job == null ) {445 if (job == null && job.JobInfo != null) { 418 446 response.Success = false; 419 447 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOB_WITH_THIS_ID; … … 421 449 return response; 422 450 } 423 if (job. State == State.abort) {451 if (job.JobInfo.State == State.abort) { 424 452 response.Success = false; 425 453 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_WAS_ABORTED; 426 454 } 427 if (job. Client == null) {455 if (job.JobInfo.Client == null) { 428 456 response.Success = false; 429 457 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED; … … 431 459 return response; 432 460 } 433 if (job. Client.Id != clientId) {461 if (job.JobInfo.Client.Id != clientId) { 434 462 response.Success = false; 435 463 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_CLIENT_FOR_JOB; … … 437 465 return response; 438 466 } 439 if (job. State == State.finished) {467 if (job.JobInfo.State == State.finished) { 440 468 response.Success = true; 441 469 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOBRESULT_RECEIVED; … … 443 471 return response; 444 472 } 445 if (job.State == State.requestSnapshotSent) { 446 job.State = State.calculating; 447 } 448 if (job.State != State.calculating && job.State != State.pending) { 473 if (job.JobInfo.State == State.requestSnapshotSent) { 474 job.JobInfo.State = State.calculating; 475 } 476 if (job.JobInfo.State != State.calculating && 477 job.JobInfo.State != State.pending) { 449 478 response.Success = false; 450 479 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_JOB_STATE; … … 453 482 } 454 483 job.SerializedJob = result; 455 job. Percentage = percentage;484 job.JobInfo.Percentage = percentage; 456 485 457 486 if (finished) { 458 job.State = State.finished; 459 jobAdapter.Update(job); 460 } 461 List<JobResult> jobResults = new List<JobResult>(jobResultAdapter.GetResultsOf(job)); 487 job.JobInfo.State = State.finished; 488 job.SerializedJob = result; 489 } 490 491 jobAdapter.UpdateComputableJob(job); 492 493 List<JobResult> jobResults = new List<JobResult>( 494 jobResultAdapter.GetResultsOf(job.JobInfo)); 462 495 foreach (JobResult currentResult in jobResults) 463 496 jobResultAdapter.Delete(currentResult); … … 466 499 new JobResult(); 467 500 jobResult.ClientId = client.Id; 468 jobResult.JobId = job. Id;501 jobResult.JobId = job.JobInfo.Id; 469 502 jobResult.Result = result; 470 503 jobResult.Percentage = percentage; … … 473 506 474 507 jobResultAdapter.Update(jobResult); 475 jobAdapter.Update(job );508 jobAdapter.Update(job.JobInfo); 476 509 477 510 response.Success = true; -
TabularUnified trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ExecutionEngineFacade.cs ¶
r1530 r2082 36 36 #region IExecutionEngineFacade Members 37 37 38 public ResponseObject<Job> AddJob( Job job) {38 public ResponseObject<Job> AddJob(ComputableJob job) { 39 39 return jobManager.AddNewJob(job); 40 40 } -
TabularUnified trunk/sources/HeuristicLab.Hive.Server.Core/3.2/JobManager.cs ¶
r2005 r2082 73 73 public void ResetJobsDependingOnResults(Job job) { 74 74 ISession session = factory.GetSessionForCurrentThread(); 75 ITransaction tx = null; 75 76 76 77 try { … … 78 79 session.GetDataAdapter<Job, IJobAdapter>(); 79 80 80 JobResult lastJobResult = GetLastJobResult(job); 81 if (lastJobResult != null) { 82 job.Percentage = lastJobResult.Percentage; 83 job.SerializedJob = lastJobResult.Result; 84 } else { 85 job.Percentage = 0; 86 } 87 88 job.Client = null; 89 job.State = State.offline; 90 91 jobAdapter.Update(job); 81 tx = session.BeginTransaction(); 82 83 if (job != null) { 84 ComputableJob computableJob = 85 new ComputableJob(); 86 computableJob.JobInfo = 87 job; 88 89 JobResult lastJobResult = GetLastJobResult(job); 90 if (lastJobResult != null) { 91 computableJob.JobInfo.Percentage = lastJobResult.Percentage; 92 computableJob.SerializedJob = lastJobResult.Result; 93 94 jobAdapter.UpdateComputableJob(computableJob); 95 } else { 96 computableJob.JobInfo.Percentage = 0; 97 } 98 99 computableJob.JobInfo.Client = null; 100 computableJob.JobInfo.State = State.offline; 101 102 jobAdapter.Update(computableJob.JobInfo); 103 } 104 105 tx.Commit(); 106 } 107 catch (Exception ex) { 108 if (tx != null) 109 tx.Rollback(); 110 throw ex; 92 111 } 93 112 finally { … … 185 204 /// <param name="job"></param> 186 205 /// <returns></returns> 187 public ResponseObject<Job> AddNewJob( Job job) {206 public ResponseObject<Job> AddNewJob(ComputableJob job) { 188 207 ISession session = factory.GetSessionForCurrentThread(); 189 208 … … 194 213 ResponseObject<Job> response = new ResponseObject<Job>(); 195 214 196 if (job != null ) {197 if (job. State != State.offline) {215 if (job != null && job.JobInfo != null) { 216 if (job.JobInfo.State != State.offline) { 198 217 response.Success = false; 199 218 response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOBSTATE_MUST_BE_OFFLINE; 200 219 return response; 201 220 } 202 if (job. Id != Guid.Empty) {221 if (job.JobInfo.Id != Guid.Empty) { 203 222 response.Success = false; 204 223 response.StatusMessage = ApplicationConstants.RESPONSE_JOB_ID_MUST_NOT_BE_SET; … … 211 230 } 212 231 213 job. DateCreated = DateTime.Now;214 jobAdapter.Update (job);232 job.JobInfo.DateCreated = DateTime.Now; 233 jobAdapter.UpdateComputableJob(job); 215 234 response.Success = true; 216 response.Obj = job ;235 response.Obj = job.JobInfo; 217 236 response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_ADDED; 218 237 } else { -
TabularUnified trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs ¶
r2067 r2082 99 99 } 100 100 101 public ResponseObject<Job> AddNewJob( Job job) {102 secMan.Authorize("AddJob", sessionID, job. Id);101 public ResponseObject<Job> AddNewJob(ComputableJob job) { 102 secMan.Authorize("AddJob", sessionID, job.JobInfo.Id); 103 103 return jobManager.AddNewJob(job); 104 104 } -
TabularUnified trunk/sources/HeuristicLab.Hive.Server.DataAccess/3.2/IJobAdapter.cs ¶
r2066 r2082 80 80 /// <returns></returns> 81 81 ICollection<Job> GetJobsByProject(Guid projectId); 82 83 /// <summary> 84 /// Gets the computable job with the secified jobId 85 /// </summary> 86 /// <param name="jobId"></param> 87 /// <returns></returns> 88 ComputableJob GetComputableJob(Guid jobId); 89 90 /// <summary> 91 /// Saves or update the computable job 92 /// </summary> 93 /// <param name="jobId"></param> 94 void UpdateComputableJob(ComputableJob job); 82 95 } 83 96 }
Note: See TracChangeset
for help on using the changeset viewer.