Free cookie consent management tool by TermsFeed Policy Generator

Changeset 798 for trunk/sources


Ignore:
Timestamp:
11/20/08 17:09:21 (16 years ago)
Author:
whackl
Message:

implemented serveral services (#376)

Location:
trunk/sources/HeuristicLab.Hive.Client.Core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs

    r793 r798  
    6161    }
    6262
     63    private ClientCommunicatorClient clientCommunicator;
     64
    6365    public void Start() {
    6466      Heartbeat beat = new Heartbeat { Interval = 5000 };
     
    6769      ClientInfo clientInfo = new ClientInfo { ClientId = Guid.NewGuid() };
    6870
    69       ClientCommunicatorClient clientCommunicator = ServiceLocator.GetClientCommunicator();
     71      clientCommunicator = ServiceLocator.GetClientCommunicator();
    7072      clientCommunicator.LoginCompleted += new EventHandler<LoginCompletedEventArgs>(ClientCommunicator_LoginCompleted);
    7173      clientCommunicator.LoginAsync(clientInfo);
    7274
    7375      MessageQueue queue = MessageQueue.GetInstance();
    74       queue.AddMessage(MessageContainer.MessageType.FetchJob);
    7576      while (true) {
    7677        MessageContainer container = queue.GetMessage();
     
    8182    }
    8283
    83     void ClientCommunicator_LoginCompleted(object sender, LoginCompletedEventArgs e) {     
     84    void ClientCommunicator_LoginCompleted(object sender, LoginCompletedEventArgs e) {
    8485      if (e.Result.Success) {
    8586        Logging.GetInstance().Info(this.ToString(), "Login completed to Hive Server @ " + DateTime.Now);
     
    115116          break;
    116117
    117 
    118118        case MessageContainer.MessageType.RequestSnapshot:
    119119          engines[container.JobId].RequestSnapshot();
     
    125125
    126126        case MessageContainer.MessageType.FetchJob:
    127           bool sandboxed = true;
    128 
    129           IJob job = CreateNewJob();
    130 
    131           AppDomain appDomain = CreateNewAppDomain(false);
    132           appDomains.Add(job.JobId, appDomain);
    133 
    134           Executor engine = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName);
    135           engine.Job = job;
    136           engine.JobId = job.JobId;
    137           engine.Queue = MessageQueue.GetInstance();
    138           engine.Start();
    139           engines.Add(engine.JobId, engine);
     127          clientCommunicator.PullJobCompleted += new EventHandler<PullJobCompletedEventArgs>(ClientCommunicator_PullJobCompleted);
     128          clientCommunicator.PullJobAsync(Guid.NewGuid());
    140129          break;
    141130
     
    145134          appDomains.Remove(container.JobId);
    146135          engines.Remove(container.JobId);
     136          Status.CurrentJobs--;
     137          Debug.WriteLine("Decrement CurrentJobs to:"+Status.CurrentJobs.ToString());
    147138          break;
     139      }
     140    }
    148141
    149       }
     142    void ClientCommunicator_PullJobCompleted(object sender, PullJobCompletedEventArgs e) {
     143      bool sandboxed = false;
     144
     145      IJob job = new TestJob { JobId = e.Result.JobId };
     146
     147      AppDomain appDomain = CreateNewAppDomain(sandboxed);
     148      appDomains.Add(job.JobId, appDomain);
     149
     150      Executor engine = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName);
     151      engine.Job = job;
     152      engine.JobId = job.JobId;
     153      engine.Queue = MessageQueue.GetInstance();
     154      engine.Start();
     155      engines.Add(engine.JobId, engine);
     156
     157      Status.CurrentJobs++;
     158
     159      Debug.WriteLine("Increment CurrentJobs to:"+Status.CurrentJobs.ToString());
    150160    }
    151161
  • trunk/sources/HeuristicLab.Hive.Client.Core/Heartbeat.cs

    r793 r798  
    7878
    7979    void ClientCommunicator_SendHeartBeatCompleted(object sender, SendHeartBeatCompletedEventArgs e) {
    80       System.Diagnostics.Debug.WriteLine("Heartbeat received! " + e.Result.ActionRequest.ToString());
    81       foreach (MessageContainer mc in e.Result.ActionRequest) {
    82         MessageQueue.GetInstance().AddMessage(mc);
    83 
    84       }
     80      System.Diagnostics.Debug.WriteLine("Heartbeat received! ");
     81      e.Result.ActionRequest.ForEach(mc => MessageQueue.GetInstance().AddMessage(mc));
    8582    }
    8683  }
Note: See TracChangeset for help on using the changeset viewer.