Changeset 4264 for branches/3.3-HiveMigration/sources/HeuristicLab.Hive
- Timestamp:
- 08/19/10 13:30:56 (14 years ago)
- Location:
- branches/3.3-HiveMigration/sources/HeuristicLab.Hive
- Files:
-
- 3 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Contracts/3.3/ApplicationConstants.cs
r4263 r4264 35 35 /// </summary> 36 36 public static System.Transactions.IsolationLevel ISOLATION_LEVEL_SCOPE = System.Transactions.IsolationLevel.ReadUncommitted; 37 37 38 public static int HEARTBEAT_MAX_DIF = 120; // value in seconds 39 38 40 public static int JOB_TIME_TO_LIVE = 5; 39 40 //public static string RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS = "Logged in";41 //public static string RESPONSE_SERVERCONSOLE_LOGIN_FAILED = "Login failed";42 43 //public static string RESPONSE_USERROLE_GET_ALL_USERS = "UserRole.GetAllUsers";44 //public static string RESPONSE_USERROLE_USER_EXISTS_ALLREADY = "UserRole.UserExistsAllready";45 //public static string RESPONSE_USERROLE_USER_SUCCESSFULLY_ADDED = "UserRole.UserSuccessfullyAdded";46 //public static string RESPONSE_USERROLE_USER_DOESNT_EXIST = "UserRole.UserDoesntExist";47 //public static string RESPONSE_USERROLE_USER_REMOVED = "UserRole.UserRemoved";48 //public static string RESPONSE_USERROLE_USERGROUP_EXISTS_ALLREADY = "UserRole.UsergroupExistsAllready";49 //public static string RESPONSE_USERROLE_USERGROUP_ADDED = "UserRole.UserGroupAdded";50 //public static string RESPONSE_USERROLE_USERGROUP_DOESNT_EXIST = "UserRole.UserGroupDoesntExist";51 //public static string RESPONSE_USERROLE_PERMISSIONOWNER_DOESNT_EXIST = "UserRole.PermissionOwnerDoesntExist";52 //public static string RESPONSE_USERROLE_PERMISSIONOWNER_REMOVED = "UserRole.PermissionOwnerRemoved";53 //public static string RESPONSE_USERROLE_PERMISSIONOWNER_ADDED = "UserRole.PermissionOwnerAdded";54 //public static string RESPONSE_USERROLE_GET_ALL_USERGROUPS = "UserRole.AllUserGroupsReturned";55 //public static string RESPONSE_USERROLE_ID_MUST_NOT_BE_SET = "UserRole.IdMustNotBeSet";56 //public static string RESPONSE_USERROLE_USERGROUP_ADDED_TO_USERGROUP = "UserRole.UserGroupAddedToUserGroup";57 //public static string RESPONSE_USERROLE_USERNAME_EXISTS_ALLREADY = "UserRole.UsernameExistsAllready";58 59 //public static string RESPONSE_CLIENT_GET_ALL_CLIENTS = "Client.GetAllClients";60 //public static string RESPONSE_CLIENT_GET_ALL_CLIENTGROUPS = "Client.GetAllClientGroups";61 //public static string RESPONSE_CLIENT_ID_MUST_NOT_BE_SET = "Client.IdMustNotBeSet";62 //public static string RESPONSE_CLIENT_CLIENTGROUP_ADDED = "Client.ClientGroupAdded";63 //public static string RESPONSE_CLIENT_CLIENTGROUP_DOESNT_EXIST = "Client.ClientGroupDoesntExist";64 //public static string RESPONSE_CLIENT_CLIENTGROUP_DELETED = "Client group sucessfully deleted";65 //public static string RESPONSE_CLIENT_RESOURCE_ADDED_TO_GROUP = "Client.ResourceAddedToGroup";66 //public static string RESPONSE_CLIENT_RESOURCE_REMOVED = "Client.ResourceRemoved";67 //public static string RESPONSE_CLIENT_RESOURCE_NOT_FOUND = "Client.ResourceNotFound";68 //public static string RESPONSE_CLIENT_PERMISSIONOWNER_DOESNT_EXIST = "Client.PermissionOwnerDoesntExist";69 //public static string RESPONSE_CLIENT_GET_GROUPS_OF_CLIENT = "Get all groups of a client";70 71 //public static string RESPONSE_COMMUNICATOR_HEARTBEAT_RECEIVED = "Communicator.HeardbeatReceived";72 //public static string RESPONSE_COMMUNICATOR_JOB_PULLED = "Communicator.JobPulled";73 //public static string RESPONSE_COMMUNICATOR_JOBRESULT_RECEIVED = "Communicator.JobResultReceived";74 //public static string RESPONSE_COMMUNICATOR_LOGIN_USER_ALLREADY_ONLINE = "Communicator.LoginUserAllreadyOnline";75 //public static string RESPONSE_COMMUNICATOR_LOGIN_SUCCESS = "Communicator.LoginSuccess";76 //public static string RESPONSE_COMMUNICATOR_LOGOUT_CLIENT_NOT_REGISTERED = "Communicator.LogoutClientNotRegistered";77 //public static string RESPONSE_COMMUNICATOR_LOGOUT_SUCCESS = "Communicator.LogoutSuccess";78 //public static string RESPONSE_COMMUNICATOR_NO_JOBS_LEFT = "Communicator.NoJobsLeft";79 //public static string RESPONSE_COMMUNICATOR_ID_MUST_NOT_BE_SET = "Communicator.IdMustNotBeSet";80 //public static string RESPONSE_COMMUNICATOR_NO_JOB_WITH_THIS_ID = "Communicator.NoJobWithThisId";81 //public static string RESPONSE_COMMUNICATOR_WRONG_JOB_STATE = "Communicator.WrongJobState";82 //public static string RESPONSE_COMMUNICATOR_USER_NOT_LOGGED_IN = "Communicator.UserNotLoggedIn";83 //public static string RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED = "Communicator.JobIsNotBeenigCalculated";84 //public static string RESPONSE_COMMUNICATOR_WRONG_CLIENT_FOR_JOB = "Communicator.WrongClientForJob";85 //public static string RESPONSE_COMMUNICATOR_JOB_ALLREADY_FINISHED = "Job allready finished. Not needed anymore";86 //public static string RESPONSE_COMMUNICATOR_JOB_DOESNT_EXIST = "No job exists with this id";87 //public static string RESPONSE_COMMUNICATOR_SEND_JOBRESULT = "Please send the Jobresult to the server";88 //public static string RESPONSE_COMMUNICATOR_PLUGINS_SENT = "Communicator.PluginsSent";89 //public static string RESPONSE_COMMUNICATOR_PLUGINS_NOT_AVAIL = "Communicator.PluginsNotAvail";90 //public static string RESPONSE_COMMUNICATOR_JOB_WAS_ABORTED = "Job was aborted";91 92 //public static string RESPONSE_COMMUNICATOR_FETCH_OR_FORCEFETCH_CALENDAR = "new Calendar must be fetched / force fetched";93 94 //public static string RESPONSE_JOB_ALL_JOBS = "Job.AllJobs";95 //public static string RESPONSE_JOB_GET_JOB_BY_ID = "Job.GetJobById";96 //public static string RESPONSE_JOB_ID_MUST_NOT_BE_SET = "Job.IdMustNotBeSet";97 //public static string RESPONSE_JOB_JOB_ADDED = "Job.JobAdded";98 //public static string RESPONSE_JOB_JOB_NULL = "Job.JobNull";99 //public static string RESPONSE_JOB_JOB_DOESNT_EXIST = "JobDoesntExist";100 //public static string RESPONSE_JOB_JOB_REMOVED = "Job.JobRemoved";101 //public static string RESPONSE_JOB_JOBSTATE_MUST_BE_OFFLINE = "Job.JobStateMustBeOffline";102 //public static string RESPONSE_JOB_IS_NOT_BEEING_CALCULATED = "Job.IsNotBeeingCalculated";103 //public static string RESPONSE_JOB_JOB_RESULT_SENT = "Job.JobResultSent";104 //public static string RESPONSE_JOB_REQUEST_ALLREADY_SET = "Job.RequestAllreadySet";105 //public static string RESPONSE_JOB_ABORT_REQUEST_ALLREADY_SET = "Job.AbortRequestAllreadySet";106 //public static string RESPONSE_JOB_REQUEST_SET = "Job.RequestSet";107 //public static string RESPONSE_JOB_ABORT_REQUEST_SET = "Job.AbortRequestSet";108 //public static string RESPONSE_JOB_RESULT_NOT_YET_HERE = "Requested job result is not yet finished";109 //public static string RESPONSE_JOB_PROJECT_NAME_EMPTY = "Please specifiy a project name";110 //public static string RESPONSE_JOB_PROJECT_ADDED = "Project successfully added";111 //public static string RESPONSE_JOB_PROJECT_DOESNT_EXIST = "The specified project doesn't exist";112 //public static string RESPONSE_JOB_PROJECT_DELETED = "The project was sucessfully deleted";113 114 //public static string RESPONSE_UPTIMECALENDAR_NO_CALENDAR_FOUND = "No Calendar could be found anywhere in the tree";115 //public static string RESPONSE_UPTIMECALENDAR_STATUS_UPDATED = "Calendar status has been updated";116 41 } 117 42 } -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Contracts/3.3/BusinessObjects/ClientDto.cs
r4141 r4264 29 29 30 30 namespace HeuristicLab.Hive.Contracts.BusinessObjects { 31 32 public enum State { NullState, Idle, Calculating, Offline, Finished, Abort, RequestSnapshot, RequestSnapshotSent, Pending, Failed };33 public enum CalendarState { Fetch, ForceFetch, Fetching, Fetched, NotAllowedToFetch };34 35 31 [StorableClass] 36 32 [DataContract] … … 57 53 [Storable] 58 54 [DataMember] 59 public S tate State { get; set; }55 public SlaveState State { get; set; } 60 56 [Storable] 61 57 [DataMember] -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Contracts/3.3/BusinessObjects/HeartBeatData.cs
r4253 r4264 38 38 [DataMember] 39 39 public Dictionary<Guid, double> JobProgress { get; set; } // TODO: define Type 40 [DataMember] 41 public bool IsAllowedToCalculate { get; set; } // this is true if slave is allowed to work according to calendar 40 42 41 43 public override string ToString() { -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Contracts/3.3/BusinessObjects/JobDto.cs
r4144 r4264 38 38 [Storable] 39 39 [DataMember] 40 public State State { get; set; }40 public JobState State { get; set; } 41 41 [Storable] 42 42 [DataMember] -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Contracts/3.3/BusinessObjects/JobResult.cs
r4170 r4264 44 44 [Storable] 45 45 [DataMember] 46 public State State { get; set; }46 public JobState State { get; set; } 47 47 [Storable] 48 48 [DataMember] -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Contracts/3.3/HeuristicLab.Hive.Contracts-3.3.csproj
r4263 r4264 118 118 <Compile Include="BusinessObjects\AppointmentDto.cs" /> 119 119 <Compile Include="BusinessObjects\CachedHivePluginInfoDto.cs" /> 120 <Compile Include="BusinessObjects\CalendarState.cs" /> 120 121 <Compile Include="BusinessObjects\ClientGroupDto.cs" /> 121 122 <Compile Include="BusinessObjects\HivePluginFile.cs" /> 122 123 <Compile Include="BusinessObjects\JobResultList.cs" /> 124 <Compile Include="BusinessObjects\JobState.cs" /> 123 125 <Compile Include="BusinessObjects\ResourceDto.cs" /> 124 126 <Compile Include="BusinessObjects\SerializedJob.cs" /> … … 129 131 <Compile Include="BusinessObjects\JobResult.cs" /> 130 132 <Compile Include="BusinessObjects\SerializedJobResult.cs" /> 133 <Compile Include="BusinessObjects\SlaveState.cs" /> 131 134 <Compile Include="BusinessObjects\UpTimeStatisticsDto.cs" /> 132 135 <Compile Include="BusinessObjects\ClientDto.cs" /> -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Contracts/3.3/Interfaces/IJobManager.cs
r4263 r4264 36 36 37 37 [OperationContract] 38 ResponseList<JobDto> GetAllJobsWithFilter( State jobState, int offset, int count);38 ResponseList<JobDto> GetAllJobsWithFilter(JobState jobState, int offset, int count); 39 39 40 40 [OperationContract] -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/HiveExperiment.cs
r4263 r4264 447 447 JobItem jobItem = (JobItem)sender; 448 448 Thread t = new Thread(() => { 449 if (jobItem.State == State.Finished) {449 if (jobItem.State == JobState.Finished) { 450 450 FetchAndUpdateJob(jobItem.JobDto.Id); 451 451 DisposeOptimizerMappings(jobItem.JobDto.Id); 452 } else if (jobItem.State == State.Failed) {452 } else if (jobItem.State == JobState.Failed) { 453 453 DisposeOptimizerMappings(jobItem.JobDto.Id); 454 454 } … … 517 517 CoresNeeded = 1, // [chn] how to determine real cores needed? 518 518 PluginsNeeded = pluginsNeeded, 519 State = State.Offline,519 State = JobState.Offline, 520 520 MemoryNeeded = 0, 521 521 UserId = Guid.Empty // [chn] set real userid here! … … 556 556 IExecutionEngineFacade executionEngineFacade = GetExecutionEngineFacade(); 557 557 IEnumerable<Guid> jobIdsToQuery = from job in JobItems 558 where job.State != State.Finished &&559 job.State != State.Failed558 where job.State != JobState.Finished && 559 job.State != JobState.Failed 560 560 select job.JobDto.Id; 561 561 if (jobIdsToQuery.Count() > 0) { -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/JobItem.cs
r4263 r4264 22 22 public override Image ItemImage { 23 23 get { 24 if (State == State.Offline) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutablePrepared; 25 else if (State == State.Idle) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutablePrepared; 26 else if (State == State.Calculating) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStarted; 27 else if (State == State.Abort) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStopped; 28 else if (State == State.Failed) return HeuristicLab.Common.Resources.VS2008ImageLibrary.Error; 29 else if (State == State.Finished) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStopped; 24 if (State == JobState.Offline) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutablePrepared; 25 else if (State == JobState.Calculating) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStarted; 26 else if (State == JobState.Aborted) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStopped; 27 else if (State == JobState.Failed) return HeuristicLab.Common.Resources.VS2008ImageLibrary.Error; 28 else if (State == JobState.Finished) return HeuristicLab.Common.Resources.VS2008ImageLibrary.ExecutableStopped; 30 29 else return HeuristicLab.Common.Resources.VS2008ImageLibrary.Event; 31 30 } … … 63 62 } 64 63 65 public State State {64 public JobState State { 66 65 get { return jobResult != null ? JobResult.State : JobDto.State; } 67 66 } -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Console/3.3/AddJobForm.cs
r4263 r4264 111 111 if (numJobs > 0) { 112 112 for (int i = 0; i < numJobs; i++) { 113 JobDto job = new JobDto { State = State.Offline, CoresNeeded = 1 };113 JobDto job = new JobDto { State = JobState.Offline, CoresNeeded = 1 }; 114 114 115 115 // if project selected (0 -> none) -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Console/3.3/HiveServerManagementConsole.cs
r4263 r4264 110 110 void jdf_NewDataAvailable(object sender, EventArgs e) { 111 111 JobDataFetcher fetcher = (JobDataFetcher) sender; 112 if (fetcher.PollStates.Contains( State.Finished)) {113 updateJobListView(fetcher, lv_finishedJobs, 0);114 } else if(fetcher.PollStates.Contains( State.Calculating)) {115 updateJobListView(fetcher, lv_calculatingJobs, 1);116 } else if (fetcher.PollStates.Contains( State.Offline)) {117 updateJobListView(fetcher, lv_offlineJobs, 2);118 } 119 } 120 121 private void updateJobListView(JobDataFetcher fetcher, ListView listView, int category) {112 if (fetcher.PollStates.Contains(JobState.Finished)) { 113 UpdateJobListView(fetcher, lv_finishedJobs, 0); 114 } else if(fetcher.PollStates.Contains(JobState.Calculating)) { 115 UpdateJobListView(fetcher, lv_calculatingJobs, 1); 116 } else if (fetcher.PollStates.Contains(JobState.Offline)) { 117 UpdateJobListView(fetcher, lv_offlineJobs, 2); 118 } 119 } 120 121 private void UpdateJobListView(JobDataFetcher fetcher, ListView listView, int category) { 122 122 if (listView.InvokeRequired) { 123 listView.Invoke(new updateListView( updateJobListView), new object[] { fetcher, listView, category });123 listView.Invoke(new updateListView(UpdateJobListView), new object[] { fetcher, listView, category }); 124 124 } else { 125 125 listView.BeginUpdate(); … … 137 137 private void Init() { 138 138 139 jdfFinished = new JobDataFetcher(new State[] {State.Finished}, 50);140 jdfCalculating = new JobDataFetcher(new State[] {State.Calculating}, 50);141 jdfOffline = new JobDataFetcher(new State[] {State.Offline}, 50);139 jdfFinished = new JobDataFetcher(new JobState[] {JobState.Finished}, 50); 140 jdfCalculating = new JobDataFetcher(new JobState[] {JobState.Calculating}, 50); 141 jdfOffline = new JobDataFetcher(new JobState[] {JobState.Offline}, 50); 142 142 143 143 cmb_finishedJob_count.SelectedItem = "50"; … … 348 348 int percentageUsage = CapacityRam(((ClientDto)resource).NrOfCores, ((ClientDto)resource).NrOfFreeCores); 349 349 int usage = 3; 350 if ((((ClientDto)resource).State != S tate.Offline) &&351 (((ClientDto)resource).State != S tate.NullState)) {350 if ((((ClientDto)resource).State != SlaveState.Offline) && 351 (((ClientDto)resource).State != SlaveState.NullState)) { 352 352 if ((percentageUsage >= 0) && (percentageUsage <= 25)) { 353 353 usage = 0; … … 419 419 //lvSnapshots.Enabled = true; 420 420 421 if (job.State == State.Offline) {421 if (job.State == JobState.Offline) { 422 422 pbJobControl.Image = ilLargeImgJob.Images[2]; 423 } else if (job.State == State.Calculating) {423 } else if (job.State == JobState.Calculating) { 424 424 pbJobControl.Image = ilLargeImgJob.Images[1]; 425 } else if (job.State == State.Finished) {425 } else if (job.State == JobState.Finished) { 426 426 pbJobControl.Image = ilLargeImgJob.Images[0]; 427 427 } … … 480 480 lvJobDetails.Items.Add(lvi); 481 481 482 if (job.State == State.Finished) {482 if (job.State == JobState.Finished) { 483 483 lvi = null; 484 484 lvi = new ListViewItem(); … … 500 500 int percentageUsage = CapacityRam(currentClient.NrOfCores, currentClient.NrOfFreeCores); 501 501 int usage = 3; 502 if ((currentClient.State != S tate.Offline) && (currentClient.State !=State.NullState)) {502 if ((currentClient.State != SlaveState.Offline) && (currentClient.State != SlaveState.NullState)) { 503 503 if ((percentageUsage >= 0) && (percentageUsage <= 25)) { 504 504 usage = 0; … … 630 630 JobDto selectedJob = (JobDto)jlv.SelectedItems[0].Tag; 631 631 632 if (selectedJob != null && selectedJob.State == State.Calculating) {632 if (selectedJob != null && selectedJob.State == JobState.Calculating) { 633 633 jlv.ContextMenuStrip.Items.Add(offlineItemAbortJob); 634 634 jlv.ContextMenuStrip.Items.Add(menuItemGetSnapshot); … … 806 806 change = true; 807 807 } 808 if (job.State != State.Offline) {808 if (job.State != JobState.Offline) { 809 809 if ((!IsEqual(job.Client, jobold.Client)) || (job.State != jobold.State) 810 810 || (job.Percentage != jobold.Percentage)) { -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Console/3.3/JobDataFetcher.cs
r4263 r4264 13 13 namespace HeuristicLab.Hive.Server.ServerConsole { 14 14 public class JobDataFetcher { 15 private List< State> pollStates;15 private List<JobState> pollStates; 16 16 17 public IEnumerable< State> PollStates {17 public IEnumerable<JobState> PollStates { 18 18 get { return pollStates; } 19 19 } … … 48 48 public int CurrentPage { get; set; } 49 49 50 public JobDataFetcher(IEnumerable< State> states, int nrOfEntries) {51 pollStates = new List< State>();50 public JobDataFetcher(IEnumerable<JobState> states, int nrOfEntries) { 51 pollStates = new List<JobState>(); 52 52 CachedJobs = new List<JobDto>(); 53 53 NrOfEntriesOnPage = nrOfEntries; … … 85 85 // * using for loop 86 86 87 State[] pollStatesCopy = PollStates.ToArray();87 JobState[] pollStatesCopy = PollStates.ToArray(); 88 88 for (int i = 0; i < pollStatesCopy.Length; i++) { 89 89 ResponseList<JobDto> resList = jobManager.GetAllJobsWithFilter(pollStatesCopy[i], CurrentPage * NrOfEntriesOnPage, NrOfEntriesOnPage); -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Console/3.3/JobListView.cs
r4116 r4264 28 28 private JobDataFetcher jdf; 29 29 30 public JobListView(IEnumerable< State> states, int nrOfEntries)30 public JobListView(IEnumerable<JobState> states, int nrOfEntries) 31 31 : base() { 32 32 InitializeComponent(); … … 40 40 JobDataFetcher datafetcher = (JobDataFetcher) sender; 41 41 this.BeginUpdate(); 42 if (datafetcher.PollStates.Contains( State.Finished)) {42 if (datafetcher.PollStates.Contains(JobState.Finished)) { 43 43 this.Items.Clear(); 44 44 ListViewItem lviDummy = new ListViewItem("blahr", 0); -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/DefaultScheduler.cs
r4263 r4264 21 21 22 22 public bool ExistsJobForSlave(HeartBeatData hbData) { 23 List<JobDto> allOfflineJobsForSlave = new List<JobDto>(DaoLocator.JobDao.FindFittingJobsForSlave( State.Offline, hbData.FreeCores, hbData.FreeMemory, hbData.SlaveId));23 List<JobDto> allOfflineJobsForSlave = new List<JobDto>(DaoLocator.JobDao.FindFittingJobsForSlave(JobState.Offline, hbData.FreeCores, hbData.FreeMemory, hbData.SlaveId)); 24 24 return (allOfflineJobsForSlave != null && allOfflineJobsForSlave.Count > 0); 25 25 } … … 31 31 using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = ApplicationConstants.ISOLATION_LEVEL_SCOPE })) { 32 32 ClientDto slave = DaoLocator.ClientDao.FindById(slaveId); 33 LinkedList<JobDto> allOfflineJobsForSlave = new LinkedList<JobDto>(DaoLocator.JobDao.FindFittingJobsForSlave( State.Offline, slave.NrOfFreeCores, slave.FreeMemory, slave.Id));33 LinkedList<JobDto> allOfflineJobsForSlave = new LinkedList<JobDto>(DaoLocator.JobDao.FindFittingJobsForSlave(JobState.Offline, slave.NrOfFreeCores, slave.FreeMemory, slave.Id)); 34 34 if (allOfflineJobsForSlave != null && allOfflineJobsForSlave.Count > 0) { 35 35 jobToCalculate = allOfflineJobsForSlave.First.Value; 36 jobToCalculate.State = State.Calculating;36 jobToCalculate.State = JobState.Calculating; 37 37 jobToCalculate.Client = slave; 38 jobToCalculate.Client.State = S tate.Calculating;38 jobToCalculate.Client.State = SlaveState.Calculating; 39 39 jobToCalculate.DateCalculated = DateTime.Now; 40 40 DaoLocator.JobDao.AssignSlaveToJob(slave.Id, jobToCalculate.Id); -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Facades/ServerConsoleFacade.cs
r4263 r4264 108 108 } 109 109 110 public ResponseList<JobDto> GetAllJobsWithFilter( State jobState, int offset, int count) {110 public ResponseList<JobDto> GetAllJobsWithFilter(JobState jobState, int offset, int count) { 111 111 using (contextFactory.GetContext(false)) { 112 112 secMan.Authorize("AccessJobs", sessionID, Guid.Empty); -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/JobManager.cs
r4263 r4264 58 58 List<JobDto> allJobs = new List<JobDto>(DaoLocator.JobDao.FindAll()); 59 59 foreach (JobDto curJob in allJobs) { 60 if (curJob.State != State.Calculating && curJob.State !=State.Finished) {60 if (curJob.State != JobState.Calculating && curJob.State != JobState.Finished) { 61 61 DaoLocator.JobDao.SetJobOffline(curJob); 62 62 } … … 86 86 } 87 87 88 public ResponseList<JobDto> GetAllJobsWithFilter( State jobState, int offset, int count) {88 public ResponseList<JobDto> GetAllJobsWithFilter(JobState jobState, int offset, int count) { 89 89 ResponseList<JobDto> response = new ResponseList<JobDto>(); 90 90 response.List = new List<JobDto>(DaoLocator.JobDao.FindWithLimitations(jobState, offset, count)); … … 153 153 154 154 if (job != null && job.JobInfo != null) { 155 if (job.JobInfo.State != State.Offline) {155 if (job.JobInfo.State != JobState.Offline) { 156 156 response.StatusMessage = ResponseStatus.AddNewJob_JobStateMustBeOffline; 157 157 return response; … … 222 222 223 223 //if it's a snapshot but the result hasn't reached the server yet... 224 if (snapshot && (job.State == State.RequestSnapshot || job.State == State.RequestSnapshotSent)) {224 if (snapshot && (job.State == JobState.SnapshotRequested || job.State == JobState.SnapshotSent)) { 225 225 response.StatusMessage = ResponseStatus.GetLastSerializedResult_JobResultNotYetThere; 226 226 … … 229 229 230 230 //if it's NOT a snapshot, NEITHER request NOR is it finished 231 if (!requested && !snapshot && job.State != State.Finished) {231 if (!requested && !snapshot && job.State != JobState.Finished) { 232 232 response.StatusMessage = ResponseStatus.GetLastSerializedResult_JobResultNotYetThere; 233 233 … … 248 248 249 249 JobDto job = DaoLocator.JobDao.FindById(jobId); 250 if (job.State == State.RequestSnapshot || job.State == State.RequestSnapshotSent) {250 if (job.State == JobState.SnapshotRequested || job.State == JobState.SnapshotSent) { 251 251 response.StatusMessage = ResponseStatus.RequestSnapshot_SnapshotAlreadyRequested; 252 252 return response; 253 253 } 254 if (job.State != State.Calculating) {254 if (job.State != JobState.Calculating) { 255 255 response.StatusMessage = ResponseStatus.RequestSnapshot_JobIsNotBeeingCalculated; 256 256 return response; 257 257 } 258 258 // job is in correct state 259 job.State = State.RequestSnapshot;259 job.State = JobState.SnapshotRequested; 260 260 DaoLocator.JobDao.Update(job); 261 261 … … 275 275 return response; // no commit needed 276 276 } 277 if (job.State == State.Abort) {277 if (job.State == JobState.Aborted) { 278 278 //response.Success = true; 279 279 response.StatusMessage = ResponseStatus.AbortJob_AbortAlreadyRequested; 280 280 return response; // no commit needed 281 281 } 282 if (job.State != State.Calculating && job.State != State.RequestSnapshot && job.State != State.RequestSnapshotSent) {282 if (job.State != JobState.Calculating && job.State != JobState.SnapshotRequested && job.State != JobState.SnapshotSent) { 283 283 //response.Success = false; 284 284 response.StatusMessage = ResponseStatus.AbortJob_JobIsNotBeeingCalculated; … … 286 286 } 287 287 // job is in correct state 288 job.State = State.Abort;288 job.State = JobState.Aborted; 289 289 DaoLocator.JobDao.Update(job); 290 290 -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/SlaveCommunicator.cs
r4263 r4264 83 83 84 84 foreach (ClientDto client in allClients) { 85 if (client.State != S tate.Offline && client.State !=State.NullState) {85 if (client.State != SlaveState.Offline && client.State != SlaveState.NullState) { 86 86 heartbeatLock.EnterUpgradeableReadLock(); 87 87 … … 89 89 Logger.Info("Client " + client.Id + 90 90 " wasn't offline but hasn't sent heartbeats - setting offline"); 91 client.State = S tate.Offline;91 client.State = SlaveState.Offline; 92 92 DaoLocator.ClientDao.Update(client); 93 93 Logger.Info("Client " + client.Id + … … 114 114 Logger.Debug("setting client offline"); 115 115 // client must be set offline 116 client.State = S tate.Offline;116 client.State = SlaveState.Offline; 117 117 118 118 //clientAdapter.Update(client); … … 147 147 148 148 private void CheckForPendingJobs() { 149 IList<JobDto> pendingJobsInDB = new List<JobDto>(DaoLocator.JobDao.GetJobsByState( State.Pending));149 IList<JobDto> pendingJobsInDB = new List<JobDto>(DaoLocator.JobDao.GetJobsByState(JobState.Pending)); 150 150 151 151 foreach (JobDto currJob in pendingJobsInDB) { … … 153 153 if (pendingJobs.ContainsKey(currJob.Id)) { 154 154 if (pendingJobs[currJob.Id] <= 0) { 155 currJob.State = State.Offline;155 currJob.State = JobState.Offline; 156 156 DaoLocator.JobDao.Update(currJob); 157 157 } else { … … 186 186 //Really set offline? 187 187 //Reconnect issues with the currently calculating jobs 188 slaveInfo.State = S tate.Idle;188 slaveInfo.State = SlaveState.Idle; 189 189 slaveInfo.CalendarSyncStatus = dbClient != null ? dbClient.CalendarSyncStatus : CalendarState.NotAllowedToFetch; 190 190 … … 255 255 Logger.Debug("END Finished Client Fetching"); 256 256 // check if the client is logged in 257 if (client.State == S tate.Offline || client.State ==State.NullState) {257 if (client.State == SlaveState.Offline || client.State == SlaveState.NullState) { 258 258 // response.Success = false; 259 259 response.StatusMessage = ResponseStatus.ProcessHeartBeat_UserNotLoggedIn; … … 359 359 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id)); 360 360 Logger.Error("There is no job calculated by this user " + hbData.SlaveId + " Job: " + curJob); 361 } else if (curJob.State == State.Abort) {361 } else if (curJob.State == JobState.Aborted) { 362 362 // a request to abort the job has been set 363 363 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id)); 364 curJob.State = State.Finished;364 curJob.State = JobState.Finished; 365 365 } else { 366 366 // save job progress 367 367 curJob.Percentage = jobProgress.Value; 368 368 369 if (curJob.State == State.RequestSnapshot) {369 if (curJob.State == JobState.SnapshotRequested) { 370 370 // a request for a snapshot has been set 371 371 response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.RequestSnapshot, curJob.Id)); 372 curJob.State = State.RequestSnapshotSent;372 curJob.State = JobState.SnapshotSent; 373 373 } 374 374 } … … 394 394 Logger.Error("Job TTL reached Zero, Job gets removed: " + currJob + " and set back to offline. User that sucks: " + currJob.Client); 395 395 396 currJob.State = State.Offline;396 currJob.State = JobState.Offline; 397 397 DaoLocator.JobDao.Update(currJob); 398 398 … … 403 403 } else { 404 404 Logger.Error("Job ID wasn't with the heartbeats: " + currJob); 405 currJob.State = State.Offline;405 currJob.State = JobState.Offline; 406 406 DaoLocator.JobDao.Update(currJob); 407 407 } … … 516 516 return response; 517 517 } 518 if (job.JobInfo.State == State.Abort) {518 if (job.JobInfo.State == JobState.Aborted) { 519 519 //response.Success = false; 520 520 response.StatusMessage = ResponseStatus.ProcessJobResult_JobAborted; … … 545 545 return response; 546 546 } 547 if (job.JobInfo.State == State.Finished) {547 if (job.JobInfo.State == JobState.Finished) { 548 548 response.StatusMessage = ResponseStatus.Ok; 549 549 response.JobId = jobId; … … 555 555 } 556 556 //Todo: RequestsnapshotSent => calculating? 557 if (job.JobInfo.State == State.RequestSnapshotSent) {558 job.JobInfo.State = State.Calculating;559 } 560 if (job.JobInfo.State != State.Calculating && job.JobInfo.State !=State.Pending) {557 if (job.JobInfo.State == JobState.SnapshotSent) { 558 job.JobInfo.State = JobState.Calculating; 559 } 560 if (job.JobInfo.State != JobState.Calculating && job.JobInfo.State != JobState.Pending) { 561 561 //response.Success = false; 562 562 response.StatusMessage = ResponseStatus.ProcessJobResult_InvalidJobState; … … 571 571 572 572 if (!string.IsNullOrEmpty(exception)) { 573 job.JobInfo.State = State.Failed;573 job.JobInfo.State = JobState.Failed; 574 574 job.JobInfo.Exception = exception; 575 575 job.JobInfo.DateFinished = DateTime.Now; 576 576 } else if (finished) { 577 job.JobInfo.State = State.Finished;577 job.JobInfo.State = JobState.Finished; 578 578 job.JobInfo.DateFinished = DateTime.Now; 579 579 } … … 638 638 return response; 639 639 } 640 if (client.State == S tate.Calculating) {640 if (client.State == SlaveState.Calculating) { 641 641 // check wich job the client was calculating and reset it 642 642 IEnumerable<JobDto> jobsOfClient = DaoLocator.JobDao.FindActiveJobsOfSlave(client); 643 643 foreach (JobDto job in jobsOfClient) { 644 if (job.State != State.Finished)644 if (job.State != JobState.Finished) 645 645 DaoLocator.JobDao.SetJobOffline(job); 646 646 } 647 647 } 648 648 649 client.State = S tate.Offline;649 client.State = SlaveState.Offline; 650 650 DaoLocator.ClientDao.Update(client); 651 651 … … 668 668 return response; 669 669 } 670 if (job.State == State.Finished) {670 if (job.State == JobState.Finished) { 671 671 //response.Success = true; 672 672 response.StatusMessage = ResponseStatus.IsJobStillNeeded_JobAlreadyFinished; … … 674 674 return response; 675 675 } 676 job.State = State.Pending;676 job.State = JobState.Pending; 677 677 lock (pendingJobs) { 678 678 pendingJobs.Add(job.Id, PENDING_TIMEOUT); -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.DataAccess/3.3/IJobDao.cs
r4253 r4264 9 9 IEnumerable<JobDto> FindActiveJobsOfSlave(ClientDto slave); 10 10 11 IEnumerable<JobDto> GetJobsByState( State state);11 IEnumerable<JobDto> GetJobsByState(JobState state); 12 12 13 13 void AssignSlaveToJob(Guid slaveId, Guid jobId); … … 19 19 byte[] GetBinaryJobFile(Guid jobId); 20 20 21 IEnumerable<JobDto> FindFittingJobsForSlave( State state, int freeCores, int freeMemory, Guid slaveGuid);21 IEnumerable<JobDto> FindFittingJobsForSlave(JobState state, int freeCores, int freeMemory, Guid slaveGuid); 22 22 Stream GetSerializedJobStream(Guid jobId); 23 23 24 IEnumerable<JobDto> FindWithLimitations( State jobState, int offset, int count);24 IEnumerable<JobDto> FindWithLimitations(JobState jobState, int offset, int count); 25 25 26 26 void SetBinaryJobFile(Guid jobId, byte[] data); -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.LINQDataAccess/3.3/ClientDao.cs
r4116 r4264 83 83 target.NumberOfCores = source.NrOfCores; 84 84 target.NumberOfFreeCores = source.NrOfFreeCores; 85 target.Status = Enum.GetName(typeof( State), source.State);85 target.Status = Enum.GetName(typeof(JobState), source.State); 86 86 return target; 87 87 } … … 101 101 target.NrOfCores = source.NumberOfCores ?? 0; 102 102 target.NrOfFreeCores = source.NumberOfFreeCores ?? 0; 103 target.State = (S tate) Enum.Parse(typeof (State), source.Status, true);103 target.State = (SlaveState)Enum.Parse(typeof(SlaveState), source.Status, true); 104 104 return target; 105 105 } -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.LINQDataAccess/3.3/JobDao.cs
r4253 r4264 25 25 } 26 26 27 public IEnumerable<JobDto> FindWithLimitations( State jobState, int offset, int count) {27 public IEnumerable<JobDto> FindWithLimitations(JobState jobState, int offset, int count) { 28 28 IQueryable<JobDto> query = null; 29 if (jobState == State.Finished) {29 if (jobState == JobState.Finished) { 30 30 query = from job in Context.Jobs 31 where job.JobState == Enum.GetName(typeof ( State), jobState)31 where job.JobState == Enum.GetName(typeof (JobState), jobState) 32 32 orderby job.DateFinished 33 33 select EntityToDto(job, null); 34 } else if (jobState == State.Calculating || jobState == State.RequestSnapshot || jobState == State.RequestSnapshotSent) {34 } else if (jobState == JobState.Calculating || jobState == JobState.SnapshotRequested || jobState == JobState.SnapshotSent) { 35 35 query = from job in Context.Jobs 36 where job.JobState == Enum.GetName(typeof( State), jobState)36 where job.JobState == Enum.GetName(typeof(JobState), jobState) 37 37 orderby job.DateCalculated 38 38 select EntityToDto(job, null); 39 39 } else { 40 40 query = from job in Context.Jobs 41 where job.JobState == Enum.GetName(typeof( State), jobState)41 where job.JobState == Enum.GetName(typeof(JobState), jobState) 42 42 orderby job.DateCreated 43 43 select EntityToDto(job, null); … … 95 95 public IEnumerable<JobDto> FindActiveJobsOfSlave(ClientDto client) { 96 96 return (from j in Context.Jobs 97 where (j.JobState == Enum.GetName(typeof ( State),State.Calculating) ||98 j.JobState == Enum.GetName(typeof ( State), State.Abort) ||99 j.JobState == Enum.GetName(typeof ( State), State.RequestSnapshot) ||100 j.JobState == Enum.GetName(typeof ( State), State.RequestSnapshotSent)) &&97 where (j.JobState == Enum.GetName(typeof (JobState), JobState.Calculating) || 98 j.JobState == Enum.GetName(typeof (JobState), JobState.Aborted) || 99 j.JobState == Enum.GetName(typeof (JobState), JobState.SnapshotRequested) || 100 j.JobState == Enum.GetName(typeof (JobState), JobState.SnapshotSent)) && 101 101 (j.ResourceId.Equals(client.Id)) 102 102 select EntityToDto(j, null)).ToList(); 103 103 } 104 104 105 public IEnumerable<JobDto> FindFittingJobsForSlave( State state, int freeCores, int freeMemory, Guid clientId) {105 public IEnumerable<JobDto> FindFittingJobsForSlave(JobState state, int freeCores, int freeMemory, Guid clientId) { 106 106 ClientGroupDao cgd = new ClientGroupDao(); 107 107 … … 111 111 112 112 var q = (from ar in Context.AssignedResources 113 where ar.Job.JobState == Enum.GetName(typeof ( State),State.Offline) &&113 where ar.Job.JobState == Enum.GetName(typeof (JobState), JobState.Offline) && 114 114 ar.Job.CoresNeeded <= freeCores && 115 115 ar.Job.MemoryNeeded <= freeMemory && … … 120 120 } 121 121 122 public IEnumerable<JobDto> GetJobsByState( State state) {122 public IEnumerable<JobDto> GetJobsByState(JobState state) { 123 123 return (from j in Context.Jobs 124 where (j.JobState == Enum.GetName(typeof ( State), state))124 where (j.JobState == Enum.GetName(typeof (JobState), state)) 125 125 select EntityToDto(j, null)).ToList(); 126 126 } … … 137 137 Job j = Context.Jobs.SingleOrDefault(jq => jq.JobId.Equals(job.Id)); 138 138 j.Client = null; 139 j.JobState = Enum.GetName(typeof( State),State.Offline);139 j.JobState = Enum.GetName(typeof(JobState), JobState.Offline); 140 140 CommitChanges(); 141 141 } … … 177 177 178 178 target.Priority = source.Priority; 179 target.JobState = Enum.GetName(typeof( State), source.State);179 target.JobState = Enum.GetName(typeof(JobState), source.State); 180 180 return target; 181 181 } … … 206 206 207 207 target.Priority = source.Priority; 208 target.State = ( State) Enum.Parse(typeof (State), source.JobState, true);208 target.State = (JobState) Enum.Parse(typeof (JobState), source.JobState, true); 209 209 return target; 210 210 } -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Core/3.3/Core.cs
r4263 r4264 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 26 using HeuristicLab.Hive.Slave.ExecutionEngine; 24 using System.IO; 25 using System.Threading; 26 using HeuristicLab.Core; 27 using HeuristicLab.Hive.Contracts; 28 using HeuristicLab.Hive.Contracts.BusinessObjects; 29 using HeuristicLab.Hive.Contracts.ResponseObjects; 27 30 using HeuristicLab.Hive.Slave.Common; 28 using System.Threading;29 using System.Reflection;30 using System.Diagnostics;31 using System.Security.Permissions;32 using System.Security.Policy;33 using System.Security;34 31 using HeuristicLab.Hive.Slave.Communication; 35 using HeuristicLab.Hive.Contracts.BusinessObjects; 36 using HeuristicLab.Hive.Contracts; 37 using System.Runtime.Remoting.Messaging; 38 using HeuristicLab.PluginInfrastructure; 39 using System.ServiceModel; 40 using System.ServiceModel.Description; 32 using HeuristicLab.Hive.Slave.Communication.ServerService; 41 33 using HeuristicLab.Hive.Slave.Core.ClientConsoleService; 42 34 using HeuristicLab.Hive.Slave.Core.ConfigurationManager; 43 using HeuristicLab.Hive.Slave.Communication.ServerService;44 using HeuristicLab.Hive.JobBase;45 35 using HeuristicLab.Hive.Slave.Core.JobStorage; 36 using HeuristicLab.Hive.Slave.ExecutionEngine; 46 37 using HeuristicLab.Tracing; 47 using HeuristicLab.Core;48 using System.IO;49 using HeuristicLab.Hive.Contracts.ResponseObjects;50 38 51 39 namespace HeuristicLab.Hive.Slave.Core { … … 102 90 103 91 //Initialize the heartbeat 104 beat = new Heartbeat { Interval = 10000};92 beat = new Heartbeat { Interval = new TimeSpan(0, 0, 10) }; 105 93 beat.StartHeartbeat(); 106 94 … … 171 159 Logger.Info("Uptime Limit reached, storing jobs and sending them back"); 172 160 173 //check if there are running jobs 174 if (engines.Count > 0) { 175 //make sure there is no more fetching of jobs while the snapshots get processed 176 CurrentlyFetching = true; 177 //request a snapshot of each running job 178 foreach (KeyValuePair<Guid, Executor> kvp in engines) { 179 kvp.Value.RequestSnapshot(); 180 } 181 182 } else { 183 //Disconnect afterwards 184 WcfService.Instance.Disconnect(); 185 } 161 ShutdownRunningJobsAndSubmitSnapshots(); 186 162 break; 187 163 … … 209 185 WcfService.Instance.Logout(ConfigManager.Instance.GetClientInfo().Id); 210 186 break; 187 } 188 } 189 190 private void ShutdownRunningJobsAndSubmitSnapshots() { 191 //check if there are running jobs 192 if (engines.Count > 0) { 193 //make sure there is no more fetching of jobs while the snapshots get processed 194 CurrentlyFetching = true; 195 //request a snapshot of each running job 196 foreach (KeyValuePair<Guid, Executor> kvp in engines) { 197 kvp.Value.RequestSnapshot(); 198 } 199 211 200 } 212 201 } -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Core/3.3/Heartbeat.cs
r4254 r4264 33 33 using HeuristicLab.Hive.Slave.Communication.ServerService; 34 34 using HeuristicLab.Tracing; 35 using System.Threading; 35 36 //using BO = HeuristicLab.Hive.Contracts.BusinessObjects; 36 37 … … 43 44 private bool offline; 44 45 45 public double Interval { get; set; } 46 private Timer heartbeatTimer = null; 46 public TimeSpan Interval { get; set; } 47 48 private Thread heartBeatThread; 47 49 48 50 private static object locker = new object(); 49 51 50 52 public Heartbeat() { 51 Interval = 100;53 Interval = new TimeSpan(0,0,10); 52 54 } 53 55 54 public Heartbeat( doubleinterval) {56 public Heartbeat(TimeSpan interval) { 55 57 Interval = interval; 56 58 } … … 58 60 private WcfService wcfService; 59 61 62 private bool abortThreadPending; 63 60 64 /// <summary> 61 65 /// Starts the Heartbeat signal. 62 66 /// </summary> 63 67 public void StartHeartbeat() { 64 heartbeatTimer = new System.Timers.Timer();65 heartbeatTimer.Interval = this.Interval;66 heartbeatTimer.AutoReset = true;67 heartbeatTimer.Elapsed += new ElapsedEventHandler(heartbeatTimer_Elapsed);68 68 wcfService = WcfService.Instance; 69 69 wcfService.ProcessHeartBeatCompleted += new EventHandler<ProcessHeartBeatCompletedEventArgs>(wcfService_ProcessHeartBeatCompleted); 70 heartbeatTimer.Start(); 70 abortThreadPending = false; 71 heartBeatThread = GetHeartBeatThread(); 72 heartBeatThread.Start(); 71 73 } 72 74 73 /// <summary> 74 /// This Method is called every time the timer ticks 75 /// </summary> 76 /// <param name="sender"></param> 77 /// <param name="e"></param> 78 void heartbeatTimer_Elapsed(object sender, ElapsedEventArgs e) { 79 lock (locker) { 80 // check if cwfService is disconnected for any reason (should happen at first heartbeat) 81 // [chn] TODO: Client should always send heartbeats. when calendar disallows he should tell the server he does not want to compute anything 82 if (wcfService.ConnState == NetworkEnum.WcfConnState.Disconnected && 83 (!UptimeManager.Instance.CalendarAvailable || UptimeManager.Instance.IsOnline())) { 84 wcfService.Connect(); 85 } 86 if (wcfService.ConnState == NetworkEnum.WcfConnState.Connected) { 87 wcfService.LoginSync(ConfigManager.Instance.GetClientInfo()); 88 } 89 90 ClientDto info = ConfigManager.Instance.GetClientInfo(); 91 92 PerformanceCounter counter = new PerformanceCounter("Memory", "Available Bytes", true); 93 int mb = (int)(counter.NextValue() / 1024 / 1024); 94 95 HeartBeatData heartBeatData = new HeartBeatData { 96 SlaveId = info.Id, 97 FreeCores = info.NrOfCores - ConfigManager.Instance.GetUsedCores(), 98 FreeMemory = mb, 99 JobProgress = ConfigManager.Instance.GetProgressOfAllJobs() 100 }; 101 102 DateTime lastFullHour = DateTime.Parse(DateTime.Now.Hour.ToString() + ":00"); 103 TimeSpan span = DateTime.Now - lastFullHour; 104 if (span.TotalSeconds < (Interval / 1000)) { 105 if (UptimeManager.Instance.IsOnline() && UptimeManager.Instance.CalendarAvailable) { 106 //That's quiet simple: Just reconnect and you're good for new jobs 107 if (wcfService.ConnState != NetworkEnum.WcfConnState.Loggedin) { 108 Logger.Info("Client goes online according to timetable"); 75 private Thread GetHeartBeatThread() { 76 return new Thread(() => { 77 while (!abortThreadPending) { 78 lock (locker) { 79 // check if cwfService is disconnected for any reason (should happen at first heartbeat) 80 // [chn] TODO: Client should always send heartbeats. when calendar disallows he should tell the server he does not want to compute anything 81 if (wcfService.ConnState == NetworkEnum.WcfConnState.Disconnected) { 109 82 wcfService.Connect(); 110 83 } 111 } else { 112 //We have quit a lot of work to do here: snapshot all jobs, submit them back, then disconnect and then pray to god that nothing goes wrong 113 MessageQueue.GetInstance().AddMessage(MessageContainer.MessageType.UptimeLimitDisconnect); 114 } 115 } 116 if (wcfService.ConnState == NetworkEnum.WcfConnState.Failed) { 117 wcfService.Connect(); 118 } else if (wcfService.ConnState == NetworkEnum.WcfConnState.Loggedin) { 119 Logger.Debug("Sending Heartbeat: " + heartBeatData); 120 wcfService.ProcessHeartBeatAsync(heartBeatData); 121 } 122 } 84 85 if (wcfService.ConnState == NetworkEnum.WcfConnState.Loggedin) { 86 87 // client is allowed to calculate stuff 88 ClientDto info = ConfigManager.Instance.GetClientInfo(); 89 90 HeartBeatData heartBeatData = new HeartBeatData { 91 SlaveId = info.Id, 92 FreeCores = info.NrOfCores - ConfigManager.Instance.GetUsedCores(), 93 FreeMemory = GetFreeMemory(), 94 JobProgress = ConfigManager.Instance.GetProgressOfAllJobs(), 95 IsAllowedToCalculate = UptimeManager.Instance.IsOnline() && UptimeManager.Instance.CalendarAvailable 96 }; 97 98 if (!heartBeatData.IsAllowedToCalculate) { 99 // stop all running jobs and send snapshots to server 100 MessageQueue.GetInstance().AddMessage(MessageContainer.MessageType.UptimeLimitDisconnect); 101 } 102 103 Logger.Debug("Sending Heartbeat: " + heartBeatData); 104 wcfService.ProcessHeartBeatAsync(heartBeatData); 105 } 106 107 } // lock 108 Thread.Sleep(Interval); 109 } // while 110 abortThreadPending = false; 111 }); 112 } 113 114 private int GetFreeMemory() { 115 PerformanceCounter counter = new PerformanceCounter("Memory", "Available Bytes", true); 116 int mb = (int)(counter.NextValue() / 1024 / 1024); 117 return mb; 123 118 } 124 119 … … 129 124 130 125 public void StopHeartBeat() { 131 heartbeatTimer.Dispose();126 abortThreadPending = true; 132 127 } 133 128 }
Note: See TracChangeset
for help on using the changeset viewer.