Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/29/08 17:55:35 (16 years ago)
Author:
gkronber
Message:

moved GZip persistence into the PersistenceManager in HeuristicLab.Core because compression is needed in several plugins (CEDMA and Grid)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Grid/JobManager.cs

    r391 r402  
    2929using HeuristicLab.Core;
    3030using System.IO;
    31 using System.IO.Compression;
    3231using System.Windows.Forms;
    3332using System.Diagnostics;
     
    6968
    7069    public JobManager(string address) {
     70      Trace.Listeners.Clear();
     71      Trace.Listeners.Add(new EventLogTraceListener("HeuristicLab.Grid"));
    7172      this.address = address;
    7273      Thread starterThread = new Thread(StartEngines);
     
    9394
    9495    private void ResetConnection() {
     96      Trace.TraceInformation("Reset connection in JobManager");
    9597      lock(connectionLock) {
    9698        // open a new channel
     
    139141          }
    140142        }
    141       } finally {
    142         Debug.Assert(false);  // make sure that we are notified when this thread is stopped in debugging
     143      } catch(Exception e) {
     144        Trace.TraceError("Exception "+e+" in JobManager.StartEngines() killed the start-engine thread\n"+e.StackTrace);
    143145      }
    144146    }
     
    181183          }
    182184        }
    183       } finally {
    184         Debug.Assert(false); // just to make sure that I get notified when debugging whenever this thread is killed somehow
     185      } catch(Exception e) {
     186        Trace.TraceError("Exception " + e + " in JobManager.GetResults() killed the results-gathering thread\n"+ e.StackTrace);
    185187      }
    186188    }
     
    199201
    200202    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);
    208204    }
    209205
     
    219215        }
    220216        // 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);
    224218      }
    225219    }
     
    244238        }
    245239      } while(retries < MAX_CONNECTION_RETRIES);
     240      Trace.TraceWarning("Reached max connection retries in TryStartExecuteEngine");
    246241      return Guid.Empty;
    247242    }
     
    264259        }
    265260      } while(retries < MAX_CONNECTION_RETRIES);
     261      Trace.TraceWarning("Reached max connection retries in TryEndExecuteEngine");
    266262      return null;
    267263    }
     
    285281        }
    286282      } while(retries < MAX_CONNECTION_RETRIES);
     283      Trace.TraceWarning("Reached max connection retries in TryGetJobState");
    287284      return JobState.Unknown;
    288285    }
Note: See TracChangeset for help on using the changeset viewer.