Changeset 798 for trunk/sources
- Timestamp:
- 11/20/08 17:09:21 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Hive.Client.Core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs
r793 r798 61 61 } 62 62 63 private ClientCommunicatorClient clientCommunicator; 64 63 65 public void Start() { 64 66 Heartbeat beat = new Heartbeat { Interval = 5000 }; … … 67 69 ClientInfo clientInfo = new ClientInfo { ClientId = Guid.NewGuid() }; 68 70 69 ClientCommunicatorClientclientCommunicator = ServiceLocator.GetClientCommunicator();71 clientCommunicator = ServiceLocator.GetClientCommunicator(); 70 72 clientCommunicator.LoginCompleted += new EventHandler<LoginCompletedEventArgs>(ClientCommunicator_LoginCompleted); 71 73 clientCommunicator.LoginAsync(clientInfo); 72 74 73 75 MessageQueue queue = MessageQueue.GetInstance(); 74 queue.AddMessage(MessageContainer.MessageType.FetchJob);75 76 while (true) { 76 77 MessageContainer container = queue.GetMessage(); … … 81 82 } 82 83 83 void ClientCommunicator_LoginCompleted(object sender, LoginCompletedEventArgs e) { 84 void ClientCommunicator_LoginCompleted(object sender, LoginCompletedEventArgs e) { 84 85 if (e.Result.Success) { 85 86 Logging.GetInstance().Info(this.ToString(), "Login completed to Hive Server @ " + DateTime.Now); … … 115 116 break; 116 117 117 118 118 case MessageContainer.MessageType.RequestSnapshot: 119 119 engines[container.JobId].RequestSnapshot(); … … 125 125 126 126 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()); 140 129 break; 141 130 … … 145 134 appDomains.Remove(container.JobId); 146 135 engines.Remove(container.JobId); 136 Status.CurrentJobs--; 137 Debug.WriteLine("Decrement CurrentJobs to:"+Status.CurrentJobs.ToString()); 147 138 break; 139 } 140 } 148 141 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()); 150 160 } 151 161 -
trunk/sources/HeuristicLab.Hive.Client.Core/Heartbeat.cs
r793 r798 78 78 79 79 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)); 85 82 } 86 83 }
Note: See TracChangeset
for help on using the changeset viewer.