- Timestamp:
- 03/12/09 14:39:22 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs
r1272 r1334 46 46 new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); 47 47 48 private static Mutex jobLock =49 new Mutex();50 51 48 IClientAdapter clientAdapter; 52 49 IJobAdapter jobAdapter; -
trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/IScheduler.cs
r1284 r1334 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; -
trunk/sources/HeuristicLab.Hive.Server.Scheduler/DefaultScheduler.cs
r1284 r1334 4 4 using System.Text; 5 5 using HeuristicLab.Hive.Server.Core.InternalInterfaces; 6 using HeuristicLab.Hive.Contracts.BusinessObjects; 7 using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess; 8 using System.Threading; 6 9 7 10 namespace HeuristicLab.Hive.Server.Scheduler { 8 class DefaultScheduler : IScheduler { 11 class DefaultScheduler: IScheduler { 12 13 IJobAdapter jobAdapter; 14 IClientAdapter clientAdapter; 15 16 private static Mutex jobLock = 17 new Mutex(); 18 9 19 #region IScheduler Members 10 20 21 public DefaultScheduler() { 22 jobAdapter = ServiceLocator.GetJobAdapter(); 23 clientAdapter = ServiceLocator.GetClientAdapter(); 24 } 25 11 26 public bool ExistsJobForClient(HeuristicLab.Hive.Contracts.BusinessObjects.HeartBeatData hbData) { 12 throw new NotImplementedException(); 27 List<Job> allOfflineJobs = new List<Job>(jobAdapter.GetJobsByState(State.offline)); 28 return (allOfflineJobs.Count > 0); 13 29 } 14 30 15 31 public HeuristicLab.Hive.Contracts.BusinessObjects.Job GetNextJobForClient(Guid clientId) { 16 throw new NotImplementedException(); 32 33 /// Critical section /// 34 jobLock.WaitOne(); 35 36 LinkedList<Job> allOfflineJobs = new LinkedList<Job>(jobAdapter.GetJobsByState(State.offline)); 37 38 Job job2Calculate = null; 39 if (allOfflineJobs != null && allOfflineJobs.Count > 0) { 40 job2Calculate = allOfflineJobs.First.Value; 41 job2Calculate.State = State.calculating; 42 job2Calculate.Client = clientAdapter.GetById(clientId); 43 job2Calculate.Client.State = State.calculating; 44 45 job2Calculate.DateCalculated = DateTime.Now; 46 jobAdapter.Update(job2Calculate); 47 } 48 jobLock.ReleaseMutex(); 49 /// End Critical section /// 50 51 return job2Calculate; 17 52 } 18 53
Note: See TracChangeset
for help on using the changeset viewer.