Changeset 1133
- Timestamp:
- 01/15/09 14:53:13 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Contracts/ApplicationConstants.cs
r1121 r1133 68 68 public static string RESPONSE_COMMUNICATOR_NO_JOBS_LEFT = "Communicator.NoJobsLeft"; 69 69 public static string RESPONSE_COMMUNICATOR_ID_MUST_NOT_BE_SET = "Communicator.IdMustNotBeSet"; 70 public static string RESPONSE_COMMUNICATOR_NO_JO _WITH_THIS_ID = "Communicator.NoJobWithThisId";70 public static string RESPONSE_COMMUNICATOR_NO_JOB_WITH_THIS_ID = "Communicator.NoJobWithThisId"; 71 71 public static string RESPONSE_COMMUNICATOR_WRONG_JOB_STATE = "Communicator.WrongJobState"; 72 72 public static string RESPONSE_COMMUNICATOR_USER_NOT_LOGGED_IN = "Communicator.UserNotLoggedIn"; 73 public static string RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED = "Communicator.JobIsNotBeenigCalculated"; 74 public static string RESPONSE_COMMUNICATOR_WRONG_CLIENT_FOR_JOB = "Communicator.WrongClientForJob"; 73 75 74 76 public static string RESPONSE_JOB_ALL_JOBS = "Job.AllJobs"; -
trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/JobResult.cs
r1103 r1133 35 35 public Job Job { get; set; } 36 36 [DataMember] 37 public byte[] Result { get; set; } // TODO DataStructure for Result needs to be defined 37 public byte[] Result { get; set; } 38 [DataMember] 39 public double Percentage { get; set; } 40 [DataMember] 41 public DateTime timestamp { get; set; } 38 42 [DataMember] 39 43 public ClientInfo Client { get; set; } -
trunk/sources/HeuristicLab.Hive.Contracts/HiveServerMessages.resx
r1096 r1133 229 229 <value>User is not logged in, you must login before sending Heartbeats</value> 230 230 </data> 231 <data name="Communicator.JobIsNotBeenigCalculated" xml:space="preserve"> 232 <value>There is no client registered to calculate this job</value> 233 </data> 234 <data name="Communicator.WrongClientForJob" xml:space="preserve"> 235 <value>This client is not registered to calculate this job</value> 236 </data> 231 237 </root> -
trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/IClientCommunicator.cs
r1103 r1133 43 43 long jobId, 44 44 byte[] result, 45 double percentage, 45 46 Exception exception, 46 47 bool finished); -
trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/ILifecycleManager.cs
r1088 r1133 38 38 /// The server heartbeat 39 39 /// </summary> 40 event EventHandler OnServerHeartbeat; 40 void RegisterHeartbeat(EventHandler handler); 41 42 /// <summary> 43 /// The startup event 44 /// </summary> 45 void RegisterStartup(EventHandler handler); 46 47 /// <summary> 48 /// The shutdown event 49 /// </summary> 50 void RegisterShutdown(EventHandler handler); 41 51 42 52 /// <summary> -
trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs
r1127 r1133 58 58 lifecycleManager = ServiceLocator.GetLifecycleManager(); 59 59 60 lifecycleManager. OnServerHeartbeat +=61 new EventHandler(lifecycleManager_OnServerHeartbeat) ;60 lifecycleManager.RegisterHeartbeat( 61 new EventHandler(lifecycleManager_OnServerHeartbeat)); 62 62 63 63 lastHeartbeats = new Dictionary<Guid, DateTime>(); … … 90 90 foreach (Job job in allJobs) { 91 91 if (job.Client.ClientId == client.ClientId) { 92 // TODO check for job results 92 List<JobResult> allJobResults = new List<JobResult>(jobResultAdapter.GetAll()); 93 foreach (JobResult jR in allJobResults) { 94 JobResult lastJobResult = null; 95 if (jR.Job != null && jR.Job.Id == job.Id) { 96 if (lastJobResult != null) { 97 98 } 99 } 100 } 101 102 93 103 job.Client = null; 94 104 job.Percentage = 0; … … 231 241 long jobId, 232 242 byte[] result, 243 double percentage, 233 244 Exception exception, 234 245 bool finished) { … … 239 250 Job job = 240 251 jobAdapter.GetById(jobId); 252 253 if (job.Client == null) { 254 response.Success = false; 255 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED; 256 return response; 257 } 258 if (job.Client.ClientId != clientId) { 259 response.Success = false; 260 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_CLIENT_FOR_JOB; 261 return response; 262 } 241 263 if (job == null) { 242 264 response.Success = false; 243 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JO _WITH_THIS_ID;265 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOB_WITH_THIS_ID; 244 266 return response; 245 267 } … … 249 271 return response; 250 272 } 273 job.SerializedJob = result; 274 job.Percentage = percentage; 275 251 276 if (finished) { 252 277 job.State = State.finished; … … 263 288 jobResult.Job = job; 264 289 jobResult.Result = result; 290 jobResult.Percentage = percentage; 265 291 jobResult.Exception = exception; 266 292 267 jobResultAdapter.Update(jobResult); 293 jobResultAdapter.Update(jobResult); 294 jobAdapter.Update(job); 268 295 269 296 response.Success = true; -
trunk/sources/HeuristicLab.Hive.Server.Core/ClientFacade.cs
r1103 r1133 51 51 long jobId, 52 52 byte[] result, 53 double percentage, 53 54 Exception exception, 54 55 bool finished) { 55 return clientCommunicator.SendJobResult(clientId, jobId, result, exception, finished);56 return clientCommunicator.SendJobResult(clientId, jobId, result, percentage, exception, finished); 56 57 } 57 58 -
trunk/sources/HeuristicLab.Hive.Server.Core/JobManager.cs
r1121 r1133 33 33 34 34 IJobAdapter jobAdapter; 35 ILifecycleManager lifecycleManager; 35 36 36 37 #region IJobManager Members … … 38 39 public JobManager() { 39 40 jobAdapter = ServiceLocator.GetJobAdapter(); 41 42 lifecycleManager = ServiceLocator.GetLifecycleManager(); 43 44 lifecycleManager.RegisterStartup(new EventHandler(lifecycleManager_OnStartup)); 45 lifecycleManager.RegisterStartup(new EventHandler(lifecycleManager_OnShutdown)); 46 } 47 48 void checkForDeadJobs() { 49 List<Job> allJobs = new List<Job>(jobAdapter.GetAll()); 50 foreach (Job curJob in allJobs) { 51 if (curJob.State == State.calculating) { 52 // TODO check for job results 53 curJob.State = State.idle; 54 curJob.Percentage = 0; 55 curJob.Client = null; 56 } 57 } 58 } 59 60 void lifecycleManager_OnStartup(object sender, EventArgs e) { 61 checkForDeadJobs(); 62 } 63 64 void lifecycleManager_OnShutdown(object sender, EventArgs e) { 65 checkForDeadJobs(); 40 66 } 41 67 -
trunk/sources/HeuristicLab.Hive.Server.Core/LifecycleManager.cs
r1088 r1133 33 33 new Timer(); 34 34 35 private static event EventHandler OnServerHeartbeat; 36 private static event EventHandler OnStartup; 37 private static event EventHandler OnShutdown; 35 38 #region ILifecycleManager Members 36 public event EventHandler OnServerHeartbeat;37 39 38 public LifecycleManager() { 39 timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); 40 public void RegisterHeartbeat(EventHandler handler) { 41 OnServerHeartbeat += handler; 42 } 43 44 public void RegisterStartup(EventHandler handler) { 45 OnStartup += handler; 46 } 47 48 public void RegisterShutdown(EventHandler handler) { 49 OnShutdown += handler; 40 50 } 41 51 42 52 public void Init() { 43 53 timer.Interval = new TimeSpan(0, 0, 10).TotalMilliseconds; // TODO: global constant needed 54 timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); 44 55 timer.Start(); 56 57 if (OnStartup != null) 58 OnStartup(this, null); 45 59 } 46 60 … … 56 70 public void Shutdown() { 57 71 ServiceLocator.GetTransactionManager().UpdateDB(); 72 73 if (OnShutdown != null) 74 OnShutdown(this, null); 58 75 } 59 76
Note: See TracChangeset
for help on using the changeset viewer.