Changeset 4092 for branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3
- Timestamp:
- 07/23/10 14:17:20 (14 years ago)
- Location:
- branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3
- Files:
-
- 4 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/ClientCommunicator.cs
r4091 r4092 40 40 public class ClientCommunicator : IClientCommunicator, 41 41 IInternalClientCommunicator { 42 private static Dictionary<Guid, DateTime> lastHeartbeats = 43 new Dictionary<Guid, DateTime>(); 44 private static Dictionary<Guid, int> newAssignedJobs = 45 new Dictionary<Guid, int>(); 46 private static Dictionary<Guid, int> pendingJobs = 47 new Dictionary<Guid, int>(); 48 49 private static ReaderWriterLockSlim heartbeatLock = 50 new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); 42 private static Dictionary<Guid, DateTime> lastHeartbeats = new Dictionary<Guid, DateTime>(); 43 private static Dictionary<Guid, int> newAssignedJobs = new Dictionary<Guid, int>(); 44 private static Dictionary<Guid, int> pendingJobs = new Dictionary<Guid, int>(); 45 46 private static ReaderWriterLockSlim heartbeatLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); 51 47 52 48 //private ISessionFactory factory; … … 81 77 Logger.Debug("Server Heartbeat ticked"); 82 78 79 // [chn] why is transaction management done here 83 80 using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = ApplicationConstants.ISOLATION_LEVEL_SCOPE })) { 84 85 81 List<ClientDto> allClients = new List<ClientDto>(DaoLocator.ClientDao.FindAll()); 86 82 … … 144 140 } 145 141 CheckForPendingJobs(); 146 DaoLocator.DestroyContext();142 // DaoLocator.DestroyContext(); 147 143 scope.Complete(); 148 144 } … … 595 591 } 596 592 597 598 593 /// <summary> 599 594 /// the client can send job results during calculating … … 616 611 } 617 612 618 619 613 public ResponseResultReceived ProcessSnapshot(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception) { 620 614 return ProcessJobResult(clientId, jobId, result, percentage, exception, false); … … 628 622 /// <returns></returns> 629 623 public Response Logout(Guid clientId) { 630 631 624 Logger.Info("Client logged out " + clientId); 632 625 … … 720 713 721 714 return response; 722 723 715 } 724 716 -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/DaoLocator.cs
r4091 r4092 62 62 } 63 63 } 64 65 public static void DestroyContext() {66 if (ContextFactory.IsContextNull()) {67 ContextFactory.Context.Dispose();68 ContextFactory.Context = null;69 }70 }71 72 64 } 73 65 } -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/DbTestApp.cs
r4091 r4092 33 33 using HeuristicLab.PluginInfrastructure; 34 34 using HeuristicLab.Tracing; 35 using HeuristicLab.Hive.Server.DataAccess; 35 36 36 37 namespace HeuristicLab.Hive.Server { 37 38 [Application("Hive DB Test App", "Test Application for the Hive DataAccess Layer")] 38 39 internal class HiveDbTestApplication : ApplicationBase { 40 private IContextFactory contextFactory = ServiceLocator.GetContextFactory(); 41 39 42 /*private void TestJobStreaming() { 40 43 ISessionFactory factory = … … 150 153 151 154 JobDto job = new JobDto { 152 153 154 155 156 157 158 159 155 Client = c1, 156 CoresNeeded = 2, 157 DateCreated = DateTime.Now, 158 MemoryNeeded = 500, 159 Percentage = 0, 160 Priority = 1, 161 State = State.offline 162 }; 160 163 161 164 job = DaoLocator.JobDao.Insert(job); … … 214 217 } 215 218 216 219 217 220 public override void Run() { 218 221 //TestClientGroupAdapter(); … … 221 224 //TestJobResultStreaming(); 222 225 //TestJobResultDeserialization(); 223 224 //if (ContextFactory.Context.DatabaseExists()) 225 // ContextFactory.Context.DeleteDatabase(); 226 //ContextFactory.Context.CreateDatabase(); 227 //TestLINQImplementation(); 228 TestLinqFileHandling(); 229 //StressTest(); 230 231 //SpeedTest(); 232 //TestJobBytearrFetching(); 233 //TestJobStreamFetching(); 226 using (contextFactory.GetContext(false)) { 227 if (contextFactory.CurrentContext.DatabaseExists()) 228 contextFactory.CurrentContext.DeleteDatabase(); 229 contextFactory.CurrentContext.CreateDatabase(); 230 } 231 232 using (contextFactory.GetContext()) { 233 //TestLINQImplementation(); 234 TestLinqFileHandling(); 235 236 //StressTest(); 237 238 //SpeedTest(); 239 //TestJobBytearrFetching(); 240 //TestJobStreamFetching(); 241 } 242 234 243 } 235 244 236 245 private void WriteToJobWithByte(object jobid) { 237 246 using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, 238 new TransactionOptions 239 {IsolationLevel = ApplicationConstants.ISOLATION_LEVEL_SCOPE}) 240 ) { 247 new TransactionOptions { IsolationLevel = ApplicationConstants.ISOLATION_LEVEL_SCOPE })) { 241 248 Logger.Info("starting bytestuff for job " + jobid); 242 249 DaoLocator.JobDao.SetBinaryJobFile((Guid)jobid, jobmap[(Guid)jobid]); … … 248 255 private void UpdateJobStatus(object jobid) { 249 256 using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, 250 new TransactionOptions 251 {IsolationLevel = ApplicationConstants.ISOLATION_LEVEL_SCOPE}) 252 ) { 257 new TransactionOptions { IsolationLevel = ApplicationConstants.ISOLATION_LEVEL_SCOPE })) { 253 258 Thread.Sleep(1500); 254 259 Logger.Info("starting now"); … … 267 272 List<Thread> jobupdateThreads = new List<Thread>(); 268 273 List<Thread> jobProgressThreads = new List<Thread>(); 269 274 270 275 Random r = new Random(); 271 276 Stack<JobDto> jobs = new Stack<JobDto>(DaoLocator.JobDao.FindAll()); 272 277 Logger.Info("Fetched jobs"); 273 for (int x = 0; x < 10 && jobs.Count > 0; x++ 278 for (int x = 0; x < 10 && jobs.Count > 0; x++) { 274 279 Logger.Info("Creating data for Job"); 275 280 JobDto job = jobs.Pop(); 276 byte[] jobarr = new byte[50 *1024*1024];281 byte[] jobarr = new byte[50 * 1024 * 1024]; 277 282 for (int i = 0; i < jobarr.Length; i++) { 278 jobarr[i] = (byte) 283 jobarr[i] = (byte)r.Next(255); 279 284 } 280 285 jobmap.Add(job.Id, jobarr); 281 286 } 282 287 Logger.Info("filled"); 283 foreach (KeyValuePair<Guid, byte[]> kvp in jobmap) {284 Thread tjob = new Thread(new ParameterizedThreadStart(WriteToJobWithByte)); 288 foreach (KeyValuePair<Guid, byte[]> kvp in jobmap) { 289 Thread tjob = new Thread(new ParameterizedThreadStart(WriteToJobWithByte)); 285 290 Thread tupdate = new Thread(new ParameterizedThreadStart(UpdateJobStatus)); 286 291 jobupdateThreads.Add(tupdate); … … 298 303 299 304 300 private 301 void TestJobStreamFetching() { 305 private void TestJobStreamFetching() { 302 306 //using (TransactionScope scope = new TransactionScope()) { 303 307 304 HiveDataContext context = ContextFactory.Context; 305 306 ContextFactory.Context.Connection.Open 307 (); 308 ContextFactory.Context.Transaction 309 = 310 ContextFactory.Context.Connection.BeginTransaction 311 (); 312 308 HiveDataContext context = contextFactory.CurrentContext as HiveDataContext; 309 310 context.Connection.Open(); 311 context.Transaction = context.Connection.BeginTransaction(); 313 312 314 313 ClientFacade facade = new ClientFacade(); 315 316 314 Stream stream = facade.SendStreamedJob(new Guid("F5CFB334-66A0-417C-A585-71711BA21D3F")); 317 315 318 319 316 byte[] buffer = new byte[3024]; 320 321 317 int read = 0; 322 323 while (( 324 read 325 = 326 stream.Read 327 ( 328 buffer 329 , 0, 330 buffer.Length 331 )) > 0) {} 332 333 stream.Close 334 (); 318 while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) { } 319 stream.Close(); 335 320 336 321 //Stream stream = DaoLocator.JobDao.GetSerializedJobStream(new Guid("bbb51f87-4e2f-4499-a9b6-884e589c78b6")); … … 338 323 } 339 324 340 private 341 void TestJobBytearrFetching() { 325 private void TestJobBytearrFetching() { 342 326 byte[] arr = DaoLocator.JobDao.GetBinaryJobFile(new Guid("A3386907-2B3C-4976-BE07-04D660D40A5B")); 343 Console.WriteLine 344 ( 345 arr 346 ); 347 } 348 349 private 350 void SpeedTest() { 327 Console.WriteLine(arr); 328 } 329 330 private void SpeedTest() { 351 331 DateTime start = new DateTime(); 352 332 … … 356 336 357 337 TimeSpan used = end - start; 358 Console.WriteLine 359 ( 360 used.TotalMilliseconds 361 ); 338 Console.WriteLine(used.TotalMilliseconds); 362 339 } 363 340 } -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Facades/ClientFacade.cs
r4091 r4092 33 33 using HeuristicLab.Hive.Server.Core.InternalInterfaces; 34 34 using System.Transactions; 35 using HeuristicLab.Hive.Server.LINQDataAccess; 36 using HeuristicLab.Hive.Server.DataAccess; 35 37 36 38 namespace HeuristicLab.Hive.Server.Core { 37 [ServiceBehavior(InstanceContextMode = 38 InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)] 39 public class ClientFacade: IClientFacade { 39 [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)] 40 public class ClientFacade : IClientFacade { 40 41 41 public ClientFacade() { 42 public ClientFacade() { 42 43 } 43 44 44 45 private IClientCommunicator clientCommunicator = ServiceLocator.GetClientCommunicator(); 45 46 47 private IContextFactory contextFactory = ServiceLocator.GetContextFactory(); 48 46 49 #region IClientCommunicator Members 47 50 48 51 public Response Login(ClientDto clientInfo) { 49 return clientCommunicator.Login(clientInfo); 52 using (contextFactory.GetContext()) { 53 return clientCommunicator.Login(clientInfo); 54 } 50 55 } 51 56 52 57 public ResponseHB ProcessHeartBeat(HeartBeatData hbData) { 53 return clientCommunicator.ProcessHeartBeat(hbData); 58 using (contextFactory.GetContext()) { 59 return clientCommunicator.ProcessHeartBeat(hbData); 60 } 54 61 } 55 62 56 63 public ResponseJob SendJob(Guid clientId) { 57 return clientCommunicator.SendJob(clientId); 64 using (contextFactory.GetContext()) { 65 return clientCommunicator.SendJob(clientId); 66 } 58 67 } 59 68 60 /*public ResponseSerializedJob SendSerializedJob(Guid clientId) { 61 return clientCommunicator.SendSerializedJob(clientId); 62 } */ 63 64 public ResponseResultReceived StoreFinishedJobResult(Guid clientId, 65 Guid jobId, 66 byte[] result, 67 double percentage, 68 Exception exception) { 69 return clientCommunicator.StoreFinishedJobResult(clientId, jobId, result, percentage, exception); 69 public ResponseResultReceived StoreFinishedJobResult(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception) { 70 using (contextFactory.GetContext()) { 71 return clientCommunicator.StoreFinishedJobResult(clientId, jobId, result, percentage, exception); 72 } 70 73 } 71 74 72 75 public Response Logout(Guid clientId) { 73 return clientCommunicator.Logout(clientId); 76 using (contextFactory.GetContext()) { 77 return clientCommunicator.Logout(clientId); 78 } 74 79 } 75 80 76 81 public Response IsJobStillNeeded(Guid jobId) { 77 return clientCommunicator.IsJobStillNeeded(jobId); 82 using (contextFactory.GetContext()) { 83 return clientCommunicator.IsJobStillNeeded(jobId); 84 } 78 85 } 79 86 80 87 public ResponsePlugin SendPlugins(List<HivePluginInfoDto> pluginList) { 81 return clientCommunicator.SendPlugins(pluginList); 88 using (contextFactory.GetContext()) { 89 return clientCommunicator.SendPlugins(pluginList); 90 } 82 91 } 83 92 84 93 public ResponseResultReceived ProcessSnapshot(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception) { 85 return clientCommunicator.ProcessSnapshot(clientId, jobId, result, percentage, exception); 94 using (contextFactory.GetContext()) { 95 return clientCommunicator.ProcessSnapshot(clientId, jobId, result, percentage, exception); 96 } 86 97 } 87 98 88 99 89 100 public ResponseCalendar GetCalendar(Guid clientId) { 90 return clientCommunicator.GetCalendar(clientId); 101 using (contextFactory.GetContext()) { 102 return clientCommunicator.GetCalendar(clientId); 103 } 91 104 } 92 105 93 public Response SetCalendarStatus(Guid clientId, CalendarState state) { 94 return clientCommunicator.SetCalendarStatus(clientId, state); 106 public Response SetCalendarStatus(Guid clientId, CalendarState state) { 107 using (contextFactory.GetContext()) { 108 return clientCommunicator.SetCalendarStatus(clientId, state); 109 } 95 110 } 96 111 #endregion … … 98 113 #region IClientFacade Members 99 114 100 [SpringTransaction(UserTransaction = true)] 115 /// <summary> 116 /// Do not use automatic transactions here 117 /// </summary> 101 118 public Stream SendStreamedJob(Guid clientId) { 102 MultiStream stream = new MultiStream(); 119 using (contextFactory.GetContext(false)) { 120 MultiStream stream = new MultiStream(); 103 121 104 ResponseJob job = null;122 ResponseJob job = null; 105 123 106 job = this.SendJob(clientId);124 job = this.SendJob(clientId); 107 125 108 //first send response109 stream.AddStream(new StreamedObject<ResponseJob>(job));126 //first send response 127 stream.AddStream(new StreamedObject<ResponseJob>(job)); 110 128 111 IJobManager jobManager = ServiceLocator.GetJobManager();112 IInternalJobManager internalJobManager = (IInternalJobManager)jobManager;113 114 //second stream the job binary data115 MemoryStream memoryStream = new MemoryStream();116 if(job.Job != null)117 stream.AddStream(new MemoryStream(internalJobManager.GetSerializedJobDataById(job.Job.Id)));118 119 OperationContext clientContext = OperationContext.Current;129 IJobManager jobManager = ServiceLocator.GetJobManager(); 130 IInternalJobManager internalJobManager = (IInternalJobManager)jobManager; 131 132 //second stream the job binary data 133 MemoryStream memoryStream = new MemoryStream(); 134 if (job.Job != null) 135 stream.AddStream(new MemoryStream(internalJobManager.GetSerializedJobDataById(job.Job.Id))); 136 137 OperationContext clientContext = OperationContext.Current; 120 138 clientContext.OperationCompleted += new EventHandler(delegate(object sender, EventArgs args) { 121 139 if (stream != null) { … … 124 142 }); 125 143 126 return stream; 144 return stream; 145 } 127 146 } 128 147 129 148 public Stream SendStreamedPlugins(List<HivePluginInfoDto> pluginList) { 130 return new StreamedObject<ResponsePlugin>(this.SendPlugins(pluginList)); 149 using (contextFactory.GetContext()) { 150 return new StreamedObject<ResponsePlugin>(this.SendPlugins(pluginList)); 151 } 131 152 } 132 153 133 154 public ResponseResultReceived StoreFinishedJobResultStreamed(Stream stream) { 134 return ((IInternalClientCommunicator)clientCommunicator).ProcessJobResult(stream, true); 135 } 155 using (contextFactory.GetContext()) { 156 return ((IInternalClientCommunicator)clientCommunicator).ProcessJobResult(stream, true); 157 } 158 } 136 159 137 160 public ResponseResultReceived ProcessSnapshotStreamed(Stream stream) { 138 return ((IInternalClientCommunicator)clientCommunicator).ProcessJobResult(stream, false); 161 using (contextFactory.GetContext()) { 162 return ((IInternalClientCommunicator)clientCommunicator).ProcessJobResult(stream, false); 163 } 139 164 } 140 165 #endregion -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Facades/ExecutionEngineFacade.cs
r4091 r4092 27 27 using HeuristicLab.Hive.Contracts; 28 28 using HeuristicLab.Hive.Contracts.BusinessObjects; 29 using HeuristicLab.Hive.Server.DataAccess; 29 30 30 31 namespace HeuristicLab.Hive.Server.Core { 31 public class ExecutionEngineFacade : IExecutionEngineFacade {32 public class ExecutionEngineFacade : IExecutionEngineFacade { 32 33 33 private IJobManager jobManager = 34 ServiceLocator.GetJobManager();34 private IJobManager jobManager = ServiceLocator.GetJobManager(); 35 private IContextFactory contextFactory = ServiceLocator.GetContextFactory(); 35 36 36 37 public ExecutionEngineFacade() { 37 38 38 } 39 39 … … 41 41 42 42 public ResponseObject<JobDto> AddJob(SerializedJob job) { 43 return jobManager.AddNewJob(job); 43 using (contextFactory.GetContext()) { 44 return jobManager.AddNewJob(job); 45 } 44 46 } 45 47 46 public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) { 47 return jobManager.AddJobWithGroupStrings(job, resources); 48 public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) { 49 using (contextFactory.GetContext()) { 50 return jobManager.AddJobWithGroupStrings(job, resources); 51 } 48 52 } 49 53 50 54 public Response RequestSnapshot(Guid jobId) { 51 return jobManager.RequestSnapshot(jobId); 55 using (contextFactory.GetContext()) { 56 return jobManager.RequestSnapshot(jobId); 57 } 52 58 } 53 59 54 public ResponseObject<SerializedJob> 55 GetLastSerializedResult(Guid jobId, bool requested, bool snapshot) { 56 return jobManager.GetLastSerializedJobResultOf(jobId, requested, snapshot); 60 public ResponseObject<SerializedJob> GetLastSerializedResult(Guid jobId, bool requested, bool snapshot) { 61 using (contextFactory.GetContext()) { 62 return jobManager.GetLastSerializedJobResultOf(jobId, requested, snapshot); 63 } 57 64 } 58 65 59 66 public Response AbortJob(Guid jobId) { 60 return jobManager.AbortJob(jobId); 67 using (contextFactory.GetContext()) { 68 return jobManager.AbortJob(jobId); 69 } 61 70 } 62 71 -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Facades/ServerConsoleFacade.cs
r4091 r4092 30 30 using HeuristicLab.Hive.Server.Core.InternalInterfaces; 31 31 using System.ServiceModel; 32 using HeuristicLab.Hive.Server.DataAccess; 32 33 33 34 34 35 namespace HeuristicLab.Hive.Server.Core { 35 public class ServerConsoleFacade: IServerConsoleFacade { 36 private IClientManager clientManager = 37 ServiceLocator.GetClientManager(); 38 39 private IJobManager jobManager = 40 ServiceLocator.GetJobManager(); 36 public class ServerConsoleFacade : IServerConsoleFacade { 37 private IClientManager clientManager = ServiceLocator.GetClientManager(); 38 39 private IJobManager jobManager = ServiceLocator.GetJobManager(); 41 40 42 41 private IHivePermissionManager secMan = ServiceLocator.GetHivePermissionManager(); 43 42 43 private IContextFactory contextFactory = ServiceLocator.GetContextFactory(); 44 44 45 public Guid sessionID = Guid.Empty; 45 46 46 public ServerConsoleFacade() { 47 public ServerConsoleFacade() { 47 48 } 48 49 49 50 public Response Login(string username, string password) { 50 Response resp = new Response(); 51 52 sessionID = secMan.Login(username, password); 53 if (sessionID == Guid.Empty) { 54 resp.Success = false; 55 resp.StatusMessage = ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_FAILED; 56 } else { 57 resp.Success = true; 58 resp.StatusMessage = 59 ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS; 60 } 61 return resp; 51 using (contextFactory.GetContext()) { 52 Response resp = new Response(); 53 54 sessionID = secMan.Login(username, password); 55 if (sessionID == Guid.Empty) { 56 resp.Success = false; 57 resp.StatusMessage = ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_FAILED; 58 } else { 59 resp.Success = true; 60 resp.StatusMessage = 61 ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS; 62 } 63 return resp; 64 } 62 65 } 63 66 64 67 65 68 public ResponseList<ClientDto> GetAllClients() { 66 secMan.Authorize("AccessClients", sessionID, Guid.Empty); 67 return clientManager.GetAllClients(); 69 using (contextFactory.GetContext()) { 70 secMan.Authorize("AccessClients", sessionID, Guid.Empty); 71 return clientManager.GetAllClients(); 72 } 68 73 } 69 74 70 75 public ResponseList<ClientGroupDto> GetAllClientGroups() { 71 //secMan.Authorize("AccessClientGroup", sessionID, Guid.Empty); 72 return clientManager.GetAllClientGroups(); 76 using (contextFactory.GetContext()) { 77 //secMan.Authorize("AccessClientGroup", sessionID, Guid.Empty); 78 return clientManager.GetAllClientGroups(); 79 } 73 80 } 74 81 75 82 public ResponseList<UpTimeStatisticsDto> GetAllUpTimeStatistics() { 76 secMan.Authorize("AccessStatistics", sessionID, Guid.Empty); 77 return clientManager.GetAllUpTimeStatistics(); 83 using (contextFactory.GetContext()) { 84 secMan.Authorize("AccessStatistics", sessionID, Guid.Empty); 85 return clientManager.GetAllUpTimeStatistics(); 86 } 78 87 } 79 88 80 89 public ResponseObject<ClientGroupDto> AddClientGroup(ClientGroupDto clientGroup) { 81 secMan.Authorize("AddClientGroup", sessionID, Guid.Empty); 82 return clientManager.AddClientGroup(clientGroup); 90 using (contextFactory.GetContext()) { 91 secMan.Authorize("AddClientGroup", sessionID, Guid.Empty); 92 return clientManager.AddClientGroup(clientGroup); 93 } 83 94 } 84 95 85 96 public Response AddResourceToGroup(Guid clientGroupId, ResourceDto resource) { 86 secMan.Authorize("AddResource", sessionID, Guid.Empty); 87 return clientManager.AddResourceToGroup(clientGroupId, resource); 97 using (contextFactory.GetContext()) { 98 secMan.Authorize("AddResource", sessionID, Guid.Empty); 99 return clientManager.AddResourceToGroup(clientGroupId, resource); 100 } 88 101 } 89 102 90 103 public Response DeleteResourceFromGroup(Guid clientGroupId, Guid resourceId) { 104 using (contextFactory.GetContext()) { 91 105 return clientManager.DeleteResourceFromGroup(clientGroupId, resourceId); 106 } 92 107 } 93 108 94 109 public ResponseList<JobDto> GetAllJobs() { 95 secMan.Authorize("AccessJobs", sessionID, Guid.Empty); 96 return jobManager.GetAllJobs(); 110 using (contextFactory.GetContext()) { 111 secMan.Authorize("AccessJobs", sessionID, Guid.Empty); 112 return jobManager.GetAllJobs(); 113 } 97 114 } 98 115 99 116 public ResponseList<JobDto> GetAllJobsWithFilter(State jobState, int offset, int count) { 100 secMan.Authorize("AccessJobs", sessionID, Guid.Empty); 101 return jobManager.GetAllJobsWithFilter(jobState, offset, count); 117 using (contextFactory.GetContext()) { 118 secMan.Authorize("AccessJobs", sessionID, Guid.Empty); 119 return jobManager.GetAllJobsWithFilter(jobState, offset, count); 120 } 102 121 } 103 122 104 123 public ResponseObject<JobDto> GetJobById(Guid jobId) { 105 secMan.Authorize("AccessJobs", sessionID, jobId); 106 return jobManager.GetJobById(jobId); 124 using (contextFactory.GetContext()) { 125 secMan.Authorize("AccessJobs", sessionID, jobId); 126 return jobManager.GetJobById(jobId); 127 } 107 128 } 108 129 109 130 public ResponseObject<JobDto> GetJobByIdWithDetails(Guid jobId) { 110 secMan.Authorize("AccessJobs", sessionID, jobId); 111 return jobManager.GetJobByIdWithDetails(jobId); 131 using (contextFactory.GetContext()) { 132 secMan.Authorize("AccessJobs", sessionID, jobId); 133 return jobManager.GetJobByIdWithDetails(jobId); 134 } 112 135 } 113 136 114 137 public ResponseObject<JobDto> AddNewJob(SerializedJob job) { 115 secMan.Authorize("AddJob", sessionID, job.JobInfo.Id); 116 return jobManager.AddNewJob(job); 138 using (contextFactory.GetContext()) { 139 secMan.Authorize("AddJob", sessionID, job.JobInfo.Id); 140 return jobManager.AddNewJob(job); 141 } 117 142 } 118 143 119 144 public ResponseObject<JobDto> GetLastJobResultOf(Guid jobId) { 120 secMan.Authorize("AccessJobResults", sessionID, jobId); 121 return jobManager.GetLastJobResultOf(jobId); 145 using (contextFactory.GetContext()) { 146 secMan.Authorize("AccessJobResults", sessionID, jobId); 147 return jobManager.GetLastJobResultOf(jobId); 148 } 122 149 } 123 150 124 151 public ResponseObject<SerializedJob> GetLastSerializedJobResultOf(Guid jobId, bool requested, bool snapshot) { 125 secMan.Authorize("AccessJobResults", sessionID, jobId); 126 return jobManager.GetLastSerializedJobResultOf(jobId, requested, snapshot); 152 using (contextFactory.GetContext()) { 153 secMan.Authorize("AccessJobResults", sessionID, jobId); 154 return jobManager.GetLastSerializedJobResultOf(jobId, requested, snapshot); 155 } 127 156 } 128 157 129 158 public ResponseList<JobResult> GetAllJobResults(Guid jobId) { 130 secMan.Authorize("AccessJobResults", sessionID, jobId); 131 return jobManager.GetAllJobResults(jobId); 159 using (contextFactory.GetContext()) { 160 secMan.Authorize("AccessJobResults", sessionID, jobId); 161 return jobManager.GetAllJobResults(jobId); 162 } 132 163 } 133 164 134 165 public Response RemoveJob(Guid jobId) { 135 secMan.Authorize("RemoveJob", sessionID, jobId); 136 return jobManager.RemoveJob(jobId); 166 using (contextFactory.GetContext()) { 167 secMan.Authorize("RemoveJob", sessionID, jobId); 168 return jobManager.RemoveJob(jobId); 169 } 137 170 } 138 171 139 172 public Response RequestSnapshot(Guid jobId) { 140 secMan.Authorize("AccessJobResults", sessionID, jobId); 141 return jobManager.RequestSnapshot(jobId); 173 using (contextFactory.GetContext()) { 174 secMan.Authorize("AccessJobResults", sessionID, jobId); 175 return jobManager.RequestSnapshot(jobId); 176 } 142 177 } 143 178 144 179 public Response AbortJob(Guid jobId) { 145 secMan.Authorize("AbortJob", sessionID, Guid.Empty); 146 return jobManager.AbortJob(jobId); 180 using (contextFactory.GetContext()) { 181 secMan.Authorize("AbortJob", sessionID, Guid.Empty); 182 return jobManager.AbortJob(jobId); 183 } 147 184 } 148 185 149 186 public ResponseObject<List<ClientGroupDto>> GetAllGroupsOfResource(Guid resourceId) { 150 secMan.Authorize("AccessUserGroup", sessionID, Guid.Empty); 151 return clientManager.GetAllGroupsOfResource(resourceId); 187 using (contextFactory.GetContext()) { 188 secMan.Authorize("AccessUserGroup", sessionID, Guid.Empty); 189 return clientManager.GetAllGroupsOfResource(resourceId); 190 } 152 191 } 153 192 154 193 public Response DeleteClientGroup(Guid clientGroupId) { 155 secMan.Authorize("DeleteClientGroup", sessionID, Guid.Empty); 156 return clientManager.DeleteClientGroup(clientGroupId); 194 using (contextFactory.GetContext()) { 195 secMan.Authorize("DeleteClientGroup", sessionID, Guid.Empty); 196 return clientManager.DeleteClientGroup(clientGroupId); 197 } 157 198 } 158 199 159 200 public ResponseList<ProjectDto> GetAllProjects() { 160 secMan.Authorize("AccessProjects", sessionID, Guid.Empty); 161 return jobManager.GetAllProjects(); 201 using (contextFactory.GetContext()) { 202 secMan.Authorize("AccessProjects", sessionID, Guid.Empty); 203 return jobManager.GetAllProjects(); 204 } 162 205 } 163 206 164 207 public Response CreateProject(ProjectDto project) { 165 secMan.Authorize("CreateProjects", sessionID, Guid.Empty); 166 return jobManager.CreateProject(project); 208 using (contextFactory.GetContext()) { 209 secMan.Authorize("CreateProjects", sessionID, Guid.Empty); 210 return jobManager.CreateProject(project); 211 } 167 212 } 168 213 169 214 public Response ChangeProject(ProjectDto project) { 170 secMan.Authorize("ChangeProjects", sessionID, Guid.Empty); 171 return jobManager.ChangeProject(project); 215 using (contextFactory.GetContext()) { 216 secMan.Authorize("ChangeProjects", sessionID, Guid.Empty); 217 return jobManager.ChangeProject(project); 218 } 172 219 } 173 220 174 221 public Response DeleteProject(Guid projectId) { 175 secMan.Authorize("DeleteProjects", sessionID, projectId); 176 return jobManager.DeleteProject(projectId); 222 using (contextFactory.GetContext()) { 223 secMan.Authorize("DeleteProjects", sessionID, projectId); 224 return jobManager.DeleteProject(projectId); 225 } 177 226 } 178 227 179 228 public ResponseList<JobDto> GetJobsByProject(Guid projectId) { 180 secMan.Authorize("AccessJobs", sessionID, Guid.Empty); 181 return jobManager.GetJobsByProject(projectId); 229 using (contextFactory.GetContext()) { 230 secMan.Authorize("AccessJobs", sessionID, Guid.Empty); 231 return jobManager.GetJobsByProject(projectId); 232 } 182 233 } 183 234 184 235 public ResponseList<AppointmentDto> GetUptimeCalendarForResource(Guid guid) { 185 return clientManager.GetUptimeCalendarForResource(guid); 236 using (contextFactory.GetContext()) { 237 return clientManager.GetUptimeCalendarForResource(guid); 238 } 186 239 } 187 240 188 241 public Response SetUptimeCalendarForResource(Guid guid, IEnumerable<AppointmentDto> appointments, bool isForced) { 189 return clientManager.SetUptimeCalendarForResource(guid, appointments, isForced); 242 using (contextFactory.GetContext()) { 243 return clientManager.SetUptimeCalendarForResource(guid, appointments, isForced); 244 } 190 245 } 191 246 192 247 public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) { 193 return jobManager.AddJobWithGroupStrings(job, resources); 248 using (contextFactory.GetContext()) { 249 return jobManager.AddJobWithGroupStrings(job, resources); 250 } 194 251 } 195 252 } -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/HeuristicLab.Hive.Server.Core-3.3.csproj
r4091 r4092 112 112 <Compile Include="Authorization\PolicyCollection.cs" /> 113 113 <Compile Include="ClientCommunicator.cs" /> 114 <Compile Include=" ClientFacade.cs" />114 <Compile Include="Facades\ClientFacade.cs" /> 115 115 <Compile Include="ClientManager.cs" /> 116 116 <Compile Include="DaoLocator.cs" /> 117 117 <Compile Include="DbTestApp.cs" /> 118 118 <Compile Include="DefaultScheduler.cs" /> 119 <Compile Include=" ExecutionEngineFacade.cs" />119 <Compile Include="Facades\ExecutionEngineFacade.cs" /> 120 120 <Compile Include="Authorization\HivePermissionManager.cs" /> 121 121 <Compile Include="HiveServerCorePlugin.cs" /> … … 128 128 <Compile Include="LifecycleManager.cs" /> 129 129 <Compile Include="Properties\AssemblyInfo.cs" /> 130 <Compile Include=" ServerConsoleFacade.cs" />130 <Compile Include="Facades\ServerConsoleFacade.cs" /> 131 131 <Compile Include="ServiceLocator.cs" /> 132 132 <Compile Include="Properties\Settings.Designer.cs"> -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/JobManager.cs
r4060 r4092 37 37 using System.Transactions; 38 38 using HeuristicLab.Hive.Server.LINQDataAccess; 39 using IsolationLevel =System.Transactions.IsolationLevel;39 using IsolationLevel = System.Transactions.IsolationLevel; 40 40 41 41 namespace HeuristicLab.Hive.Server.Core { … … 59 59 60 60 61 private void checkForDeadJobs() {61 private void CheckForDeadJobs() { 62 62 Logger.Info("Searching for dead Jobs"); 63 using ( 64 TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, 65 new TransactionOptions 66 {IsolationLevel = ApplicationConstants.ISOLATION_LEVEL_SCOPE})) { 63 64 // [chn] why is transaction management done here? 65 using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = ApplicationConstants.ISOLATION_LEVEL_SCOPE })) { 67 66 List<JobDto> allJobs = new List<JobDto>(DaoLocator.JobDao.FindAll()); 68 67 foreach (JobDto curJob in allJobs) { … … 73 72 scope.Complete(); 74 73 } 75 DaoLocator.DestroyContext();74 // DaoLocator.DestroyContext(); 76 75 } 77 76 78 77 private void lifecycleManager_OnStartup(object sender, EventArgs e) { 79 78 Logger.Info("Startup Event Fired, Checking DB for consistency"); 80 checkForDeadJobs();79 CheckForDeadJobs(); 81 80 Logger.Info("Startup Event Done"); 82 81 } … … 84 83 private void lifecycleManager_OnShutdown(object sender, EventArgs e) { 85 84 Logger.Info("Startup Event Fired, Checking DB for consistency"); 86 checkForDeadJobs();85 CheckForDeadJobs(); 87 86 Logger.Info("Startup Event Done"); 88 87 } … … 129 128 response.Success = true; 130 129 response.StatusMessage = ApplicationConstants.RESPONSE_JOB_GET_JOB_BY_ID; 131 } 132 else { 130 } else { 133 131 response.Success = false; 134 132 response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_DOESNT_EXIST; … … 146 144 147 145 job.Obj.Client = DaoLocator.ClientDao.GetClientForJob(jobId); 148 } 149 else { 146 } else { 150 147 job.Success = false; 151 148 job.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_DOESNT_EXIST; … … 196 193 response.Obj = job.JobInfo; 197 194 response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_ADDED; 198 } 199 else { 195 } else { 200 196 response.Success = false; 201 197 response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_NULL; … … 255 251 256 252 //if it's NOT a snapshot, NEITHER request NOR is it finished 257 if (!requested && !snapshot && job.State != State.finished) {253 if (!requested && !snapshot && job.State != State.finished) { 258 254 response.Success = true; 259 255 response.StatusMessage = ApplicationConstants.RESPONSE_JOB_RESULT_NOT_YET_HERE; -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/LifecycleManager.cs
r4060 r4092 37 37 private static event EventHandler OnStartup; 38 38 private static event EventHandler OnShutdown; 39 39 40 #region ILifecycleManager Members 40 41 -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Properties/AssemblyInfo.cs
r4091 r4092 55 55 // by using the '*' as shown below: 56 56 // [assembly: AssemblyVersion("1.0.*")] 57 [assembly: AssemblyVersion("3.3.0.40 78")]58 [assembly: AssemblyFileVersion("3.3.0.40 78")]59 [assembly: AssemblyBuildDate("2010/07/23 09:04:35")]57 [assembly: AssemblyVersion("3.3.0.4091")] 58 [assembly: AssemblyFileVersion("3.3.0.4091")] 59 [assembly: AssemblyBuildDate("2010/07/23 14:14:54")] -
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/ServiceLocator.cs
r4060 r4092 31 31 using HeuristicLab.Security.Contracts.Interfaces; 32 32 33 /// <summary> 34 /// The service locator for the server core 35 /// </summary> 36 public class ServiceLocator { 37 private static IClientManager clientManager = null; 33 namespace HeuristicLab.Hive.Server.Core { 34 /// <summary> 35 /// The service locator for the server core 36 /// </summary> 37 public class ServiceLocator { 38 private static IClientManager clientManager = null; 38 39 39 private static IJobManager jobManager = null;40 private static IJobManager jobManager = null; 40 41 41 private static IClientCommunicator clientCommunicator = null;42 private static IClientCommunicator clientCommunicator = null; 42 43 43 private static ILifecycleManager lifecycleManager = null;44 private static ILifecycleManager lifecycleManager = null; 44 45 45 private static ISessionFactory sessionFactory = null;46 private static ISessionFactory sessionFactory = null; 46 47 47 private static IScheduler scheduler = null;48 private static IScheduler scheduler = null; 48 49 49 private static IPermissionManager permManager = null;50 private static IPermissionManager permManager = null; 50 51 51 private static IHivePermissionManager hivePermManager = null;52 private static IHivePermissionManager hivePermManager = null; 52 53 53 /// <summary> 54 /// Gets the client manager 55 /// </summary> 56 /// <returns></returns> 57 [MethodImpl(MethodImplOptions.Synchronized)] 58 public static IClientManager GetClientManager() { 59 if (clientManager == null) 60 clientManager = new ClientManager(); 54 private static IContextFactory contextFactory = null; 61 55 62 return clientManager; 63 } 56 /// <summary> 57 /// Gets the client manager 58 /// </summary> 59 /// <returns></returns> 60 [MethodImpl(MethodImplOptions.Synchronized)] 61 public static IClientManager GetClientManager() { 62 if (clientManager == null) 63 clientManager = new ClientManager(); 64 64 65 /// <summary> 66 /// Gets the job manager 67 /// </summary> 68 /// <returns></returns> 69 [MethodImpl(MethodImplOptions.Synchronized)] 70 public static IJobManager GetJobManager() { 71 if (jobManager == null) 72 jobManager = new JobManager(); 73 74 return jobManager; 75 } 76 77 /// <summary> 78 /// Gets the client Communicator 79 /// </summary> 80 /// <returns></returns> 81 [MethodImpl(MethodImplOptions.Synchronized)] 82 public static IClientCommunicator GetClientCommunicator() { 83 if (clientCommunicator == null) 84 clientCommunicator = new ClientCommunicator(); 85 86 return clientCommunicator; 87 } 88 89 /// <summary> 90 /// Gets the lifecycle manager 91 /// </summary> 92 /// <returns></returns> 93 [MethodImpl(MethodImplOptions.Synchronized)] 94 public static ILifecycleManager GetLifecycleManager() { 95 if (lifecycleManager == null) { 96 lifecycleManager = new LifecycleManager(); 97 } 98 return lifecycleManager; 99 } 100 101 /// <summary> 102 /// Gets the db session factory 103 /// </summary> 104 /// <returns></returns> 105 [MethodImpl(MethodImplOptions.Synchronized)] 106 public static ISessionFactory GetSessionFactory() { 107 if (sessionFactory == null) { 108 sessionFactory = 109 ApplicationManager.Manager.GetInstances<ISessionFactory>().First(); 110 111 sessionFactory.DbConnectionType = 112 typeof(SqlConnection); 113 114 sessionFactory.DbConnectionString = 115 HeuristicLab.Hive.Server.Core.Properties.Settings.Default.HiveServerConnectionString; 65 return clientManager; 116 66 } 117 67 118 return sessionFactory; 119 } 68 /// <summary> 69 /// Gets the job manager 70 /// </summary> 71 /// <returns></returns> 72 [MethodImpl(MethodImplOptions.Synchronized)] 73 public static IJobManager GetJobManager() { 74 if (jobManager == null) 75 jobManager = new JobManager(); 120 76 121 /// <summary> 122 /// Gets the scheduler 123 /// </summary> 124 /// <returns></returns> 125 [MethodImpl(MethodImplOptions.Synchronized)] 126 public static IScheduler GetScheduler() { 127 if (scheduler == null) { 128 scheduler = ApplicationManager.Manager.GetInstances<IScheduler>().First(); 77 return jobManager; 129 78 } 130 79 131 return scheduler; 132 } 80 /// <summary> 81 /// Gets the client Communicator 82 /// </summary> 83 /// <returns></returns> 84 [MethodImpl(MethodImplOptions.Synchronized)] 85 public static IClientCommunicator GetClientCommunicator() { 86 if (clientCommunicator == null) 87 clientCommunicator = new ClientCommunicator(); 133 88 134 /// <summary> 135 /// Gets the permission manager 136 /// </summary> 137 /// <returns></returns> 138 [MethodImpl(MethodImplOptions.Synchronized)] 139 public static IPermissionManager GetPermissionManager() { 140 if (permManager == null) 141 permManager = ApplicationManager.Manager.GetInstances<IPermissionManager>().First(); 142 return permManager; 143 144 } 89 return clientCommunicator; 90 } 145 91 146 /// <summary> 147 /// Gets the permission manager 148 /// </summary> 149 /// <returns></returns> 150 [MethodImpl(MethodImplOptions.Synchronized)] 151 public static IHivePermissionManager GetHivePermissionManager() { 152 if (hivePermManager == null) 153 hivePermManager = ApplicationManager.Manager.GetInstances<IHivePermissionManager>().First(); 154 return hivePermManager; 92 /// <summary> 93 /// Gets the lifecycle manager 94 /// </summary> 95 /// <returns></returns> 96 [MethodImpl(MethodImplOptions.Synchronized)] 97 public static ILifecycleManager GetLifecycleManager() { 98 if (lifecycleManager == null) { 99 lifecycleManager = new LifecycleManager(); 100 } 101 return lifecycleManager; 102 } 155 103 104 /// <summary> 105 /// Gets the db session factory 106 /// </summary> 107 /// <returns></returns> 108 [MethodImpl(MethodImplOptions.Synchronized)] 109 public static ISessionFactory GetSessionFactory() { 110 if (sessionFactory == null) { 111 sessionFactory = ApplicationManager.Manager.GetInstances<ISessionFactory>().First(); 112 sessionFactory.DbConnectionType = typeof(SqlConnection); 113 sessionFactory.DbConnectionString = HeuristicLab.Hive.Server.Core.Properties.Settings.Default.HiveServerConnectionString; 114 } 115 116 return sessionFactory; 117 } 118 119 /// <summary> 120 /// Gets the scheduler 121 /// </summary> 122 /// <returns></returns> 123 [MethodImpl(MethodImplOptions.Synchronized)] 124 public static IScheduler GetScheduler() { 125 if (scheduler == null) { 126 scheduler = ApplicationManager.Manager.GetInstances<IScheduler>().First(); 127 } 128 129 return scheduler; 130 } 131 132 /// <summary> 133 /// Gets the permission manager 134 /// </summary> 135 /// <returns></returns> 136 [MethodImpl(MethodImplOptions.Synchronized)] 137 public static IPermissionManager GetPermissionManager() { 138 if (permManager == null) 139 permManager = ApplicationManager.Manager.GetInstances<IPermissionManager>().First(); 140 return permManager; 141 142 } 143 144 /// <summary> 145 /// Gets the permission manager 146 /// </summary> 147 /// <returns></returns> 148 [MethodImpl(MethodImplOptions.Synchronized)] 149 public static IHivePermissionManager GetHivePermissionManager() { 150 if (hivePermManager == null) 151 hivePermManager = ApplicationManager.Manager.GetInstances<IHivePermissionManager>().First(); 152 return hivePermManager; 153 154 } 155 156 /// <summary> 157 /// Gets the database context manager 158 /// </summary> 159 /// <returns></returns> 160 [MethodImpl(MethodImplOptions.Synchronized)] 161 public static IContextFactory GetContextFactory() { 162 if (contextFactory == null) 163 contextFactory = ApplicationManager.Manager.GetInstances<IContextFactory>().First(); 164 return contextFactory; 165 } 156 166 } 157 167 }
Note: See TracChangeset
for help on using the changeset viewer.