Changeset 501
- Timestamp:
- 08/12/08 09:04:21 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Grid
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Grid/EngineStore.cs
r500 r501 31 31 [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)] 32 32 public class EngineStore : IEngineStore { 33 private Dictionary<Guid, ManualResetEvent> waitHandles;34 33 private Database database; 35 34 … … 57 56 58 57 public EngineStore() { 59 waitHandles = new Dictionary<Guid, ManualResetEvent>();60 58 DbProviderFactory fact; 61 59 fact = DbProviderFactories.GetFactory("System.Data.SQLite"); … … 90 88 // add the new result 91 89 database.SetJobResult(guid, result); 92 waitHandles[guid].Set();93 90 } 94 91 95 92 internal void AddEngine(Guid guid, byte[] engine) { 96 93 database.InsertJob(guid, HeuristicLab.Grid.JobState.Waiting, engine); 97 waitHandles.Add(guid, new ManualResetEvent(false));98 94 } 99 95 100 96 internal byte[] GetResult(Guid guid) { 101 return GetResult(guid, System.Threading.Timeout.Infinite);102 }103 104 internal byte[] GetResult(Guid guid, int timeout) {105 97 if(JobState(guid) == HeuristicLab.Grid.JobState.Finished) { 106 ManualResetEvent waitHandle = waitHandles[guid];107 waitHandle.Close();108 waitHandles.Remove(guid);109 98 JobEntry entry = database.GetJob(guid); 110 99 return entry.RawData; 111 100 } else { 112 // result not yet available, if there is also no wait-handle for that result then we will never have a result and can return null 113 if(!waitHandles.ContainsKey(guid)) return null; 114 // otherwise we have a wait-handle and can wait for the result 115 ManualResetEvent waitHandle = waitHandles[guid]; 116 // wait 117 if(waitHandle.WaitOne(timeout, true)) { 118 // ok got the result in within the wait time => close and remove the wait-hande and return the result 119 waitHandle.Close(); 120 waitHandles.Remove(guid); 121 JobEntry entry = database.GetJob(guid); 122 return entry.RawData; 123 } else { 124 // no result yet, check for which jobs we waited too long and requeue those jobs 125 database.RestartExpiredActiveJobs(); 126 return null; 127 } 101 // JobState is Busy, Waiting or Unknown 102 // no result yet, check for which jobs we waited too long and requeue those jobs 103 database.RestartExpiredActiveJobs(); 104 return null; 128 105 } 129 106 } -
trunk/sources/HeuristicLab.Grid/GridServer.cs
r500 r501 45 45 } 46 46 47 public byte[] EndExecuteEngine(Guid guid) {47 public byte[] TryEndExecuteEngine(Guid guid) { 48 48 return engineStore.GetResult(guid); 49 }50 public byte[] TryEndExecuteEngine(Guid guid, int timeout) {51 return engineStore.GetResult(guid, timeout);52 49 } 53 50 } -
trunk/sources/HeuristicLab.Grid/IGridServer.cs
r500 r501 41 41 Guid BeginExecuteEngine(byte[] engine); 42 42 [OperationContract] 43 byte[] EndExecuteEngine(Guid engineGuid); 44 [OperationContract] 45 byte[] TryEndExecuteEngine(Guid engineGuid, int timeout); 43 byte[] TryEndExecuteEngine(Guid engineGuid); 46 44 } 47 45 } -
trunk/sources/HeuristicLab.Grid/JobManager.cs
r414 r501 251 251 try { 252 252 lock(connectionLock) { 253 byte[] zippedResult = server.TryEndExecuteEngine(engineGuid , 100);253 byte[] zippedResult = server.TryEndExecuteEngine(engineGuid); 254 254 return zippedResult; 255 255 }
Note: See TracChangeset
for help on using the changeset viewer.