Changeset 402
- Timestamp:
- 07/29/08 17:55:35 (17 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/PersistenceManager.cs
r267 r402 25 25 using System.Xml; 26 26 using System.IO; 27 using System.IO.Compression; 27 28 28 29 namespace HeuristicLab.Core { … … 86 87 } 87 88 89 public static IStorable RestoreFromGZip(byte[] serializedStorable) { 90 GZipStream stream = new GZipStream(new MemoryStream(serializedStorable), CompressionMode.Decompress); 91 return Load(stream); 92 } 93 94 public static byte[] SaveToGZip(IStorable storable) { 95 MemoryStream memStream = new MemoryStream(); 96 GZipStream stream = new GZipStream(memStream, CompressionMode.Compress, true); 97 Save(storable, stream); 98 stream.Close(); 99 return memStream.ToArray(); 100 } 101 88 102 public static string BuildTypeString(Type type) { 89 103 string assembly = type.Assembly.FullName; -
trunk/sources/HeuristicLab.Grid/ClientForm.cs
r383 r402 33 33 using System.Threading; 34 34 using System.IO; 35 using System.IO.Compression;36 35 using System.Net; 36 using System.Diagnostics; 37 37 38 38 namespace HeuristicLab.Grid { … … 61 61 private void startButton_Click(object sender, EventArgs e) { 62 62 try { 63 Trace.Listeners.Clear(); 64 Trace.Listeners.Add(new EventLogTraceListener("HeuristicLab.Grid")); 65 63 66 ResetConnection(); 64 67 fetchOperationTimer.Start(); … … 77 80 78 81 private void ResetConnection() { 82 Trace.TraceInformation("Reset connection in GridClient"); 79 83 NetTcpBinding binding = new NetTcpBinding(); 80 84 binding.MaxReceivedMessageSize = 100000000; // 100Mbytes … … 112 116 gotEngine = engineStore.TryTakeEngine(out currentGuid, out engineXml); 113 117 } catch(TimeoutException) { 118 Trace.TraceWarning("TimeoutException while trying to get an engine"); 114 119 currentEngine = null; 115 120 currentGuid = Guid.Empty; … … 118 123 fetchOperationTimer.Start(); 119 124 } catch(CommunicationException) { 125 Trace.TraceWarning("CommunicationException while trying to get an engine"); 120 126 // connection problem -> reset connection and start the timer again 121 127 ResetConnection(); … … 156 162 success = true; 157 163 } catch(TimeoutException) { 164 Trace.TraceWarning("TimeoutException while trying to store the result of an engine"); 158 165 success = false; 159 166 retries++; 160 167 Thread.Sleep(TimeSpan.FromSeconds(CONNECTION_RETRY_TIMEOUT_SEC)); 161 168 } catch(CommunicationException) { 169 Trace.TraceWarning("CommunicationException while trying to store the result of an engine"); 162 170 ResetConnection(); 163 171 success = false; … … 180 188 181 189 private ProcessingEngine RestoreEngine(byte[] engine) { 182 GZipStream stream = new GZipStream(new MemoryStream(engine), CompressionMode.Decompress); 183 return (ProcessingEngine)PersistenceManager.Load(stream); 190 return (ProcessingEngine)PersistenceManager.RestoreFromGZip(engine); 184 191 } 185 192 private byte[] SaveEngine(IEngine engine) { 186 MemoryStream memStream = new MemoryStream(); 187 GZipStream stream = new GZipStream(memStream, CompressionMode.Compress, true); 188 PersistenceManager.Save(engine, stream); 189 stream.Close(); 190 return memStream.ToArray(); 193 return PersistenceManager.SaveToGZip(engine); 191 194 } 192 195 } -
trunk/sources/HeuristicLab.Grid/JobManager.cs
r391 r402 29 29 using HeuristicLab.Core; 30 30 using System.IO; 31 using System.IO.Compression;32 31 using System.Windows.Forms; 33 32 using System.Diagnostics; … … 69 68 70 69 public JobManager(string address) { 70 Trace.Listeners.Clear(); 71 Trace.Listeners.Add(new EventLogTraceListener("HeuristicLab.Grid")); 71 72 this.address = address; 72 73 Thread starterThread = new Thread(StartEngines); … … 93 94 94 95 private void ResetConnection() { 96 Trace.TraceInformation("Reset connection in JobManager"); 95 97 lock(connectionLock) { 96 98 // open a new channel … … 139 141 } 140 142 } 141 } finally{142 Debug.Assert(false); // make sure that we are notified when this thread is stopped in debugging143 } catch(Exception e) { 144 Trace.TraceError("Exception "+e+" in JobManager.StartEngines() killed the start-engine thread\n"+e.StackTrace); 143 145 } 144 146 } … … 181 183 } 182 184 } 183 } finally{184 Debug.Assert(false); // just to make sure that I get notified when debugging whenever this thread is killed somehow185 } catch(Exception e) { 186 Trace.TraceError("Exception " + e + " in JobManager.GetResults() killed the results-gathering thread\n"+ e.StackTrace); 185 187 } 186 188 } … … 199 201 200 202 private byte[] ZipEngine(ProcessingEngine engine) { 201 MemoryStream memStream = new MemoryStream(); 202 GZipStream stream = new GZipStream(memStream, CompressionMode.Compress, true); 203 PersistenceManager.Save(engine, stream); 204 stream.Close(); 205 byte[] zippedEngine = memStream.ToArray(); 206 memStream.Close(); 207 return zippedEngine; 203 return PersistenceManager.SaveToGZip(engine); 208 204 } 209 205 … … 219 215 } 220 216 // restore the engine 221 using(GZipStream stream = new GZipStream(new MemoryStream(zippedResult), CompressionMode.Decompress)) { 222 return (ProcessingEngine)PersistenceManager.Load(stream); 223 } 217 return (ProcessingEngine)PersistenceManager.RestoreFromGZip(zippedResult); 224 218 } 225 219 } … … 244 238 } 245 239 } while(retries < MAX_CONNECTION_RETRIES); 240 Trace.TraceWarning("Reached max connection retries in TryStartExecuteEngine"); 246 241 return Guid.Empty; 247 242 } … … 264 259 } 265 260 } while(retries < MAX_CONNECTION_RETRIES); 261 Trace.TraceWarning("Reached max connection retries in TryEndExecuteEngine"); 266 262 return null; 267 263 } … … 285 281 } 286 282 } while(retries < MAX_CONNECTION_RETRIES); 283 Trace.TraceWarning("Reached max connection retries in TryGetJobState"); 287 284 return JobState.Unknown; 288 285 }
Note: See TracChangeset
for help on using the changeset viewer.