Free cookie consent management tool by TermsFeed Policy Generator

Changeset 932


Ignore:
Timestamp:
12/10/08 11:15:47 (16 years ago)
Author:
kgrading
Message:

implementation for #425

Location:
trunk/sources
Files:
4 added
3 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Client.Common/HeuristicLab.Hive.Client.Common.csproj

    r852 r932  
    6868    <Compile Include="Logging.cs" />
    6969    <Compile Include="MessageQueue.cs" />
     70    <Compile Include="NetworkEnum.cs" />
    7071    <Compile Include="Properties\AssemblyInfo.cs" />
    71     <Compile Include="Status.cs" />
    7272  </ItemGroup>
    7373  <ItemGroup>
  • trunk/sources/HeuristicLab.Hive.Client.Communication/HeuristicLab.Hive.Client.Communication.csproj

    r923 r932  
    7070    <Compile Include="Properties\AssemblyInfo.cs" />
    7171    <Compile Include="ServerProxy.cs" />
    72     <Compile Include="ServiceLocator.cs" />
    7372    <Compile Include="WcfService.cs" />
    7473  </ItemGroup>
  • trunk/sources/HeuristicLab.Hive.Client.Communication/WcfService.cs

    r924 r932  
    88using HeuristicLab.Hive.Contracts.BusinessObjects;
    99using HeuristicLab.Hive.Client.Common;
    10 
    1110
    1211namespace HeuristicLab.Hive.Client.Communication {
     
    2221    }
    2322
    24     public enum ConnectionState { connected, disconnected, failed } 
    25     public ConnectionState ConnState { get; set; }
     23    public DateTime ConnectedSince { get; private set; }   
     24    public NetworkEnum.WcfConnState ConnState { get; private set; }
     25    public string ServerIP { get; private set; }
     26    public int ServerPort { get; private set; }
    2627
    2728    public event EventHandler ConnectionRestored;   
     29    public event EventHandler ServerChanged;   
    2830
    2931    private ClientCommunicatorClient proxy = null;
    30     private string serverIP;
    31     private string serverPort;
    3232
    3333    private WcfService() {
     
    3838          proxy = new ClientCommunicatorClient(
    3939            new NetTcpBinding(),
    40             new EndpointAddress("net.tcp://" + serverIP + ":" + serverPort + "/HiveServer/ClientCommunicator")
     40            new EndpointAddress("net.tcp://" + ServerIP + ":" + ServerPort + "/HiveServer/ClientCommunicator")
    4141            );
    4242        }
     
    4747        proxy.SendHeartBeatCompleted += new EventHandler<SendHeartBeatCompletedEventArgs>(proxy_SendHeartBeatCompleted);
    4848
    49         if (ConnState == ConnectionState.failed)
     49        if (ConnState == NetworkEnum.WcfConnState.Failed)
    5050          ConnectionRestored(this, new EventArgs());
    51         ConnState = ConnectionState.connected;
    52 
     51        ConnState = NetworkEnum.WcfConnState.Connected;
     52        ConnectedSince = DateTime.Now;
    5353      }
    5454      catch (Exception ex) {
     
    5757    }
    5858
    59     public void Connect(String serverIP, String serverPort) {
    60       this.serverIP = serverIP;
    61       this.serverPort = serverPort;
     59    public void Connect(String serverIP, int serverPort) {
     60      if(!(this.ServerIP == serverIP) && !(this.ServerPort == ServerPort))
     61        ServerChanged(this, new EventArgs());
     62      this.ServerIP = serverIP;
     63      this.ServerPort = serverPort;
    6264      Connect();
    6365    }
    6466
     67    public void Disconnect() {
     68      ConnState = NetworkEnum.WcfConnState.Disconnected;
     69    }
     70
    6571    private void NetworkErrorHandling(Exception e) {
    66       ConnState = ConnectionState.failed;
     72      ConnState = NetworkEnum.WcfConnState.Failed;
    6773      Logging.GetInstance().Error(this.ToString(), "exception: ", e);
    6874    }
     
    7177    public event System.EventHandler<LoginCompletedEventArgs> LoginCompleted;
    7278    public void LoginAsync(ClientInfo clientInfo) {
    73       if (ConnState == ConnectionState.connected)
     79      if (ConnState == NetworkEnum.WcfConnState.Connected)
    7480        proxy.LoginAsync(clientInfo);
    7581    }
     
    8591    public event System.EventHandler<PullJobCompletedEventArgs> PullJobCompleted;
    8692    public void PullJobAsync(Guid guid) {
    87       if (ConnState == ConnectionState.connected)
     93      if (ConnState == NetworkEnum.WcfConnState.Connected)
    8894        proxy.PullJobAsync(guid);
    8995    }
     
    99105    public event System.EventHandler<SendJobResultCompletedEventArgs> SendJobResultCompleted;
    100106    public void SendJobResultAsync(JobResult result, bool finished) {
    101       if (ConnState == ConnectionState.connected)
     107      if (ConnState == NetworkEnum.WcfConnState.Connected)
    102108        proxy.SendJobResult(result, finished);
    103109    }
     
    115121    public event System.EventHandler<SendHeartBeatCompletedEventArgs> SendHeartBeatCompleted;
    116122    public void SendHeartBeatAsync(HeartBeatData hbd) {
    117       if (ConnState == ConnectionState.connected)
     123      if (ConnState == NetworkEnum.WcfConnState.Connected)
    118124        proxy.SendHeartBeatAsync(hbd);
    119125    }
     
    127133
    128134    #endregion
     135
    129136  }
    130137}
  • trunk/sources/HeuristicLab.Hive.Client.Core/ClientConsoleService/ClientConsoleCommunicator.cs

    r919 r932  
    44using System.Text;
    55using HeuristicLab.Hive.Client.Core.ClientConsoleService.Interfaces;
     6using HeuristicLab.Hive.Client.Core.ConfigurationManager;
     7using HeuristicLab.Hive.Client.Communication;
    68
    79namespace HeuristicLab.Hive.Client.Core.ClientConsoleService {
     
    1012
    1113    public StatusCommons GetStatusInfos() {
    12       throw new NotImplementedException();
     14      return ConfigManager.Instance.GetStatusForClientConsole();
    1315    }
    1416
    1517    public ConnectionContainer GetConnection() {
    16       throw new NotImplementedException();
     18      return new ConnectionContainer{IPAdress = WcfService.Instance.ServerIP, Port = WcfService.Instance.ServerPort } ;
    1719    }
    1820
    1921    public void SetConnection(ConnectionContainer container) {
    20       throw new NotImplementedException();
     22      WcfService.Instance.Connect(container.IPAdress, container.Port);
     23    }
     24
     25    public void Disconnect() {
     26      WcfService.Instance.Disconnect();
    2127    }
    2228
  • trunk/sources/HeuristicLab.Hive.Client.Core/ClientConsoleService/Interfaces/IClientConsoleCommunicator.cs

    r919 r932  
    1414    [OperationContract]
    1515    void SetConnection(ConnectionContainer container);
     16    [OperationContract]
     17    void Disconnect();
    1618  }
    1719}
  • trunk/sources/HeuristicLab.Hive.Client.Core/ClientConsoleService/TransferObjects/StatusCommons.cs

    r919 r932  
    33using System.Linq;
    44using System.Text;
     5using HeuristicLab.Hive.Client.Common;
    56
    67namespace HeuristicLab.Hive.Client.Core.ClientConsoleService {
    78  [Serializable]
    8   public class StatusCommons {
    9     public enum ClientStatusEnum { Connected, Disconnected, ConnInterrupted };
     9  public class StatusCommons {   
    1010    public Guid ClientGuid { get; set; }
    11     public ClientStatusEnum Status { get; set; }
     11    public NetworkEnum.WcfConnState Status { get; set; }
    1212    public DateTime ConnectedSince { get; set; }
    1313    public int JobsFetched { get; set; }
  • trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs

    r924 r932  
    4040using System.ServiceModel.Description;
    4141using HeuristicLab.Hive.Client.Core.ClientConsoleService;
     42using HeuristicLab.Hive.Client.Core.ConfigurationManager;
    4243
    4344
     
    5758      server.StartClientConsoleServer(new Uri("net.tcp://127.0.0.1:8000/ClientConsole/"));
    5859
    59       ConfigurationManager manager = ConfigurationManager.GetInstance();
     60      ConfigManager manager = ConfigManager.Instance;
    6061      manager.Core = this;
    6162
    6263      wcfService = WcfService.Instance;
    63       wcfService.Connect("192.168.132.1", "9000");
     64      wcfService.Connect("10.20.53.1", 9000);
    6465
    6566      wcfService.LoginCompleted += new EventHandler<LoginCompletedEventArgs>(wcfService_LoginCompleted);
     
    6768      wcfService.SendJobResultCompleted += new EventHandler<SendJobResultCompletedEventArgs>(wcfService_SendJobResultCompleted);
    6869      wcfService.ConnectionRestored += new EventHandler(wcfService_ConnectionRestored);
     70      wcfService.ServerChanged += new EventHandler(wcfService_ServerChanged);
    6971
    70       wcfService.LoginAsync(ConfigurationManager.GetInstance().GetClientInfo());
     72      wcfService.LoginAsync(ConfigManager.Instance.GetClientInfo());
    7173
    7274      Heartbeat beat = new Heartbeat { Interval = 10000 };
     
    115117      byte[] sJob = engines[jId].GetFinishedJob();
    116118     
    117       JobResult jobResult = new JobResult { JobId = jId, Result = sJob, Client = ConfigurationManager.GetInstance().GetClientInfo() };
     119      JobResult jobResult = new JobResult { JobId = jId, Result = sJob, Client = ConfigManager.Instance.GetClientInfo() };
    118120      wcfService.SendJobResultAsync(jobResult, true);
    119121    }
     
    135137      if (e.Result.Success) {
    136138        Logging.GetInstance().Info(this.ToString(), "Login completed to Hive Server @ " + DateTime.Now);
    137         ConfigurationManager.GetInstance().Loggedin();
    138         Status.LoginTime = DateTime.Now;
    139         Status.LoggedIn = true;
     139        ConfigManager.Instance.Loggedin();       
    140140      } else
    141141        Logging.GetInstance().Error(this.ToString(), e.Result.StatusMessage);
     
    156156      engines.Add(e.Result.JobId, engine);
    157157
    158       Status.CurrentJobs++;
     158      ClientStatusInfo.JobsFetched++;
    159159
    160       Debug.WriteLine("Increment CurrentJobs to:"+Status.CurrentJobs.ToString());
     160      Debug.WriteLine("Increment FetchedJobs to:"+ClientStatusInfo.JobsFetched);
    161161    }
    162162
     
    166166        appDomains.Remove(e.Result.JobId);
    167167        engines.Remove(e.Result.JobId);
    168         Status.CurrentJobs--;
    169         Debug.WriteLine("Decrement CurrentJobs to:" + Status.CurrentJobs.ToString());
     168        ClientStatusInfo.JobsProcessed++;
     169        Debug.WriteLine("ProcessedJobs to:" + ClientStatusInfo.JobsProcessed);
    170170      } else {
    171171        Debug.WriteLine("Job sending FAILED!");
    172172      }
    173173    }
     174
     175    void wcfService_ServerChanged(object sender, EventArgs e) {
     176      foreach(KeyValuePair<long, AppDomain> entries in appDomains)
     177        AppDomain.Unload(appDomains[entries.Key]);
     178      appDomains = new Dictionary<long, AppDomain>();
     179      engines = new Dictionary<long, Executor>();
     180    }
     181
    174182
    175183    #endregion
  • trunk/sources/HeuristicLab.Hive.Client.Core/Heartbeat.cs

    r923 r932  
    7474                                                              freeMemory = 1000,
    7575                                                              jobProgress = 1};
    76       if (wcfService.ConnState == WcfService.ConnectionState.failed) {
     76      if (wcfService.ConnState == NetworkEnum.WcfConnState.Failed) {
    7777        wcfService.Connect();
    78       } else if (wcfService.ConnState == WcfService.ConnectionState.connected) {
     78      } else if (wcfService.ConnState == NetworkEnum.WcfConnState.Connected) {
    7979        wcfService.SendHeartBeatAsync(heartBeatData);
    8080      }
  • trunk/sources/HeuristicLab.Hive.Client.Core/HeuristicLab.Hive.Client.Core.csproj

    r919 r932  
    7676    <Compile Include="ClientConsoleService\TransferObjects\JobStatus.cs" />
    7777    <Compile Include="ClientConsoleService\TransferObjects\StatusCommons.cs" />
    78     <Compile Include="ConfigurationManager.cs" />
     78    <Compile Include="ConfigurationManager\ClientStatusInfo.cs" />
     79    <Compile Include="ConfigurationManager\ConfigManager.cs" />
    7980    <Compile Include="Core.cs" />
    8081    <Compile Include="CoreApplication.cs" />
Note: See TracChangeset for help on using the changeset viewer.