Changeset 4343
- Timestamp:
- 08/30/10 15:17:19 (14 years ago)
- Location:
- branches/3.3-Hive/sources/HeuristicLab.Hive
- Files:
-
- 1 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Calendar/3.3/Properties/AssemblyInfo.cs
r4342 r4343 58 58 // [assembly: AssemblyVersion("1.0.*")] 59 59 [assembly: AssemblyVersion("3.3.0.0")] 60 [assembly: AssemblyFileVersion("3.3.0.43 38")]60 [assembly: AssemblyFileVersion("3.3.0.4342")] -
branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment.Views/3.3/MenuItems/ConnectionSetupMenuItem.cs
r4342 r4343 44 44 new ConnectionSetupView().Show(); 45 45 } 46 public override int Position { 47 get { return 1600; } 48 } 46 49 } 47 50 } -
branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Communication/3.3/HeuristicLab.Hive.Slave.Communication-3.3.csproj
r4338 r4343 122 122 <DependentUpon>Settings.settings</DependentUpon> 123 123 </Compile> 124 <Compile Include="SlaveService Pool.cs" />124 <Compile Include="SlaveServiceCache.cs" /> 125 125 <Compile Include="WcfService.cs" /> 126 126 </ItemGroup> -
branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Communication/3.3/WcfService.cs
r4338 r4343 78 78 public event EventHandler Connected; 79 79 80 Slave FacadeServicePoolservicePool;80 SlaveServiceCache servicePool; 81 81 82 82 /// <summary> … … 92 92 /// </summary> 93 93 public void Connect() { 94 SlaveService.ISlaveFacade client = null; 95 try { 96 Logger.Debug("Starting the Connection Process"); 97 if (String.Empty.Equals(ServerIp)) { 98 Logger.Info("No Server IP set!"); 99 return; 100 } 101 servicePool = new SlaveFacadeServicePool(ServerIp); 102 103 Logger.Debug("Creating the new connection proxy"); 104 client = servicePool.CreateStreamedSlaveFacade(); 105 Logger.Debug("Created the new connection proxy"); 106 107 ConnState = NetworkEnum.WcfConnState.Connected; 108 ConnectedSince = DateTime.Now; 109 110 if (Connected != null) { 111 Connected(this, new EventArgs()); 112 } 113 if (ConnState == NetworkEnum.WcfConnState.Failed) { 114 ConnectionRestored(this, new EventArgs()); 115 } 116 } 117 catch (Exception ex) { 118 HandleNetworkError(ex); 119 } 120 finally { 121 servicePool.DisposeSlaveClient(client); 94 servicePool = new SlaveServiceCache(ServerIp); 95 using (DisposableSlaveFacadeClient client = servicePool.GetStreamedSlaveFacade()) { 96 try { 97 Logger.Debug("Starting the Connection Process"); 98 if (String.Empty.Equals(ServerIp)) { 99 Logger.Info("No Server IP set!"); 100 return; 101 } 102 ConnState = NetworkEnum.WcfConnState.Connected; 103 ConnectedSince = DateTime.Now; 104 105 if (Connected != null) { 106 Connected(this, new EventArgs()); 107 } 108 if (ConnState == NetworkEnum.WcfConnState.Failed) { 109 ConnectionRestored(this, new EventArgs()); 110 } 111 } 112 catch (Exception ex) { 113 HandleNetworkError(ex); 114 } 122 115 } 123 116 } … … 145 138 /// </summary> 146 139 public void Login(SlaveDto slaveInfo) { 147 SlaveService.ISlaveFacade client = null; 148 try { 149 if (ConnState == NetworkEnum.WcfConnState.Connected) { 150 Logger.Debug("STARTED: Login Sync"); 151 client = servicePool.CreateSlaveFacade(); 152 Response res = client.Login(slaveInfo); 153 if (res.StatusMessage != ResponseStatus.Ok) { 154 Logger.Error("FAILED: Login Failed! " + res.StatusMessage); 155 throw new Exception(res.StatusMessage.ToString()); 156 } else { 157 Logger.Info("ENDED: Login succeeded" + res.StatusMessage); 158 LoggedIn = true; 159 } 160 } 161 } 162 catch (Exception e) { 163 HandleNetworkError(e); 164 } 165 finally { 166 servicePool.DisposeSlaveClient(client); 140 using (DisposableSlaveFacadeClient client = servicePool.GetSlaveFacade()) { 141 try { 142 if (ConnState == NetworkEnum.WcfConnState.Connected) { 143 Logger.Debug("STARTED: Login Sync"); 144 Response res = client.Login(slaveInfo); 145 if (res.StatusMessage != ResponseStatus.Ok) { 146 Logger.Error("FAILED: Login Failed! " + res.StatusMessage); 147 throw new Exception(res.StatusMessage.ToString()); 148 } else { 149 Logger.Info("ENDED: Login succeeded" + res.StatusMessage); 150 LoggedIn = true; 151 } 152 } 153 } 154 catch (Exception e) { 155 HandleNetworkError(e); 156 } 167 157 } 168 158 } … … 175 165 public void GetJobAsync(Guid guid) { 176 166 if (LoggedIn) { 167 DisposableSlaveFacadeClient client = servicePool.GetStreamedSlaveFacade(); 177 168 Logger.Debug("STARTED: Fetching of Jobs from Server for Slave"); 178 SlaveService.ISlaveFacade client = servicePool.CreateStreamedSlaveFacade();179 //client.GetStreamedJobAsync(guid);180 169 client.BeginGetStreamedJob(guid, (ar => { 181 170 if (ar.IsCompleted) { … … 213 202 if (memStream != null) 214 203 memStream.Dispose(); 204 205 servicePool.ReleaseSlaveClient(client); 215 206 } 216 207 } else 217 208 HandleNetworkError(new FaultException("GetJobAsync did not complete")); 218 219 servicePool.DisposeSlaveClient(client);220 209 }), null); 221 210 } … … 231 220 public void GetFinishedJobResultAsync(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception, bool finished) { 232 221 if (LoggedIn) { 222 DisposableSlaveFacadeClient client = servicePool.GetStreamedSlaveFacade(); 233 223 Logger.Debug("STARTED: Sending back the finished job results"); 234 224 Logger.Debug("Building stream"); … … 236 226 Logger.Debug("Builded stream"); 237 227 Logger.Debug("Making the call"); 238 //proxy.StoreFinishedJobResultStreamedAsync(stream, stream); 239 SlaveService.ISlaveFacade client = servicePool.CreateStreamedSlaveFacade(); 228 240 229 client.BeginStoreFinishedJobResultStreamed(stream, (ar => { 241 Logger.Debug("Finished storing the job"); 242 if (stream != null) 243 stream.Dispose(); 244 245 if (ar.IsCompleted) { 246 var res = client.EndStoreFinishedJobResultStreamed(ar); 247 StoreFinishedJobResultCompletedEventArgs args = new StoreFinishedJobResultCompletedEventArgs(new object[] { res }, null, false, null); 248 Logger.Debug("calling the Finished Job Event"); 249 GetFinishedJobResultCompleted(this, args); 250 Logger.Debug("ENDED: Sending back the finished job results"); 251 } else { 252 HandleNetworkError(new FaultException("GetFinishedJobResultAsync did not complete")); 253 } 254 servicePool.DisposeSlaveClient(client); 230 try { 231 Logger.Debug("Finished storing the job"); 232 if (stream != null) 233 stream.Dispose(); 234 235 if (ar.IsCompleted) { 236 var res = client.EndStoreFinishedJobResultStreamed(ar); 237 StoreFinishedJobResultCompletedEventArgs args = new StoreFinishedJobResultCompletedEventArgs(new object[] { res }, null, false, null); 238 Logger.Debug("calling the Finished Job Event"); 239 GetFinishedJobResultCompleted(this, args); 240 Logger.Debug("ENDED: Sending back the finished job results"); 241 } else { 242 HandleNetworkError(new FaultException("GetFinishedJobResultAsync did not complete")); 243 } 244 } 245 finally { 246 servicePool.ReleaseSlaveClient(client); 247 } 255 248 }), null); 256 249 } … … 263 256 public void ProcessSnapshotAsync(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception, bool finished) { 264 257 if (LoggedIn) { 258 DisposableSlaveFacadeClient client = servicePool.GetStreamedSlaveFacade(); 259 265 260 Stream stream = GetStreamedJobResult(clientId, jobId, result, percentage, exception); 266 //proxy.ProcessSnapshotStreamedAsync(stream, stream);267 SlaveService.ISlaveFacade client = servicePool.CreateStreamedSlaveFacade();268 261 client.BeginProcessSnapshotStreamed(stream, (ar => { 269 if (stream != null) 270 stream.Dispose(); 271 272 if (ar.IsCompleted) { 273 var res = client.EndStoreFinishedJobResultStreamed(ar); 274 ProcessSnapshotCompletedEventArgs args = new ProcessSnapshotCompletedEventArgs(new object[] { res }, null, false, null); 275 ProcessSnapshotCompleted(this, args); 262 try { 263 if (stream != null) 264 stream.Dispose(); 265 266 if (ar.IsCompleted) { 267 var res = client.EndStoreFinishedJobResultStreamed(ar); 268 ProcessSnapshotCompletedEventArgs args = new ProcessSnapshotCompletedEventArgs(new object[] { res }, null, false, null); 269 ProcessSnapshotCompleted(this, args); 270 } else { 271 HandleNetworkError(new FaultException("ProcessSnapshotAsync did not complete")); 272 } 273 } 274 finally { 275 servicePool.ReleaseSlaveClient(client); 276 } 277 }), null); 278 } 279 } 280 281 #endregion 282 283 /// <summary> 284 /// Methods for sending the periodically Heartbeat 285 /// </summary> 286 #region Heartbeat 287 288 public event System.EventHandler<ProcessHeartBeatCompletedEventArgs> ProcessHeartBeatCompleted; 289 public void ProcessHeartBeatSync(HeartBeatData hbd) { 290 if (LoggedIn) { 291 using (DisposableSlaveFacadeClient client = servicePool.GetStreamedSlaveFacade()) { 292 Logger.Debug("STARTING: sending heartbeat"); 293 var res = client.ProcessHeartBeat(hbd); 294 295 if (res.StatusMessage == ResponseStatus.Ok) { 296 ProcessHeartBeatCompleted(this, new ProcessHeartBeatCompletedEventArgs(new object[] { res }, null, false, null)); 297 Logger.Debug("ENDED: sending heartbeats"); 276 298 } else { 277 HandleNetworkError(new FaultException("ProcessSnapshotAsync did not complete")); 278 } 279 servicePool.DisposeSlaveClient(client); 280 }), null); 281 } 282 } 283 284 #endregion 285 286 /// <summary> 287 /// Methods for sending the periodically Heartbeat 288 /// </summary> 289 #region Heartbeat 290 291 public event System.EventHandler<ProcessHeartBeatCompletedEventArgs> ProcessHeartBeatCompleted; 292 public void ProcessHeartBeatAsync(HeartBeatData hbd) { 293 if (LoggedIn) { 294 Logger.Debug("STARTING: sending heartbeat"); 295 //proxy.ProcessHeartBeatAsync(hbd); 296 SlaveService.ISlaveFacade client = servicePool.CreateStreamedSlaveFacade(); 297 client.BeginProcessHeartBeat(hbd, (ar => { 298 if (ar.IsCompleted) { 299 var res = client.EndProcessHeartBeat(ar); 300 if (res.StatusMessage == ResponseStatus.Ok) { 301 ProcessHeartBeatCompleted(this, new ProcessHeartBeatCompletedEventArgs(new object[] { res }, null, false, null)); 302 Logger.Debug("ENDED: sending heartbeats"); 303 } else { 304 Logger.Error("FAILED: sending heartbeats: " + res.StatusMessage.ToString()); 305 } 306 } else { 307 HandleNetworkError(new FaultException("ProcessHeartBeatAsync did not complete")); 308 } 309 servicePool.DisposeSlaveClient(client); 310 }), null); 299 Logger.Error("FAILED: sending heartbeats: " + res.StatusMessage.ToString()); 300 } 301 } 311 302 } 312 303 } … … 337 328 338 329 public ResponseResultReceived StoreFinishedJobResultsSync(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception, bool finished) { 339 SlaveService.ISlaveFacade client = servicePool.CreateStreamedSlaveFacade();340 ResponseResultReceived res = client.StoreFinishedJobResultStreamed(GetStreamedJobResult(clientId, jobId, result, percentage, exception));341 servicePool.DisposeSlaveClient(client);342 return res;330 using (DisposableSlaveFacadeClient client = servicePool.GetStreamedSlaveFacade()) { 331 ResponseResultReceived res = client.StoreFinishedJobResultStreamed(GetStreamedJobResult(clientId, jobId, result, percentage, exception)); 332 return res; 333 } 343 334 } 344 335 … … 346 337 try { 347 338 Logger.Debug("STARTING: Sync call: IsJobStillNeeded"); 348 SlaveService.ISlaveFacade client = servicePool.CreateStreamedSlaveFacade();349 Response res = client.IsJobStillNeeded(jobId);350 servicePool.DisposeSlaveClient(client);351 Logger.Debug("ENDED: Sync call: IsJobStillNeeded");352 return res;339 using (DisposableSlaveFacadeClient client = servicePool.GetStreamedSlaveFacade()) { 340 Response res = client.IsJobStillNeeded(jobId); 341 Logger.Debug("ENDED: Sync call: IsJobStillNeeded"); 342 return res; 343 } 353 344 } 354 345 catch (Exception e) { … … 360 351 public ResponseResultReceived ProcessSnapshotSync(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception) { 361 352 try { 362 SlaveService.ISlaveFacade client = servicePool.CreateStreamedSlaveFacade(); 363 var res = client.ProcessSnapshotStreamed(GetStreamedJobResult(clientId, jobId, result, percentage, exception)); 364 servicePool.DisposeSlaveClient(client); 365 return res; 353 using (DisposableSlaveFacadeClient client = servicePool.GetStreamedSlaveFacade()) { 354 return client.ProcessSnapshotStreamed(GetStreamedJobResult(clientId, jobId, result, percentage, exception)); 355 } 366 356 } 367 357 catch (Exception e) { … … 373 363 public IEnumerable<CachedHivePluginInfoDto> RequestPlugins(List<HivePluginInfoDto> requestedPlugins) { 374 364 try { 375 Logger.Debug("STARTED: Requesting Plugins for Job");376 Logger.Debug("STARTED: Getting the stream");377 SlaveService.ISlaveFacade client = servicePool.CreateStreamedSlaveFacade();378 Stream stream = client.GetStreamedPlugins(requestedPlugins.ToArray());379 servicePool.DisposeSlaveClient(client);380 Logger.Debug("ENDED: Getting the stream");381 BinaryFormatter formatter = new BinaryFormatter();382 Logger.Debug("STARTED: Deserializing the stream");383 ResponseList<CachedHivePluginInfoDto> response = (ResponseList<CachedHivePluginInfoDto>)formatter.Deserialize(stream);384 Logger.Debug("ENDED: Deserializing the stream");385 if (stream != null)386 stream.Dispose();387 return response.List;365 using (DisposableSlaveFacadeClient client = servicePool.GetStreamedSlaveFacade()) { 366 Logger.Debug("STARTED: Requesting Plugins for Job"); 367 Logger.Debug("STARTED: Getting the stream"); 368 Stream stream = client.GetStreamedPlugins(requestedPlugins.ToArray()); 369 Logger.Debug("ENDED: Getting the stream"); 370 BinaryFormatter formatter = new BinaryFormatter(); 371 Logger.Debug("STARTED: Deserializing the stream"); 372 ResponseList<CachedHivePluginInfoDto> response = (ResponseList<CachedHivePluginInfoDto>)formatter.Deserialize(stream); 373 Logger.Debug("ENDED: Deserializing the stream"); 374 if (stream != null) 375 stream.Dispose(); 376 return response.List; 377 } 388 378 } 389 379 catch (Exception e) { … … 396 386 try { 397 387 Logger.Debug("STARTED: Logout"); 398 SlaveService.ISlaveFacade client = servicePool.CreateStreamedSlaveFacade();399 client.Logout(guid);400 servicePool.DisposeSlaveClient(client);388 using (DisposableSlaveFacadeClient client = servicePool.GetStreamedSlaveFacade()) { 389 client.Logout(guid); 390 } 401 391 Logger.Debug("ENDED: Logout"); 402 392 } … … 409 399 try { 410 400 Logger.Debug("STARTED: Syncing Calendars"); 411 SlaveService.ISlaveFacade client = servicePool.CreateStreamedSlaveFacade();412 ResponseCalendar cal = client.GetCalendar(clientId);413 servicePool.DisposeSlaveClient(client);414 Logger.Debug("ENDED: Syncing Calendars");415 return cal;401 using (DisposableSlaveFacadeClient client = servicePool.GetStreamedSlaveFacade()) { 402 ResponseCalendar cal = client.GetCalendar(clientId); 403 Logger.Debug("ENDED: Syncing Calendars"); 404 return cal; 405 } 416 406 } 417 407 catch (Exception e) { … … 424 414 try { 425 415 Logger.Debug("STARTED: Setting Calendar status to: " + state); 426 SlaveService.ISlaveFacade client = servicePool.CreateStreamedSlaveFacade();427 Response resp = client.SetCalendarStatus(clientId, state);428 servicePool.DisposeSlaveClient(client);429 Logger.Debug("ENDED: Setting Calendar status to: " + state);430 return resp;416 using (DisposableSlaveFacadeClient client = servicePool.GetStreamedSlaveFacade()) { 417 Response resp = client.SetCalendarStatus(clientId, state); 418 Logger.Debug("ENDED: Setting Calendar status to: " + state); 419 return resp; 420 } 431 421 } 432 422 catch (Exception e) { -
branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Core/3.3/HeartbeatManager.cs
r4342 r4343 104 104 105 105 Logger.Debug("Sending Heartbeat: " + heartBeatData); 106 wcfService.ProcessHeartBeat Async(heartBeatData);106 wcfService.ProcessHeartBeatSync(heartBeatData); 107 107 } 108 108
Note: See TracChangeset
for help on using the changeset viewer.