Example #1
0
 /// <summary>
 /// Creates a new instance of the <see cref="Controller"/> class.
 /// </summary>
 public Controller()
 {
     globals = Globals.Instance();
     log = new QueueEventLogger(100);
     crawler = null;
     stats = new long[10];
     proxy = CrawlWaveServerProxy.Instance(globals);
 }
Example #2
0
 /// <summary>
 /// Attempts to stop the Crawler.
 /// </summary>
 /// <returns>Null if the operation succeeds, or a <see cref="SerializedException"/> 
 /// encapsulating the error that occured if the operation fails.</returns>
 /// <exception cref="InvalidOperationException">Thrown if the Crawler has not yet been initialized.</exception>
 public SerializedException Stop()
 {
     SerializedException sx = null;
     try
     {
         if(Crawler.InstanceExists())
         {
             if(crawler == null)
             {
                 crawler = Crawler.Instance();
                 AttachObservers();
             }
             crawler.StopImmediately();
         }
         else
         {
             throw new InvalidOperationException("The Crawler has not been initialized and cannot be stopped.");
         }
     }
     catch(Exception e)
     {
         sx = new SerializedException(e.GetType().ToString(), e.Message, e.StackTrace);
     }
     return sx;
 }
Example #3
0
 /// <summary>
 /// Retrieves the crawler's statistics as an array of longs.
 /// </summary>
 /// <returns>An array of longs containing the crawler's statistics.</returns>
 public long[] GetStatistics()
 {
     if(Crawler.InstanceExists())
     {
         if(crawler == null)
         {
             crawler = Crawler.Instance();
             AttachObservers();
         }
         for(int i = 0; i<10; i++)
         {
             stats[i] = crawler.Statistics[i];
         }
     }
     return stats;
 }
Example #4
0
 /// <summary>
 /// Attempts to start the Crawler and enable the logging of events.
 /// </summary>
 /// <returns>Null if the operation succeeds, or a <see cref="SerializedException"/> 
 /// encapsulating the error that occured if the operation fails.</returns>
 public SerializedException Start()
 {
     SerializedException sx = null;
     try
     {
         if(crawler == null)
         {
             crawler = Crawler.Instance();
             AttachObservers();
         }
         crawler.Start();
     }
     catch(Exception e)
     {
         sx = new SerializedException(e.GetType().ToString(), e.Message, e.StackTrace);
     }
     return sx;
 }
Example #5
0
 /// <summary>
 /// Provides a global access point for the single instance of the <see cref="Crawler"/>
 /// class.
 /// </summary>
 /// <returns>A reference to the single instance of <see cref="Crawler"/>.</returns>
 public static Crawler Instance()
 {
     if (instance==null)
     {
         //Make sure the call is thread-safe.
         Mutex mutex=new Mutex();
         mutex.WaitOne();
         if( instance == null )
         {
             instance = new Crawler();
         }
         mutex.Close();
     }
     return instance;
 }