- Timestamp:
- 03/19/09 17:05:34 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs
r1367 r1368 51 51 /// </summary> 52 52 public class Core: MarshalByRefObject { 53 public delegate string GetASnapshotDelegate(); 54 //Todo: private + getter/setter removen. 55 public static Object Locker { get; set; } 56 //Todo: ev. Rename to "abortRequested" 57 public static bool ShutdownFlag { get; set; } 58 59 //Todo: Access modifier 60 Dictionary<long, Executor> engines = new Dictionary<long, Executor>(); 61 Dictionary<long, AppDomain> appDomains = new Dictionary<long, AppDomain>(); 62 Dictionary<long, Job> jobs = new Dictionary<long, Job>(); 53 //Todo: Ask wagner 54 public static Object Locker { get; set; } 55 public static bool abortRequested { get; set; } 56 57 private Dictionary<long, Executor> engines = new Dictionary<long, Executor>(); 58 private Dictionary<long, AppDomain> appDomains = new Dictionary<long, AppDomain>(); 59 private Dictionary<long, Job> jobs = new Dictionary<long, Job>(); 63 60 64 61 private WcfService wcfService; … … 70 67 public void Start() { 71 68 Core.Locker = new Object(); 72 ShutdownFlag= false;69 abortRequested = false; 73 70 74 71 Logging.GetInstance().Info(this.ToString(), "Hive Client started"); … … 101 98 //Main processing loop 102 99 //Todo: own thread for message handling 103 while (!ShutdownFlag) { 100 //Rly?! 101 while (!abortRequested) { 104 102 MessageContainer container = queue.GetMessage(); 105 103 Debug.WriteLine("Main loop received this message: " + container.Message.ToString()); … … 113 111 /// </summary> 114 112 /// <param name="container">The Container, containing the message</param> 115 private void DetermineAction(MessageContainer container) { 116 //Todo: Threads aus Threadpool verwenden 117 113 private void DetermineAction(MessageContainer container) { 118 114 switch (container.Message) { 119 115 //Server requests to abort a job … … 131 127 //Snapshot is ready and can be sent back to the Server 132 128 case MessageContainer.MessageType.SnapshotReady: 133 Thread ssr = new Thread(new ParameterizedThreadStart(GetSnapshot)); 134 ssr.Start(container.JobId); 129 ThreadPool.QueueUserWorkItem(new WaitCallback(GetSnapshot), container.JobId); 130 //Thread ssr = new Thread(new ParameterizedThreadStart(GetSnapshot)); 131 //ssr.Start(container.JobId); 135 132 break; 136 133 //Pull a Job from the Server … … 140 137 //A Job has finished and can be sent back to the server 141 138 case MessageContainer.MessageType.FinishedJob: 142 Thread finThread = new Thread(new ParameterizedThreadStart(GetFinishedJob)); 143 finThread.Start(container.JobId); 139 ThreadPool.QueueUserWorkItem(new WaitCallback(GetFinishedJob), container.JobId); 140 //Thread finThread = new Thread(new ParameterizedThreadStart(GetFinishedJob)); 141 //finThread.Start(container.JobId); 144 142 break; 145 143 //Hard shutdown of the client 146 144 case MessageContainer.MessageType.Shutdown: 147 ShutdownFlag= true;145 abortRequested = true; 148 146 beat.StopHeartBeat(); 149 147 break; … … 155 153 156 154 private void GetFinishedJob(object jobId) { 157 long jId = (long)jobId; 158 //Todo: Don't return null, throw exception! 159 byte[] sJob = engines[jId].GetFinishedJob(); 160 161 if (WcfService.Instance.ConnState == NetworkEnum.WcfConnState.Loggedin) { 162 wcfService.ProcessJobResultAsync(ConfigManager.Instance.GetClientInfo().ClientId, 163 jId, 164 sJob, 165 1, 166 null, 167 true); 168 } else { 169 //Todo: locking 170 JobStorageManager.PersistObjectToDisc(wcfService.ServerIP, wcfService.ServerPort, jId, sJob); 171 AppDomain.Unload(appDomains[jId]); 172 appDomains.Remove(jId); 173 engines.Remove(jId); 174 jobs.Remove(jId); 155 long jId = (long)jobId; 156 try { 157 byte[] sJob = engines[jId].GetFinishedJob(); 158 159 if (WcfService.Instance.ConnState == NetworkEnum.WcfConnState.Loggedin) { 160 wcfService.ProcessJobResultAsync(ConfigManager.Instance.GetClientInfo().ClientId, 161 jId, 162 sJob, 163 1, 164 null, 165 true); 166 } else { 167 JobStorageManager.PersistObjectToDisc(wcfService.ServerIP, wcfService.ServerPort, jId, sJob); 168 lock (Core.Locker) { 169 AppDomain.Unload(appDomains[jId]); 170 appDomains.Remove(jId); 171 engines.Remove(jId); 172 jobs.Remove(jId); 173 } 174 } 175 } 176 catch (InvalidStateException ise) { 177 Logging.GetInstance().Error(this.ToString(), "Exception: ", ise); 175 178 } 176 179 } … … 224 227 } 225 228 } 226 227 //Todo: Remove intellgent stuff from the async event and move it to the main thread (message queue) 229 228 230 //Todo: Seperate this method into 2: Finished jobs and Snapshots 229 231 void wcfService_SendJobResultCompleted(object sender, ProcessJobResultCompletedEventArgs e) { -
trunk/sources/HeuristicLab.Hive.Client.Core/Heartbeat.cs
r1366 r1368 73 73 Console.WriteLine("tick"); 74 74 ClientInfo info = ConfigManager.Instance.GetClientInfo(); 75 // Todo: remove tempfix for free cores. Fix spelling of freeCores (uppercase)75 // Todo: remove tempfix for free cores. 76 76 77 77 HeartBeatData heartBeatData = new HeartBeatData { 78 78 ClientId = info.ClientId, 79 freeCores = info.NrOfCores - (ClientStatusInfo.JobsFetched - ClientStatusInfo.JobsProcessed),80 freeMemory = 1000,81 jobProgress = ConfigManager.Instance.GetProgressOfAllJobs()79 FreeCores = info.NrOfCores - (ClientStatusInfo.JobsFetched - ClientStatusInfo.JobsProcessed), 80 FreeMemory = 1000, 81 JobProgress = ConfigManager.Instance.GetProgressOfAllJobs() 82 82 }; 83 83 if (wcfService.ConnState == NetworkEnum.WcfConnState.Failed) { -
trunk/sources/HeuristicLab.Hive.Client.ExecutionEngine/Executor.cs
r1132 r1368 93 93 //Job isn't finished! 94 94 if (Job.Running) { 95 return null;95 throw new InvalidStateException("Job is still running"); 96 96 } else { 97 97 return SerializeJobObject(); -
trunk/sources/HeuristicLab.Hive.Client.ExecutionEngine/HeuristicLab.Hive.Client.ExecutionEngine.csproj
r1008 r1368 66 66 <Compile Include="Executor.cs" /> 67 67 <Compile Include="ExecutionEnginePlugin.cs" /> 68 <Compile Include="InvalidStateException.cs" /> 68 69 <Compile Include="Properties\AssemblyInfo.cs" /> 69 70 </ItemGroup> -
trunk/sources/HeuristicLab.Hive.Contracts/BusinessObjects/HeartBeatData.cs
r1121 r1368 33 33 public Guid ClientId { get; set; } 34 34 [DataMember] 35 public int freeMemory { get; set; }35 public int FreeMemory { get; set; } 36 36 [DataMember] 37 public int freeCores { get; set; }37 public int FreeCores { get; set; } 38 38 [DataMember] 39 public Dictionary<long, double> jobProgress { get; set; } // TODO: define Type39 public Dictionary<long, double> JobProgress { get; set; } // TODO: define Type 40 40 } 41 41 } -
trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs
r1365 r1368 190 190 response.Success = true; 191 191 response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_HEARTBEAT_RECEIVED; 192 if (hbData. freeCores > 0 && scheduler.ExistsJobForClient(hbData))192 if (hbData.FreeCores > 0 && scheduler.ExistsJobForClient(hbData)) 193 193 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.FetchJob)); 194 194 else 195 195 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.NoMessage)); 196 196 197 if (hbData. jobProgress != null) {197 if (hbData.JobProgress != null) { 198 198 List<Job> jobsOfClient = new List<Job>(jobAdapter.GetActiveJobsOf(clientAdapter.GetById(hbData.ClientId))); 199 199 if (jobsOfClient == null || jobsOfClient.Count == 0) { … … 203 203 } 204 204 205 foreach (KeyValuePair<long, double> jobProgress in hbData. jobProgress) {205 foreach (KeyValuePair<long, double> jobProgress in hbData.JobProgress) { 206 206 Job curJob = jobAdapter.GetById(jobProgress.Key); 207 207 if (curJob.Client == null || curJob.Client.ClientId != hbData.ClientId) {
Note: See TracChangeset
for help on using the changeset viewer.