Free cookie consent management tool by TermsFeed Policy Generator

Changeset 923


Ignore:
Timestamp:
12/07/08 16:14:00 (15 years ago)
Author:
kgrading
Message:

refactoring of the WCF Service for the Server (#418)

Location:
trunk/sources
Files:
1 added
3 edited

Legend:

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

    r919 r923  
    7171    <Compile Include="ServerProxy.cs" />
    7272    <Compile Include="ServiceLocator.cs" />
     73    <Compile Include="WcfService.cs" />
    7374  </ItemGroup>
    7475  <ItemGroup>
     
    8081      <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project>
    8182      <Name>HeuristicLab.Core</Name>
     83    </ProjectReference>
     84    <ProjectReference Include="..\HeuristicLab.Hive.Client.Common\HeuristicLab.Hive.Client.Common.csproj">
     85      <Project>{89F4BC52-C174-481E-9BD2-3814171020E8}</Project>
     86      <Name>HeuristicLab.Hive.Client.Common</Name>
    8287    </ProjectReference>
    8388    <ProjectReference Include="..\HeuristicLab.Hive.Contracts\HeuristicLab.Hive.Contracts.csproj">
  • trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs

    r919 r923  
    5050    Dictionary<long, AppDomain> appDomains = new Dictionary<long, AppDomain>();
    5151
    52     private ClientCommunicatorClient clientCommunicator;
     52    private WcfService wcfService;
    5353
    5454    public void Start() {
     
    6060      manager.Core = this;
    6161
    62       clientCommunicator = ServiceLocator.GetClientCommunicator();
    63       clientCommunicator.LoginCompleted += new EventHandler<LoginCompletedEventArgs>(ClientCommunicator_LoginCompleted);
    64       clientCommunicator.PullJobCompleted += new EventHandler<PullJobCompletedEventArgs>(ClientCommunicator_PullJobCompleted);
    65       clientCommunicator.SendJobResultCompleted += new EventHandler<SendJobResultCompletedEventArgs>(ClientCommunicator_SendJobResultCompleted);
    66       //clientCommunicator.LoginAsync(ConfigurationManager.GetInstance().GetClientInfo());
     62      wcfService = WcfService.Instance;
     63      wcfService.Connect("192.168.132.1", "9000");
     64
     65      wcfService.LoginCompleted += new EventHandler<LoginCompletedEventArgs>(wcfService_LoginCompleted);
     66      wcfService.PullJobCompleted += new EventHandler<PullJobCompletedEventArgs>(wcfService_PullJobCompleted);
     67      wcfService.SendJobResultCompleted += new EventHandler<SendJobResultCompletedEventArgs>(wcfService_SendJobResultCompleted);
     68
     69      wcfService.LoginAsync(ConfigurationManager.GetInstance().GetClientInfo());
    6770
    6871      Heartbeat beat = new Heartbeat { Interval = 10000 };
     
    7679        DetermineAction(container);
    7780      }
    78     }
    79 
    80     void ClientCommunicator_LoginCompleted(object sender, LoginCompletedEventArgs e) {
    81       if (e.Result.Success) {
    82         Logging.GetInstance().Info(this.ToString(), "Login completed to Hive Server @ " + DateTime.Now);
    83         ConfigurationManager.GetInstance().Loggedin();
    84         Status.LoginTime = DateTime.Now;
    85         Status.LoggedIn = true;
    86       } else
    87         Logging.GetInstance().Error(this.ToString(), e.Result.StatusMessage);
    8881    }
    8982
     
    10699
    107100        case MessageContainer.MessageType.FetchJob:
    108           clientCommunicator.PullJobAsync(Guid.NewGuid());
     101          wcfService.PullJobAsync(Guid.NewGuid());
    109102          break;         
    110103        case MessageContainer.MessageType.FinishedJob:
     
    115108    }
    116109
     110    #region Async Threads for the EE
     111   
    117112    private void GetFinishedJob(object jobId) {
    118113      long jId = (long)jobId;
     
    120115     
    121116      JobResult jobResult = new JobResult { JobId = jId, Result = sJob, Client = ConfigurationManager.GetInstance().GetClientInfo() };
    122       clientCommunicator.SendJobResultAsync(jobResult, true);
     117      wcfService.SendJobResultAsync(jobResult, true);
    123118    }
    124119
     
    128123    }
    129124
    130     void ClientCommunicator_PullJobCompleted(object sender, PullJobCompletedEventArgs e) {
     125    #endregion
     126
     127    #region wcfService Events
     128
     129    void wcfService_LoginCompleted(object sender, LoginCompletedEventArgs e) {
     130      if (e.Result.Success) {
     131        Logging.GetInstance().Info(this.ToString(), "Login completed to Hive Server @ " + DateTime.Now);
     132        ConfigurationManager.GetInstance().Loggedin();
     133        Status.LoginTime = DateTime.Now;
     134        Status.LoggedIn = true;
     135      } else
     136        Logging.GetInstance().Error(this.ToString(), e.Result.StatusMessage);
     137    }   
     138
     139    void wcfService_PullJobCompleted(object sender, PullJobCompletedEventArgs e) {
    131140      bool sandboxed = false;
    132141
     
    147156    }
    148157
    149     void ClientCommunicator_SendJobResultCompleted(object sender, SendJobResultCompletedEventArgs e) {
     158    void wcfService_SendJobResultCompleted(object sender, SendJobResultCompletedEventArgs e) {
    150159      if (e.Result.Success) {
    151160        AppDomain.Unload(appDomains[e.Result.JobId]);
     
    159168    }
    160169
     170    #endregion
     171
    161172    public Dictionary<long, Executor> GetExecutionEngines() {
    162173      return engines;
  • trunk/sources/HeuristicLab.Hive.Client.Core/Heartbeat.cs

    r798 r923  
    4848    }
    4949
    50     private ClientCommunicatorClient clientCommunicator;
     50    private WcfService wcfService;
    5151
    5252    /// <summary>
     
    5858      heartbeatTimer.AutoReset = true;
    5959      heartbeatTimer.Elapsed += new ElapsedEventHandler(heartbeatTimer_Elapsed);
    60       clientCommunicator = ServiceLocator.GetClientCommunicator();
    61       clientCommunicator.SendHeartBeatCompleted += new EventHandler<SendHeartBeatCompletedEventArgs>(ClientCommunicator_SendHeartBeatCompleted);
     60      wcfService = WcfService.Instance;
     61      wcfService.SendHeartBeatCompleted += new EventHandler<SendHeartBeatCompletedEventArgs>(wcfService_SendHeartBeatCompleted);
    6262      heartbeatTimer.Start();
    6363    }
     
    7474                                                              freeMemory = 1000,
    7575                                                              jobProgress = 1};
    76       clientCommunicator.SendHeartBeatAsync(heartBeatData);
     76      if (wcfService.ConnState == WcfService.ConnectionState.failed) {
     77        wcfService.Connect();
     78      } else if (wcfService.ConnState == WcfService.ConnectionState.connected) {
     79        wcfService.SendHeartBeatAsync(heartBeatData);
     80      }
    7781    }
    7882
    79     void ClientCommunicator_SendHeartBeatCompleted(object sender, SendHeartBeatCompletedEventArgs e) {
     83    void wcfService_SendHeartBeatCompleted(object sender, SendHeartBeatCompletedEventArgs e) {
    8084      System.Diagnostics.Debug.WriteLine("Heartbeat received! ");
    8185      e.Result.ActionRequest.ForEach(mc => MessageQueue.GetInstance().AddMessage(mc));
Note: See TracChangeset for help on using the changeset viewer.