Changeset 5795
- Timestamp:
- 03/22/11 16:44:28 (14 years ago)
- 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 8 8 </service> 9 9 </services> 10 <client> 11 <endpoint name="SlaveCommunicationServiceEndpoint" address="net.pipe://localhost/HeuristicLabSlaveCom" binding="netNamedPipeBinding" contract="HeuristicLab.Clients.Hive.SlaveCore.ServiceContracts.ISlaveCommunication"/> 12 </client> 10 13 11 14 </system.serviceModel> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Tests/SlaveCommListener.cs
r5711 r5795 22 22 using System; 23 23 using System.ServiceModel; 24 using System.Threading; 24 25 using HeuristicLab.Clients.Hive.SlaveCore.ServiceContracts; 25 26 … … 36 37 public void Open() { 37 38 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 } 40 55 } 41 56 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.4/SlaveItem.cs
r5599 r5795 31 31 [Item("SlaveItem", "Represents a slave which receives messages from the core")] 32 32 public class SlaveItem : Item, ISlaveCommunicationCallbacks, IDisposable { 33 ISlaveCommunication pipeProxy;34 DuplexChannelFactory<ISlaveCommunication> pipeFactory;33 private ISlaveCommunication pipeProxy; 34 private DuplexChannelFactory<ISlaveCommunication> pipeFactory; 35 35 36 36 public SlaveItem() { … … 62 62 63 63 public void Open() { 64 //TODO: read info from app.config65 pipeFactory = new DuplexChannelFactory<ISlaveCommunication>(this,66 new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/HeuristicLabSlaveCom"));64 pipeFactory = new DuplexChannelFactory<ISlaveCommunication>(this, "SlaveCommunicationServiceEndpoint"); 65 RegisterEvents(); 66 } 67 67 68 pipeProxy = pipeFactory.CreateChannel(); 69 RegisterEvents(); 70 68 public bool ReconnectToSlaveCore() { 71 69 try { 70 pipeProxy = pipeFactory.CreateChannel(); 72 71 pipeProxy.Subscribe(); 72 return true; 73 73 } 74 74 catch (Exception e) { 75 75 OnMessageLogged("Couldn't connect to Slave core. Is it possible that the Slave Core isn't running?\nException is: " + e.ToString()); 76 return false; 76 77 } 77 78 } 78 79 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() { 90 81 if (pipeFactory == null) return true; 91 return pipeFactory.State == CommunicationState.Closed ;82 return pipeFactory.State == CommunicationState.Closed || pipeFactory.State == CommunicationState.Faulted; 92 83 } 93 84 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.4/SlaveView.cs
r5789 r5795 20 20 #endregion 21 21 22 using System; 23 using System.Threading; 24 using System.Threading.Tasks; 22 25 using System.Windows.Forms; 23 26 using System.Windows.Forms.DataVisualization.Charting; … … 70 73 } else { 71 74 //try to establish a connection to the slave service 72 if (base.Content != null && ((SlaveItem)base.Content).isClosed()) {75 if (base.Content != null) { 73 76 ((SlaveItem)base.Content).Open(); 77 Task.Factory.StartNew(Connector); 74 78 } 75 79 } 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)); 76 92 } 77 93 … … 89 105 void Content_SlaveShutdown(object sender, System.EventArgs e) { 90 106 txtLog.AppendText("Slave did shutdown\n"); 107 Task.Factory.StartNew(Connector); 91 108 } 92 109 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Executor.cs
r5793 r5795 88 88 public void Pause() { 89 89 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); 91 92 } 92 93 … … 105 106 public void Stop() { 106 107 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); 108 110 } 109 111 wasJobAborted = true; … … 193 195 public JobData GetFinishedJob() { 194 196 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); 196 199 } 197 200 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/SlaveClientCom.cs
r5711 r5795 31 31 private static SlaveClientCom instance; 32 32 private static DuplexChannelFactory<ISlaveCommunication> pipeFactory; 33 public ISlaveCommunication ClientCom { get; set; } 34 33 35 /// <summary> 34 36 /// Getter for the Instance of the SlaveClientCom … … 44 46 } 45 47 46 public ISlaveCommunication ClientCom { get; set; }47 48 48 private SlaveClientCom() { 49 49 SetupClientCom(); … … 53 53 DummyListener dummy = new DummyListener(); 54 54 pipeFactory = new DuplexChannelFactory<ISlaveCommunication>(dummy, "SlaveCommunicationServiceEndpoint"); 55 55 56 ISlaveCommunication pipeProxy = pipeFactory.CreateChannel(); 56 57 ClientCom = pipeProxy;
Note: See TracChangeset
for help on using the changeset viewer.