Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/22/11 16:44:28 (13 years ago)
Author:
ascheibe
Message:

#1233 various slave and slave tray icon improvements

Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.SlaveTrayIcon/app.config

    r5721 r5795  
    88      </service>
    99    </services>
     10    <client>
     11      <endpoint name="SlaveCommunicationServiceEndpoint" address="net.pipe://localhost/HeuristicLabSlaveCom" binding="netNamedPipeBinding" contract="HeuristicLab.Clients.Hive.SlaveCore.ServiceContracts.ISlaveCommunication"/>
     12    </client>
    1013
    1114  </system.serviceModel>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Tests/SlaveCommListener.cs

    r5711 r5795  
    2222using System;
    2323using System.ServiceModel;
     24using System.Threading;
    2425using HeuristicLab.Clients.Hive.SlaveCore.ServiceContracts;
    2526
     
    3637    public void Open() {
    3738      pipeFactory = new DuplexChannelFactory<ISlaveCommunication>(this, "SlaveCommunicationServiceEndpoint");
    38       pipeProxy = pipeFactory.CreateChannel();
    39       pipeProxy.Subscribe();
     39
     40      while (!ReconnectToSlaveCore()) {
     41        Thread.Sleep(500);
     42      }
     43    }
     44
     45    public bool ReconnectToSlaveCore() {
     46      try {
     47        pipeProxy = pipeFactory.CreateChannel();
     48        pipeProxy.Subscribe();
     49        return true;
     50      }
     51      catch (Exception e) {
     52        OnMessageLogged("Couldn't connect to Slave core. Is it possible that the Slave Core isn't running?\nException is: " + e.ToString());
     53        return false;
     54      }
    4055    }
    4156
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.4/SlaveItem.cs

    r5599 r5795  
    3131  [Item("SlaveItem", "Represents a slave which receives messages from the core")]
    3232  public class SlaveItem : Item, ISlaveCommunicationCallbacks, IDisposable {
    33     ISlaveCommunication pipeProxy;
    34     DuplexChannelFactory<ISlaveCommunication> pipeFactory;
     33    private ISlaveCommunication pipeProxy;
     34    private DuplexChannelFactory<ISlaveCommunication> pipeFactory;
    3535
    3636    public SlaveItem() {
     
    6262
    6363    public void Open() {
    64       //TODO: read info from app.config
    65       pipeFactory = new DuplexChannelFactory<ISlaveCommunication>(this,
    66         new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/HeuristicLabSlaveCom"));
     64      pipeFactory = new DuplexChannelFactory<ISlaveCommunication>(this, "SlaveCommunicationServiceEndpoint");
     65      RegisterEvents();
     66    }
    6767
    68       pipeProxy = pipeFactory.CreateChannel();
    69       RegisterEvents();
    70 
     68    public bool ReconnectToSlaveCore() {
    7169      try {
     70        pipeProxy = pipeFactory.CreateChannel();
    7271        pipeProxy.Subscribe();
     72        return true;
    7373      }
    7474      catch (Exception e) {
    7575        OnMessageLogged("Couldn't connect to Slave core. Is it possible that the Slave Core isn't running?\nException is: " + e.ToString());
     76        return false;
    7677      }
    7778    }
    7879
    79     public void ReconnectToSlaveCore() {
    80       try {
    81         pipeProxy = pipeFactory.CreateChannel();
    82         pipeProxy.Subscribe();
    83       }
    84       catch (Exception e) {
    85         OnMessageLogged("Couldn't connect to Slave core. Is it possible that the Slave Core isn't running?\nException is: " + e.ToString());
    86       }
    87     }
    88 
    89     public bool isClosed() {
     80    public bool IsClosed() {
    9081      if (pipeFactory == null) return true;
    91       return pipeFactory.State == CommunicationState.Closed;
     82      return pipeFactory.State == CommunicationState.Closed || pipeFactory.State == CommunicationState.Faulted;
    9283    }
    9384
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.4/SlaveView.cs

    r5789 r5795  
    2020#endregion
    2121
     22using System;
     23using System.Threading;
     24using System.Threading.Tasks;
    2225using System.Windows.Forms;
    2326using System.Windows.Forms.DataVisualization.Charting;
     
    7073      } else {
    7174        //try to establish a connection to the slave service
    72         if (base.Content != null && ((SlaveItem)base.Content).isClosed()) {
     75        if (base.Content != null) {
    7376          ((SlaveItem)base.Content).Open();
     77          Task.Factory.StartNew(Connector);
    7478        }
    7579      }
     80    }
     81
     82    private void Connector() {
     83      bool connected = false;
     84      while (!connected) {
     85        this.Invoke(new Func<bool>(() => connected = ((SlaveItem)base.Content).ReconnectToSlaveCore()));
     86
     87        if (!connected) {
     88          Thread.Sleep(1000);
     89        }
     90      }
     91      this.Invoke(new Action(SetEnabledStateOfControls));
    7692    }
    7793
     
    89105    void Content_SlaveShutdown(object sender, System.EventArgs e) {
    90106      txtLog.AppendText("Slave did shutdown\n");
     107      Task.Factory.StartNew(Connector);
    91108    }
    92109
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Executor.cs

    r5793 r5795  
    8888    public void Pause() {
    8989      if (Job == null) {
    90         throw new InvalidStateException("Job is null");
     90        SlaveClientCom.Instance.ClientCom.LogMessage("Pausing job: Job is null");
     91        Core.EnqueueExecutorMessage(Core.KillAppDomain, JobId);
    9192      }
    9293
     
    105106    public void Stop() {
    106107      if (Job == null) {
    107         throw new InvalidStateException("Job is null");
     108        SlaveClientCom.Instance.ClientCom.LogMessage("Stopping job: Job is null");
     109        Core.EnqueueExecutorMessage(Core.KillAppDomain, JobId);
    108110      }
    109111      wasJobAborted = true;
     
    193195    public JobData GetFinishedJob() {
    194196      if (Job == null) {
    195         throw new InvalidStateException("Job is null");
     197        SlaveClientCom.Instance.ClientCom.LogMessage("Getting finished job: Job is null");
     198        Core.EnqueueExecutorMessage(Core.KillAppDomain, JobId);
    196199      }
    197200
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/SlaveClientCom.cs

    r5711 r5795  
    3131    private static SlaveClientCom instance;
    3232    private static DuplexChannelFactory<ISlaveCommunication> pipeFactory;
     33    public ISlaveCommunication ClientCom { get; set; }
     34
    3335    /// <summary>
    3436    /// Getter for the Instance of the SlaveClientCom
     
    4446    }
    4547
    46     public ISlaveCommunication ClientCom { get; set; }
    47 
    4848    private SlaveClientCom() {
    4949      SetupClientCom();
     
    5353      DummyListener dummy = new DummyListener();
    5454      pipeFactory = new DuplexChannelFactory<ISlaveCommunication>(dummy, "SlaveCommunicationServiceEndpoint");
     55
    5556      ISlaveCommunication pipeProxy = pipeFactory.CreateChannel();
    5657      ClientCom = pipeProxy;
Note: See TracChangeset for help on using the changeset viewer.