Free cookie consent management tool by TermsFeed Policy Generator

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.