Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/17/11 20:03:46 (14 years ago)
Author:
ascheibe
Message:

#1233

  • added ItemView and Item for the Slave
  • added a Tray Icon App for data visualization and control of the slave windows service
  • added control methods to SlaveCommunication for controlling the slave core
  • fixed typo in namespace
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs

    r5280 r5314  
    2626using System.ServiceModel;
    2727using System.Threading;
    28 using HeuristicLab.Clients.Hive.Slave;
    2928using HeuristicLab.Clients.Hive.Slave.ServiceContracts;
    3029using HeuristicLab.Common;
     
    3433
    3534
    36 namespace HeuristicLab.Clients.Hive.Salve {
     35namespace HeuristicLab.Clients.Hive.Slave {
    3736  /// <summary>
    3837  /// The core component of the Hive Client
     
    160159            ShutdownCore();
    161160            break;
     161          case MessageContainer.MessageType.HardPause:
     162            doHardPause();
     163            break;
     164          case MessageContainer.MessageType.SoftPause:
     165            doSoftPause();
     166            break;
     167          case MessageContainer.MessageType.Restart:
     168            doRestart();
     169            break;
    162170        }
    163171      } else {
    164172        ClientCom.LogMessage("Unknown MessageContainer: " + container);
    165173      }
     174    }
     175
     176    /// <summary>
     177    /// reinitializes everything and continues operation,
     178    /// can be called after SoftPause() or HardPause()
     179    /// </summary>
     180    public void Restart() {
     181      MessageContainer mc = new MessageContainer(MessageContainer.MessageType.Restart);
     182      MessageQueue.GetInstance().AddMessage(mc);
     183    }
     184
     185    private void doRestart() {
     186      ClientCom.LogMessage("Restart received");
     187      StartHeartbeats();
     188      ClientCom.LogMessage("Restart done");
     189    }
     190
     191    /// <summary>
     192    /// wait for jobs to finish, then pause client
     193    /// </summary>
     194    public void SoftPause() {
     195      MessageContainer mc = new MessageContainer(MessageContainer.MessageType.SoftPause);
     196      MessageQueue.GetInstance().AddMessage(mc);
     197    }
     198
     199    private void doSoftPause() {
     200      ClientCom.LogMessage("Soft pause received");
     201
     202      //TODO: jobs get removed from Jobs map, is this a problem?
     203      foreach (Job job in Jobs.Values) {
     204        engines[job.Id].Pause();
     205        JobData sJob = engines[job.Id].GetFinishedJob();
     206        job.Exception = engines[job.Id].CurrentException;
     207        job.ExecutionTime = engines[job.Id].ExecutionTime;
     208
     209        try {
     210          ClientCom.LogMessage("Sending the paused job with id: " + job.Id);
     211          wcfService.UpdateJob(job, sJob);
     212          SlaveStatusInfo.JobsProcessed++;    //TODO: count or not count, thats the question
     213        }
     214        catch (Exception e) {
     215          ClientCom.LogMessage("Transmitting to server failed. Storing the paused job with id: " + job.Id + " to hdd (" + e.ToString() + ")");
     216        }
     217        finally {
     218          KillAppDomain(job.Id); // kill app-domain in every case         
     219        }
     220      }
     221
     222      heartbeatManager.StopHeartBeat();
     223      WcfService.Instance.Disconnect();
     224      ClientCom.LogMessage("Soft pause done");
     225    }
     226
     227    /// <summary>
     228    /// pause slave immediately
     229    /// </summary>
     230    public void HardPause() {
     231      MessageContainer mc = new MessageContainer(MessageContainer.MessageType.HardPause);
     232      MessageQueue.GetInstance().AddMessage(mc);
     233    }
     234
     235    private void doHardPause() {
     236      ClientCom.LogMessage("Hard pause received");
     237      heartbeatManager.StopHeartBeat();
     238
     239      lock (engines) {
     240        ClientCom.LogMessage("engines locked");
     241        foreach (KeyValuePair<Guid, AppDomain> kvp in appDomains) {
     242          ClientCom.LogMessage("Shutting down Appdomain for " + kvp.Key);
     243          appDomains[kvp.Key].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException);
     244          AppDomain.Unload(kvp.Value);
     245        }
     246      }
     247      WcfService.Instance.Disconnect();
     248      ClientCom.LogMessage("Hard pause done");
    166249    }
    167250
     
    172255    }
    173256
     257    /// <summary>
     258    /// hard shutdown, should be called before the the application is exited
     259    /// </summary>
    174260    private void ShutdownCore() {
    175261      ClientCom.LogMessage("Shutdown Signal received");
Note: See TracChangeset for help on using the changeset viewer.