- Timestamp:
- 09/08/11 10:38:36 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3
- Files:
-
- 4 added
- 7 edited
- 29 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Convert.cs
r6703 r6717 24 24 using System.Data.Linq; 25 25 using System.Linq; 26 using DT = HeuristicLab.Services.Hive.Common.DataTransfer; 27 28 namespace HeuristicLab.Services.Hive.DataAccess { 26 using DB = HeuristicLab.Services.Hive.DataAccess; 27 using DT = HeuristicLab.Services.Hive.DataTransfer; 28 29 30 namespace HeuristicLab.Services.Hive.DataTransfer { 29 31 public static class Convert { 30 32 #region Job 31 public static DT.Job ToDto( Job source) {33 public static DT.Job ToDto(DB.Job source) { 32 34 if (source == null) return null; 33 35 return new DT.Job { … … 40 42 PluginsNeededIds = (source.RequiredPlugins == null ? new List<Guid>() : source.RequiredPlugins.Select(x => x.PluginId).ToList()), 41 43 LastHeartbeat = source.LastHeartbeat, 42 State = source.State,44 State = Convert.ToDto(source.State), 43 45 StateLog = (source.StateLogs == null ? new List<DT.StateLog>() : source.StateLogs.Select(x => Convert.ToDto(x)).OrderBy(x => x.DateTime).ToList()), 44 46 IsParentJob = source.IsParentJob, 45 47 FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished, 46 Command = source.Command,48 Command = Convert.ToDto(source.Command), 47 49 LastJobDataUpdate = (source.JobData == null ? DateTime.MinValue : source.JobData.LastUpdate), 48 50 HiveExperimentId = source.HiveExperimentId, … … 50 52 }; 51 53 } 52 public static Job ToEntity(DT.Job source) { 53 if (source == null) return null; 54 var entity = new Job(); ToEntity(source, entity); 55 return entity; 56 } 57 public static void ToEntity(DT.Job source, Job target) { 54 55 public static DB.Job ToEntity(DT.Job source) { 56 if (source == null) return null; 57 var entity = new DB.Job(); ToEntity(source, entity); 58 return entity; 59 } 60 public static void ToEntity(DT.Job source, DB.Job target) { 58 61 if ((source != null) && (target != null)) { 59 62 target.JobId = source.Id; … … 64 67 target.Priority = source.Priority; 65 68 target.LastHeartbeat = source.LastHeartbeat; 66 target.State = source.State;67 if (target.StateLogs == null) target.StateLogs = new EntitySet< StateLog>();69 target.State = Convert.ToEntity(source.State); 70 if (target.StateLogs == null) target.StateLogs = new EntitySet<DB.StateLog>(); 68 71 foreach (DT.StateLog sl in source.StateLog.Where(x => x.Id == Guid.Empty)) { 69 72 target.StateLogs.Add(Convert.ToEntity(sl)); … … 71 74 target.IsParentJob = source.IsParentJob; 72 75 target.FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished; 73 target.Command = source.Command;76 target.Command = Convert.ToEntity(source.Command); 74 77 // RequiredPlugins are added by Dao 75 78 target.HiveExperimentId = source.HiveExperimentId; … … 80 83 81 84 #region JobData 82 public static DT.JobData ToDto( JobData source) {85 public static DT.JobData ToDto(DB.JobData source) { 83 86 if (source == null) return null; 84 87 return new DT.JobData { JobId = source.JobId, Data = source.Data.ToArray(), LastUpdate = source.LastUpdate }; 85 88 } 86 public static JobData ToEntity(DT.JobData source) {87 if (source == null) return null; 88 var entity = new JobData(); ToEntity(source, entity);89 return entity; 90 } 91 public static void ToEntity(DT.JobData source, JobData target) {89 public static DB.JobData ToEntity(DT.JobData source) { 90 if (source == null) return null; 91 var entity = new DB.JobData(); ToEntity(source, entity); 92 return entity; 93 } 94 public static void ToEntity(DT.JobData source, DB.JobData target) { 92 95 if ((source != null) && (target != null)) { 93 96 target.JobId = source.JobId; target.Data = new Binary(source.Data); target.LastUpdate = source.LastUpdate; … … 97 100 98 101 #region StateLog 99 public static DT.StateLog ToDto( StateLog source) {100 if (source == null) return null; 101 return new DT.StateLog { Id = source.StateLogId, DateTime = source.DateTime, Exception = source.Exception, JobId = source.JobId, SlaveId = source.SlaveId, State = source.State, UserId = source.UserId };102 } 103 public static StateLog ToEntity(DT.StateLog source) {104 if (source == null) return null; 105 var entity = new StateLog(); ToEntity(source, entity);106 return entity; 107 } 108 public static void ToEntity(DT.StateLog source, StateLog target) {109 if ((source != null) && (target != null)) { 110 target.StateLogId = source.Id; target.DateTime = source.DateTime; target.Exception = source.Exception; target.JobId = source.JobId; target.SlaveId = source.SlaveId; target.State = source.State; target.UserId = source.UserId;102 public static DT.StateLog ToDto(DB.StateLog source) { 103 if (source == null) return null; 104 return new DT.StateLog { Id = source.StateLogId, DateTime = source.DateTime, Exception = source.Exception, JobId = source.JobId, SlaveId = source.SlaveId, State = Convert.ToDto(source.State), UserId = source.UserId }; 105 } 106 public static DB.StateLog ToEntity(DT.StateLog source) { 107 if (source == null) return null; 108 var entity = new DB.StateLog(); ToEntity(source, entity); 109 return entity; 110 } 111 public static void ToEntity(DT.StateLog source, DB.StateLog target) { 112 if ((source != null) && (target != null)) { 113 target.StateLogId = source.Id; target.DateTime = source.DateTime; target.Exception = source.Exception; target.JobId = source.JobId; target.SlaveId = source.SlaveId; target.State = Convert.ToEntity(source.State); target.UserId = source.UserId; 111 114 } 112 115 } … … 114 117 115 118 #region Downtimes 116 public static DT.Downtime ToDto(D owntime source) {119 public static DT.Downtime ToDto(DB.Downtime source) { 117 120 if (source == null) return null; 118 121 return new DT.Downtime { Id = source.DowntimeId, AllDayEvent = source.AllDayEvent, EndDate = source.EndDate, Recurring = source.Recurring, RecurringId = source.RecurringId, ResourceId = source.ResourceId, StartDate = source.StartDate }; 119 122 } 120 public static D owntime ToEntity(DT.Downtime source) {121 if (source == null) return null; 122 var entity = new D owntime(); ToEntity(source, entity);123 return entity; 124 } 125 public static void ToEntity(DT.Downtime source, D owntime target) {123 public static DB.Downtime ToEntity(DT.Downtime source) { 124 if (source == null) return null; 125 var entity = new DB.Downtime(); ToEntity(source, entity); 126 return entity; 127 } 128 public static void ToEntity(DT.Downtime source, DB.Downtime target) { 126 129 if ((source != null) && (target != null)) { 127 130 target.DowntimeId = source.Id; target.AllDayEvent = source.AllDayEvent; target.EndDate = source.EndDate; target.Recurring = source.Recurring; target.RecurringId = source.RecurringId; target.ResourceId = source.ResourceId; target.StartDate = source.StartDate; … … 131 134 132 135 #region HiveExperiment 133 public static DT.HiveExperiment ToDto( HiveExperiment source) {136 public static DT.HiveExperiment ToDto(DB.HiveExperiment source) { 134 137 if (source == null) return null; 135 138 return new DT.HiveExperiment { Id = source.HiveExperimentId, Description = source.Description, Name = source.Name, OwnerUserId = source.OwnerUserId, DateCreated = source.DateCreated, ResourceNames = source.ResourceIds, LastAccessed = source.LastAccessed }; 136 139 } 137 public static HiveExperiment ToEntity(DT.HiveExperiment source) {138 if (source == null) return null; 139 var entity = new HiveExperiment(); ToEntity(source, entity);140 return entity; 141 } 142 public static void ToEntity(DT.HiveExperiment source, HiveExperiment target) {140 public static DB.HiveExperiment ToEntity(DT.HiveExperiment source) { 141 if (source == null) return null; 142 var entity = new DB.HiveExperiment(); ToEntity(source, entity); 143 return entity; 144 } 145 public static void ToEntity(DT.HiveExperiment source, DB.HiveExperiment target) { 143 146 if ((source != null) && (target != null)) { 144 147 target.HiveExperimentId = source.Id; target.Description = source.Description; target.Name = source.Name; target.OwnerUserId = source.OwnerUserId; target.DateCreated = source.DateCreated; target.ResourceIds = source.ResourceNames; target.LastAccessed = source.LastAccessed; … … 148 151 149 152 #region HiveExperimentPermission 150 public static DT.HiveExperimentPermission ToDto( HiveExperimentPermission source) {151 if (source == null) return null; 152 return new DT.HiveExperimentPermission { HiveExperimentId = source.HiveExperimentId, GrantedUserId = source.GrantedUserId, GrantedByUserId = source.GrantedByUserId, Permission = source.Permission};153 } 154 public static HiveExperimentPermission ToEntity(DT.HiveExperimentPermission source) {155 if (source == null) return null; 156 var entity = new HiveExperimentPermission(); ToEntity(source, entity);157 return entity; 158 } 159 public static void ToEntity(DT.HiveExperimentPermission source, HiveExperimentPermission target) {160 if ((source != null) && (target != null)) { 161 target.HiveExperimentId = source.HiveExperimentId; target.GrantedUserId = source.GrantedUserId; target.GrantedByUserId = source.GrantedByUserId; target.Permission = source.Permission;153 public static DT.HiveExperimentPermission ToDto(DB.HiveExperimentPermission source) { 154 if (source == null) return null; 155 return new DT.HiveExperimentPermission { HiveExperimentId = source.HiveExperimentId, GrantedUserId = source.GrantedUserId, GrantedByUserId = source.GrantedByUserId, Permission = Convert.ToDto(source.Permission) }; 156 } 157 public static DB.HiveExperimentPermission ToEntity(DT.HiveExperimentPermission source) { 158 if (source == null) return null; 159 var entity = new DB.HiveExperimentPermission(); ToEntity(source, entity); 160 return entity; 161 } 162 public static void ToEntity(DT.HiveExperimentPermission source, DB.HiveExperimentPermission target) { 163 if ((source != null) && (target != null)) { 164 target.HiveExperimentId = source.HiveExperimentId; target.GrantedUserId = source.GrantedUserId; target.GrantedByUserId = source.GrantedByUserId; target.Permission = Convert.ToEntity(source.Permission); 162 165 } 163 166 } … … 165 168 166 169 #region Plugin 167 public static DT.Plugin ToDto( Plugin source) {170 public static DT.Plugin ToDto(DB.Plugin source) { 168 171 if (source == null) return null; 169 172 return new DT.Plugin { Id = source.PluginId, Name = source.Name, Version = new Version(source.Version), UserId = source.UserId, DateCreated = source.DateCreated, Hash = source.Hash }; 170 173 } 171 public static Plugin ToEntity(DT.Plugin source) {172 if (source == null) return null; 173 var entity = new Plugin(); ToEntity(source, entity);174 return entity; 175 } 176 public static void ToEntity(DT.Plugin source, Plugin target) {174 public static DB.Plugin ToEntity(DT.Plugin source) { 175 if (source == null) return null; 176 var entity = new DB.Plugin(); ToEntity(source, entity); 177 return entity; 178 } 179 public static void ToEntity(DT.Plugin source, DB.Plugin target) { 177 180 if ((source != null) && (target != null)) { 178 181 target.PluginId = source.Id; target.Name = source.Name; target.Version = source.Version.ToString(); target.UserId = source.UserId; target.DateCreated = source.DateCreated; target.Hash = source.Hash; … … 182 185 183 186 #region PluginData 184 public static DT.PluginData ToDto( PluginData source) {187 public static DT.PluginData ToDto(DB.PluginData source) { 185 188 if (source == null) return null; 186 189 return new DT.PluginData { Id = source.PluginDataId, PluginId = source.PluginId, Data = source.Data.ToArray(), FileName = source.FileName }; 187 190 } 188 public static PluginData ToEntity(DT.PluginData source) {189 if (source == null) return null; 190 var entity = new PluginData(); ToEntity(source, entity);191 return entity; 192 } 193 public static void ToEntity(DT.PluginData source, PluginData target) {191 public static DB.PluginData ToEntity(DT.PluginData source) { 192 if (source == null) return null; 193 var entity = new DB.PluginData(); ToEntity(source, entity); 194 return entity; 195 } 196 public static void ToEntity(DT.PluginData source, DB.PluginData target) { 194 197 if ((source != null) && (target != null)) { 195 198 target.PluginDataId = source.Id; target.PluginId = source.PluginId; target.Data = new Binary(source.Data); target.FileName = source.FileName; … … 199 202 200 203 #region Slave 201 public static DT.Slave ToDto( Slave source) {204 public static DT.Slave ToDto(DB.Slave source) { 202 205 if (source == null) return null; 203 206 return new DT.Slave { … … 211 214 Memory = source.Memory, 212 215 Name = source.Name, 213 SlaveState = source.SlaveState,214 CpuArchitecture = source.CpuArchitecture,216 SlaveState = Convert.ToDto(source.SlaveState), 217 CpuArchitecture = Convert.ToDto(source.CpuArchitecture), 215 218 OperatingSystem = source.OperatingSystem, 216 219 LastHeartbeat = source.LastHeartbeat, … … 218 221 }; 219 222 } 220 public static Slave ToEntity(DT.Slave source) {221 if (source == null) return null; 222 var entity = new Slave(); ToEntity(source, entity);223 return entity; 224 } 225 public static void ToEntity(DT.Slave source, Slave target) {223 public static DB.Slave ToEntity(DT.Slave source) { 224 if (source == null) return null; 225 var entity = new DB.Slave(); ToEntity(source, entity); 226 return entity; 227 } 228 public static void ToEntity(DT.Slave source, DB.Slave target) { 226 229 if ((source != null) && (target != null)) { 227 230 target.ResourceId = source.Id; … … 234 237 target.Memory = source.Memory; 235 238 target.Name = source.Name; 236 target.SlaveState = source.SlaveState;237 target.CpuArchitecture = source.CpuArchitecture;239 target.SlaveState = Convert.ToEntity(source.SlaveState); 240 target.CpuArchitecture = Convert.ToEntity(source.CpuArchitecture); 238 241 target.OperatingSystem = source.OperatingSystem; 239 242 target.LastHeartbeat = source.LastHeartbeat; … … 244 247 245 248 #region SlaveGroup 246 public static DT.SlaveGroup ToDto( SlaveGroup source) {249 public static DT.SlaveGroup ToDto(DB.SlaveGroup source) { 247 250 if (source == null) return null; 248 251 return new DT.SlaveGroup { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId }; 249 252 } 250 public static SlaveGroup ToEntity(DT.SlaveGroup source) {251 if (source == null) return null; 252 var entity = new SlaveGroup(); ToEntity(source, entity);253 return entity; 254 } 255 public static void ToEntity(DT.SlaveGroup source, SlaveGroup target) {253 public static DB.SlaveGroup ToEntity(DT.SlaveGroup source) { 254 if (source == null) return null; 255 var entity = new DB.SlaveGroup(); ToEntity(source, entity); 256 return entity; 257 } 258 public static void ToEntity(DT.SlaveGroup source, DB.SlaveGroup target) { 256 259 if ((source != null) && (target != null)) { 257 260 target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; … … 261 264 262 265 #region Resource 263 public static DT.Resource ToDto( Resource source) {266 public static DT.Resource ToDto(DB.Resource source) { 264 267 if (source == null) return null; 265 268 return new DT.Resource { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId }; 266 269 } 267 public static Resource ToEntity(DT.Resource source) {268 if (source == null) return null; 269 var entity = new Resource(); ToEntity(source, entity);270 return entity; 271 } 272 public static void ToEntity(DT.Resource source, Resource target) {270 public static DB.Resource ToEntity(DT.Resource source) { 271 if (source == null) return null; 272 var entity = new DB.Resource(); ToEntity(source, entity); 273 return entity; 274 } 275 public static void ToEntity(DT.Resource source, DB.Resource target) { 273 276 if ((source != null) && (target != null)) { 274 277 target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; … … 278 281 279 282 #region Statistics 280 public static DT.Statistics ToDto( Statistics source) {283 public static DT.Statistics ToDto(DB.Statistics source) { 281 284 if (source == null) return null; 282 285 return new DT.Statistics { … … 287 290 }; 288 291 } 289 public static Statistics ToEntity(DT.Statistics source) {290 if (source == null) return null; 291 var entity = new Statistics(); ToEntity(source, entity);292 return entity; 293 } 294 public static void ToEntity(DT.Statistics source, Statistics target) {292 public static DB.Statistics ToEntity(DT.Statistics source) { 293 if (source == null) return null; 294 var entity = new DB.Statistics(); ToEntity(source, entity); 295 return entity; 296 } 297 public static void ToEntity(DT.Statistics source, DB.Statistics target) { 295 298 if ((source != null) && (target != null)) { 296 299 target.StatisticsId = source.Id; … … 302 305 303 306 #region SlaveStatistics 304 public static DT.SlaveStatistics ToDto( SlaveStatistics source) {307 public static DT.SlaveStatistics ToDto(DB.SlaveStatistics source) { 305 308 if (source == null) return null; 306 309 return new DT.SlaveStatistics { … … 314 317 }; 315 318 } 316 public static SlaveStatistics ToEntity(DT.SlaveStatistics source) {317 if (source == null) return null; 318 var entity = new SlaveStatistics(); ToEntity(source, entity);319 return entity; 320 } 321 public static void ToEntity(DT.SlaveStatistics source, SlaveStatistics target) {319 public static DB.SlaveStatistics ToEntity(DT.SlaveStatistics source) { 320 if (source == null) return null; 321 var entity = new DB.SlaveStatistics(); ToEntity(source, entity); 322 return entity; 323 } 324 public static void ToEntity(DT.SlaveStatistics source, DB.SlaveStatistics target) { 322 325 if ((source != null) && (target != null)) { 323 326 target.StatisticsId = source.Id; … … 333 336 334 337 #region UserStatistics 335 public static DT.UserStatistics ToDto( UserStatistics source) {338 public static DT.UserStatistics ToDto(DB.UserStatistics source) { 336 339 if (source == null) return null; 337 340 return new DT.UserStatistics { … … 344 347 }; 345 348 } 346 public static UserStatistics ToEntity(DT.UserStatistics source) {347 if (source == null) return null; 348 var entity = new UserStatistics(); ToEntity(source, entity);349 return entity; 350 } 351 public static void ToEntity(DT.UserStatistics source, UserStatistics target) {349 public static DB.UserStatistics ToEntity(DT.UserStatistics source) { 350 if (source == null) return null; 351 var entity = new DB.UserStatistics(); ToEntity(source, entity); 352 return entity; 353 } 354 public static void ToEntity(DT.UserStatistics source, DB.UserStatistics target) { 352 355 if ((source != null) && (target != null)) { 353 356 target.StatisticsId = source.Id; … … 360 363 } 361 364 #endregion 365 366 367 #region JobState 368 public static DT.JobState ToDto(DB.JobState source) { 369 if (source == DB.JobState.Aborted) { 370 return JobState.Aborted; 371 } else if (source == DB.JobState.Calculating) { 372 return JobState.Calculating; 373 } else if (source == DB.JobState.Failed) { 374 return JobState.Failed; 375 } else if (source == DB.JobState.Finished) { 376 return JobState.Finished; 377 } else if (source == DB.JobState.Offline) { 378 return JobState.Offline; 379 } else if (source == DB.JobState.Paused) { 380 return JobState.Paused; 381 } else if (source == DB.JobState.Transferring) { 382 return JobState.Transferring; 383 } else if (source == DB.JobState.Waiting) { 384 return JobState.Waiting; 385 } else 386 return JobState.Failed; 387 } 388 389 public static DB.JobState ToEntity(DT.JobState source) { 390 if (source == DT.JobState.Aborted) { 391 return DB.JobState.Aborted; 392 } else if (source == DT.JobState.Calculating) { 393 return DB.JobState.Calculating; 394 } else if (source == DT.JobState.Failed) { 395 return DB.JobState.Failed; 396 } else if (source == DT.JobState.Finished) { 397 return DB.JobState.Finished; 398 } else if (source == DT.JobState.Offline) { 399 return DB.JobState.Offline; 400 } else if (source == DT.JobState.Paused) { 401 return DB.JobState.Paused; 402 } else if (source == DT.JobState.Transferring) { 403 return DB.JobState.Transferring; 404 } else if (source == DT.JobState.Waiting) { 405 return DB.JobState.Waiting; 406 } else 407 return DB.JobState.Failed; 408 } 409 #endregion 410 411 #region Permission 412 public static DT.Permission ToDto(DB.Permission source) { 413 if (source == DB.Permission.Full) { 414 return Permission.Full; 415 } else if (source == DB.Permission.NotAllowed) { 416 return Permission.NotAllowed; 417 } else if (source == DB.Permission.Read) { 418 return Permission.Read; 419 } else 420 return Permission.NotAllowed; 421 } 422 423 public static DB.Permission ToEntity(DT.Permission source) { 424 if (source == DT.Permission.Full) { 425 return DB.Permission.Full; 426 } else if (source == DT.Permission.NotAllowed) { 427 return DB.Permission.NotAllowed; 428 } else if (source == DT.Permission.Read) { 429 return DB.Permission.Read; 430 } else 431 return DB.Permission.NotAllowed; 432 } 433 #endregion 434 435 436 #region Command 437 public static DT.Command? ToDto(DB.Command? source) { 438 if (source.HasValue) { 439 if (source.Value == DB.Command.Abort) { 440 return Command.Abort; 441 } else if (source.Value == DB.Command.Pause) { 442 return Command.Pause; 443 } else if (source.Value == DB.Command.Stop) { 444 return Command.Stop; 445 } else 446 return Command.Pause; 447 } 448 return null; 449 } 450 451 public static DB.Command? ToEntity(DT.Command? source) { 452 if (source.HasValue) { 453 if (source == DT.Command.Abort) { 454 return DB.Command.Abort; 455 } else if (source == DT.Command.Pause) { 456 return DB.Command.Pause; 457 } else if (source == DT.Command.Stop) { 458 return DB.Command.Stop; 459 } else 460 return DB.Command.Pause; 461 } else 462 return null; 463 } 464 465 #endregion 466 467 #region CpuArchiteture 468 public static DT.CpuArchitecture ToDto(DB.CpuArchitecture source) { 469 if (source == DB.CpuArchitecture.x64) { 470 return CpuArchitecture.x64; 471 } else if (source == DB.CpuArchitecture.x86) { 472 return CpuArchitecture.x86; 473 } else 474 return CpuArchitecture.x86; 475 } 476 477 public static DB.CpuArchitecture ToEntity(DT.CpuArchitecture source) { 478 if (source == DT.CpuArchitecture.x64) { 479 return DB.CpuArchitecture.x64; 480 } else if (source == DT.CpuArchitecture.x86) { 481 return DB.CpuArchitecture.x86; 482 } else 483 return DB.CpuArchitecture.x86; 484 } 485 #endregion 486 487 #region SlaveState 488 public static DT.SlaveState ToDto(DB.SlaveState source) { 489 if (source == DB.SlaveState.Calculating) { 490 return SlaveState.Calculating; 491 } else if (source == DB.SlaveState.Idle) { 492 return SlaveState.Idle; 493 } else if (source == DB.SlaveState.Offline) { 494 return SlaveState.Offline; 495 } else 496 return SlaveState.Offline; 497 } 498 499 public static DB.SlaveState ToEntity(DT.SlaveState source) { 500 if (source == DT.SlaveState.Calculating) { 501 return DB.SlaveState.Calculating; 502 } else if (source == DT.SlaveState.Idle) { 503 return DB.SlaveState.Idle; 504 } else if (source == DT.SlaveState.Offline) { 505 return DB.SlaveState.Offline; 506 } else 507 return DB.SlaveState.Offline; 508 } 509 #endregion 362 510 } 363 511 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Command.cs
r6703 r6717 22 22 using System; 23 23 24 namespace HeuristicLab.Services.Hive. Common.DataTransfer {24 namespace HeuristicLab.Services.Hive.DataTransfer { 25 25 [Serializable] 26 26 public enum Command { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Downtime.cs
r6703 r6717 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab.Services.Hive. Common.DataTransfer {25 namespace HeuristicLab.Services.Hive.DataTransfer { 26 26 [DataContract] 27 27 public class Downtime : HiveItem { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/HiveExperiment.cs
r6703 r6717 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab.Services.Hive. Common.DataTransfer {25 namespace HeuristicLab.Services.Hive.DataTransfer { 26 26 [DataContract] 27 27 [Serializable] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/HiveExperimentPermission.cs
r6703 r6717 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab.Services.Hive. Common.DataTransfer {25 namespace HeuristicLab.Services.Hive.DataTransfer { 26 26 [DataContract] 27 27 [Serializable] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/HiveItem.cs
r6703 r6717 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab.Services.Hive. Common.DataTransfer {25 namespace HeuristicLab.Services.Hive.DataTransfer { 26 26 [DataContract] 27 27 [Serializable] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Job.cs
r6703 r6717 24 24 using System.Runtime.Serialization; 25 25 26 namespace HeuristicLab.Services.Hive. Common.DataTransfer {26 namespace HeuristicLab.Services.Hive.DataTransfer { 27 27 [DataContract] 28 28 [Serializable] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/JobData.cs
r6703 r6717 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab.Services.Hive. Common.DataTransfer {25 namespace HeuristicLab.Services.Hive.DataTransfer { 26 26 [DataContract] 27 27 [Serializable] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/JobState.cs
r6703 r6717 22 22 using System; 23 23 24 namespace HeuristicLab.Services.Hive. Common.DataTransfer {24 namespace HeuristicLab.Services.Hive.DataTransfer { 25 25 [Serializable] 26 26 public enum JobState { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/LightweightJob.cs
r6703 r6717 25 25 using System.Runtime.Serialization; 26 26 27 namespace HeuristicLab.Services.Hive. Common.DataTransfer {27 namespace HeuristicLab.Services.Hive.DataTransfer { 28 28 [DataContract] 29 29 [Serializable] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/NamedHiveItem.cs
r6703 r6717 22 22 using System.Runtime.Serialization; 23 23 24 namespace HeuristicLab.Services.Hive. Common.DataTransfer {24 namespace HeuristicLab.Services.Hive.DataTransfer { 25 25 [DataContract] 26 26 public abstract class NamedHiveItem : HiveItem { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Permission.cs
r6703 r6717 20 20 #endregion 21 21 22 namespace HeuristicLab.Services.Hive. Common.DataTransfer {22 namespace HeuristicLab.Services.Hive.DataTransfer { 23 23 public enum Permission { 24 24 /// <summary> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Plugin.cs
r6703 r6717 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab.Services.Hive. Common.DataTransfer {25 namespace HeuristicLab.Services.Hive.DataTransfer { 26 26 [DataContract] 27 27 [Serializable] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/PluginData.cs
r6703 r6717 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab.Services.Hive. Common.DataTransfer {25 namespace HeuristicLab.Services.Hive.DataTransfer { 26 26 [Serializable] 27 27 [DataContract] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Resource.cs
r6703 r6717 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab.Services.Hive. Common.DataTransfer {25 namespace HeuristicLab.Services.Hive.DataTransfer { 26 26 [DataContract] 27 27 [Serializable] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Slave.cs
r6703 r6717 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab.Services.Hive. Common.DataTransfer {25 namespace HeuristicLab.Services.Hive.DataTransfer { 26 26 public enum CpuArchitecture { 27 27 x86, x64 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/SlaveGroup.cs
r6703 r6717 22 22 using System.Runtime.Serialization; 23 23 24 namespace HeuristicLab.Services.Hive. Common.DataTransfer {24 namespace HeuristicLab.Services.Hive.DataTransfer { 25 25 [DataContract] 26 26 public class SlaveGroup : Resource { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/SlaveState.cs
r6703 r6717 21 21 22 22 23 namespace HeuristicLab.Services.Hive. Common.DataTransfer {23 namespace HeuristicLab.Services.Hive.DataTransfer { 24 24 public enum SlaveState { 25 25 Idle, -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/SlaveStatistics.cs
r6703 r6717 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab.Services.Hive. Common.DataTransfer {25 namespace HeuristicLab.Services.Hive.DataTransfer { 26 26 [DataContract] 27 27 [Serializable] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/StateLog.cs
r6703 r6717 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab.Services.Hive. Common.DataTransfer {25 namespace HeuristicLab.Services.Hive.DataTransfer { 26 26 [DataContract] 27 27 [Serializable] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Statistics.cs
r6703 r6717 24 24 using System.Runtime.Serialization; 25 25 26 namespace HeuristicLab.Services.Hive. Common.DataTransfer {26 namespace HeuristicLab.Services.Hive.DataTransfer { 27 27 [DataContract] 28 28 [Serializable] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/UserStatistics.cs
r6703 r6717 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab.Services.Hive. Common.DataTransfer {25 namespace HeuristicLab.Services.Hive.DataTransfer { 26 26 [DataContract] 27 27 [Serializable] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj
r6701 r6717 92 92 <Reference Include="System.Data.Linq" /> 93 93 <Reference Include="System.Drawing" /> 94 <Reference Include="System.Runtime.Serialization" /> 94 95 <Reference Include="System.ServiceModel" /> 95 96 <Reference Include="System.Transactions" /> … … 103 104 </ItemGroup> 104 105 <ItemGroup> 106 <Compile Include="Convert.cs" /> 107 <Compile Include="DataTransfer\Command.cs" /> 108 <Compile Include="DataTransfer\Downtime.cs" /> 109 <Compile Include="DataTransfer\Heartbeat.cs" /> 110 <Compile Include="DataTransfer\HiveExperiment.cs" /> 111 <Compile Include="DataTransfer\HiveExperimentPermission.cs" /> 112 <Compile Include="DataTransfer\HiveItem.cs" /> 113 <Compile Include="DataTransfer\Job.cs" /> 114 <Compile Include="DataTransfer\JobData.cs" /> 115 <Compile Include="DataTransfer\JobState.cs" /> 116 <Compile Include="DataTransfer\LightweightJob.cs" /> 117 <Compile Include="DataTransfer\NamedHiveItem.cs" /> 118 <Compile Include="DataTransfer\Permission.cs" /> 119 <Compile Include="DataTransfer\Plugin.cs" /> 120 <Compile Include="DataTransfer\PluginData.cs" /> 121 <Compile Include="DataTransfer\Resource.cs" /> 122 <Compile Include="DataTransfer\Slave.cs" /> 123 <Compile Include="DataTransfer\SlaveGroup.cs" /> 124 <Compile Include="DataTransfer\SlaveState.cs" /> 125 <Compile Include="DataTransfer\SlaveStatistics.cs" /> 126 <Compile Include="DataTransfer\StateLog.cs" /> 127 <Compile Include="DataTransfer\Statistics.cs" /> 128 <Compile Include="DataTransfer\UserStatistics.cs" /> 129 <Compile Include="HiveDao.cs" /> 130 <Compile Include="Interfaces\IHiveDao.cs" /> 105 131 <Compile Include="Interfaces\IUserManager.cs" /> 106 132 <Compile Include="Manager\UserManager.cs" /> … … 118 144 <Compile Include="HiveService.cs" /> 119 145 <Compile Include="Interfaces\IAuthorizationManager.cs" /> 146 <Compile Include="MessageContainer.cs" /> 120 147 <Compile Include="Properties\AssemblyInfo.cs" /> 148 <Compile Include="Properties\Settings.Designer.cs"> 149 <DependentUpon>Settings.settings</DependentUpon> 150 <AutoGen>True</AutoGen> 151 <DesignTimeSharedInput>True</DesignTimeSharedInput> 152 </Compile> 153 <Compile Include="ServiceContracts\IHiveService.cs" /> 154 <Compile Include="ServiceFaults\PluginAlreadyExistsFault.cs" /> 121 155 <Compile Include="ServiceLocator.cs" /> 122 </ItemGroup>123 <ItemGroup>124 <ProjectReference Include="..\..\HeuristicLab.Services.Hive.Common\3.3\HeuristicLab.Services.Hive.Common-3.3.csproj">125 <Project>{14424A16-48D4-445E-80BF-DDF617548BBB}</Project>126 <Name>HeuristicLab.Services.Hive.Common-3.3</Name>127 </ProjectReference>156 <None Include="Properties\Settings.settings"> 157 <Generator>PublicSettingsSingleFileGenerator</Generator> 158 <LastGenOutput>Settings.Designer.cs</LastGenOutput> 159 </None> 160 </ItemGroup> 161 <ItemGroup> 128 162 <ProjectReference Include="..\..\HeuristicLab.Services.Hive.DataAccess\3.3\HeuristicLab.Services.Hive.DataAccess-3.3.csproj"> 129 163 <Project>{EC2C8109-6E1E-4C88-9A2B-908CFF2EF4AC}</Project> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HeuristicLabServicesHivePlugin.cs.frame
r6701 r6717 32 32 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] 33 33 [PluginDependency("HeuristicLab.Core", "3.3")] 34 [PluginDependency("HeuristicLab.Persistence", "3.3")] 35 [PluginDependency("HeuristicLab.Services.Hive.Common", "3.3")] 34 [PluginDependency("HeuristicLab.Persistence", "3.3")] 36 35 [PluginDependency("HeuristicLab.Services.Hive.DataAccess", "3.3")] 37 36 public class HeuristicLabServicesHivePlugin : PluginBase { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs
r6703 r6717 24 24 using System.Linq; 25 25 using System.Linq.Expressions; 26 using HeuristicLab.Services.Hive.Common.DataTransfer; 27 using DT = HeuristicLab.Services.Hive.Common.DataTransfer; 26 using DT = HeuristicLab.Services.Hive.DataTransfer; 28 27 29 28 namespace HeuristicLab.Services.Hive.DataAccess { … … 40 39 public DT.Job GetJob(Guid id) { 41 40 using (var db = CreateContext()) { 42 return Convert.ToDto(db.Jobs.SingleOrDefault(x => x.JobId == id));41 return DT.Convert.ToDto(db.Jobs.SingleOrDefault(x => x.JobId == id)); 43 42 } 44 43 } … … 46 45 public IEnumerable<DT.Job> GetJobs(Expression<Func<Job, bool>> predicate) { 47 46 using (var db = CreateContext()) { 48 return db.Jobs.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();47 return db.Jobs.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); 49 48 } 50 49 } … … 52 51 public Guid AddJob(DT.Job dto) { 53 52 using (var db = CreateContext()) { 54 var entity = Convert.ToEntity(dto);53 var entity = DT.Convert.ToEntity(dto); 55 54 db.Jobs.InsertOnSubmit(entity); 56 55 db.SubmitChanges(); … … 66 65 using (var db = CreateContext()) { 67 66 var entity = db.Jobs.FirstOrDefault(x => x.JobId == dto.Id); 68 if (entity == null) db.Jobs.InsertOnSubmit( Convert.ToEntity(dto));69 else Convert.ToEntity(dto, entity);67 if (entity == null) db.Jobs.InsertOnSubmit(DT.Convert.ToEntity(dto)); 68 else DT.Convert.ToEntity(dto, entity); 70 69 foreach (Guid pluginId in dto.PluginsNeededIds) { 71 70 if (db.RequiredPlugins.Count(p => p.PluginId == pluginId) == 0) { … … 108 107 select child).Count() > 0 109 108 orderby ar.Job.Priority descending, db.Random() 110 select Convert.ToDto(ar.Job);109 select DT.Convert.ToDto(ar.Job); 111 110 return count == 0 ? query.ToArray() : query.Take(count).ToArray(); 112 111 } … … 126 125 && ar.Job.MemoryNeeded <= slave.FreeMemory 127 126 orderby ar.Job.Priority descending, db.Random() // take random job to avoid the race condition that occurs when this method is called concurrently (the same job would be returned) 128 select Convert.ToDto(ar.Job);127 select DT.Convert.ToDto(ar.Job); 129 128 var waitingJobs = (count == 0 ? query : query.Take(count)).ToArray(); 130 129 return waitingJobs.Union(waitingParentJobs).OrderByDescending(x => x.Priority); … … 146 145 db.SubmitChanges(); 147 146 job = db.Jobs.SingleOrDefault(x => x.JobId == jobId); 148 return Convert.ToDto(job);147 return DT.Convert.ToDto(job); 149 148 } 150 149 } … … 154 153 public DT.JobData GetJobData(Guid id) { 155 154 using (var db = CreateContext(true)) { 156 return Convert.ToDto(db.JobDatas.SingleOrDefault(x => x.JobId == id));155 return DT.Convert.ToDto(db.JobDatas.SingleOrDefault(x => x.JobId == id)); 157 156 } 158 157 } … … 160 159 public IEnumerable<DT.JobData> GetJobDatas(Expression<Func<JobData, bool>> predicate) { 161 160 using (var db = CreateContext(true)) { 162 return db.JobDatas.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();161 return db.JobDatas.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); 163 162 } 164 163 } … … 166 165 public Guid AddJobData(DT.JobData dto) { 167 166 using (var db = CreateContext(true)) { 168 var entity = Convert.ToEntity(dto);167 var entity = DT.Convert.ToEntity(dto); 169 168 db.JobDatas.InsertOnSubmit(entity); 170 169 db.SubmitChanges(); … … 176 175 using (var db = CreateContext(true)) { 177 176 var entity = db.JobDatas.FirstOrDefault(x => x.JobId == dto.JobId); 178 if (entity == null) db.JobDatas.InsertOnSubmit( Convert.ToEntity(dto));179 else Convert.ToEntity(dto, entity);177 if (entity == null) db.JobDatas.InsertOnSubmit(DT.Convert.ToEntity(dto)); 178 else DT.Convert.ToEntity(dto, entity); 180 179 db.SubmitChanges(); 181 180 } … … 194 193 public DT.StateLog GetStateLog(Guid id) { 195 194 using (var db = CreateContext()) { 196 return Convert.ToDto(db.StateLogs.SingleOrDefault(x => x.StateLogId == id));195 return DT.Convert.ToDto(db.StateLogs.SingleOrDefault(x => x.StateLogId == id)); 197 196 } 198 197 } … … 200 199 public IEnumerable<DT.StateLog> GetStateLogs(Expression<Func<StateLog, bool>> predicate) { 201 200 using (var db = CreateContext()) { 202 return db.StateLogs.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();201 return db.StateLogs.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); 203 202 } 204 203 } … … 206 205 public Guid AddStateLog(DT.StateLog dto) { 207 206 using (var db = CreateContext()) { 208 var entity = Convert.ToEntity(dto);207 var entity = DT.Convert.ToEntity(dto); 209 208 db.StateLogs.InsertOnSubmit(entity); 210 209 db.SubmitChanges(); … … 216 215 using (var db = CreateContext()) { 217 216 var entity = db.StateLogs.FirstOrDefault(x => x.StateLogId == dto.Id); 218 if (entity == null) db.StateLogs.InsertOnSubmit( Convert.ToEntity(dto));219 else Convert.ToEntity(dto, entity);217 if (entity == null) db.StateLogs.InsertOnSubmit(DT.Convert.ToEntity(dto)); 218 else DT.Convert.ToEntity(dto, entity); 220 219 db.SubmitChanges(); 221 220 } … … 234 233 public DT.HiveExperiment GetHiveExperiment(Guid id) { 235 234 using (var db = CreateContext()) { 236 return AddStatsToExperiment(db, Convert.ToDto(db.HiveExperiments.SingleOrDefault(x => x.HiveExperimentId == id)));235 return AddStatsToExperiment(db, DT.Convert.ToDto(db.HiveExperiments.SingleOrDefault(x => x.HiveExperimentId == id))); 237 236 } 238 237 } … … 251 250 public IEnumerable<DT.HiveExperiment> GetHiveExperiments(Expression<Func<HiveExperiment, bool>> predicate) { 252 251 using (var db = CreateContext()) { 253 return db.HiveExperiments.Where(predicate).Select(x => AddStatsToExperiment(db, Convert.ToDto(x))).ToArray();252 return db.HiveExperiments.Where(predicate).Select(x => AddStatsToExperiment(db, DT.Convert.ToDto(x))).ToArray(); 254 253 } 255 254 } … … 257 256 public Guid AddHiveExperiment(DT.HiveExperiment dto) { 258 257 using (var db = CreateContext()) { 259 var entity = Convert.ToEntity(dto);258 var entity = DT.Convert.ToEntity(dto); 260 259 db.HiveExperiments.InsertOnSubmit(entity); 261 260 db.SubmitChanges(); … … 267 266 using (var db = CreateContext()) { 268 267 var entity = db.HiveExperiments.FirstOrDefault(x => x.HiveExperimentId == dto.Id); 269 if (entity == null) db.HiveExperiments.InsertOnSubmit( Convert.ToEntity(dto));270 else Convert.ToEntity(dto, entity);268 if (entity == null) db.HiveExperiments.InsertOnSubmit(DT.Convert.ToEntity(dto)); 269 else DT.Convert.ToEntity(dto, entity); 271 270 db.SubmitChanges(); 272 271 } … … 285 284 public DT.HiveExperimentPermission GetHiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId) { 286 285 using (var db = CreateContext()) { 287 return Convert.ToDto(db.HiveExperimentPermissions.SingleOrDefault(x => x.HiveExperimentId == hiveExperimentId && x.GrantedUserId == grantedUserId));286 return DT.Convert.ToDto(db.HiveExperimentPermissions.SingleOrDefault(x => x.HiveExperimentId == hiveExperimentId && x.GrantedUserId == grantedUserId)); 288 287 } 289 288 } … … 291 290 public IEnumerable<DT.HiveExperimentPermission> GetHiveExperimentPermissions(Expression<Func<HiveExperimentPermission, bool>> predicate) { 292 291 using (var db = CreateContext()) { 293 return db.HiveExperimentPermissions.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();292 return db.HiveExperimentPermissions.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); 294 293 } 295 294 } … … 297 296 public void AddHiveExperimentPermission(DT.HiveExperimentPermission dto) { 298 297 using (var db = CreateContext()) { 299 var entity = Convert.ToEntity(dto);298 var entity = DT.Convert.ToEntity(dto); 300 299 db.HiveExperimentPermissions.InsertOnSubmit(entity); 301 300 db.SubmitChanges(); … … 306 305 using (var db = CreateContext()) { 307 306 var entity = db.HiveExperimentPermissions.FirstOrDefault(x => x.HiveExperimentId == dto.HiveExperimentId && x.GrantedUserId == dto.GrantedUserId); 308 if (entity == null) db.HiveExperimentPermissions.InsertOnSubmit( Convert.ToEntity(dto));309 else Convert.ToEntity(dto, entity);307 if (entity == null) db.HiveExperimentPermissions.InsertOnSubmit(DT.Convert.ToEntity(dto)); 308 else DT.Convert.ToEntity(dto, entity); 310 309 db.SubmitChanges(); 311 310 } … … 350 349 public DT.Plugin GetPlugin(Guid id) { 351 350 using (var db = CreateContext()) { 352 return Convert.ToDto(db.Plugins.SingleOrDefault(x => x.PluginId == id));351 return DT.Convert.ToDto(db.Plugins.SingleOrDefault(x => x.PluginId == id)); 353 352 } 354 353 } … … 356 355 public IEnumerable<DT.Plugin> GetPlugins(Expression<Func<Plugin, bool>> predicate) { 357 356 using (var db = CreateContext()) { 358 return db.Plugins.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();357 return db.Plugins.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); 359 358 } 360 359 } … … 362 361 public Guid AddPlugin(DT.Plugin dto) { 363 362 using (var db = CreateContext()) { 364 var entity = Convert.ToEntity(dto);363 var entity = DT.Convert.ToEntity(dto); 365 364 db.Plugins.InsertOnSubmit(entity); 366 365 db.SubmitChanges(); … … 372 371 using (var db = CreateContext()) { 373 372 var entity = db.Plugins.FirstOrDefault(x => x.PluginId == dto.Id); 374 if (entity == null) db.Plugins.InsertOnSubmit( Convert.ToEntity(dto));375 else Convert.ToEntity(dto, entity);373 if (entity == null) db.Plugins.InsertOnSubmit(DT.Convert.ToEntity(dto)); 374 else DT.Convert.ToEntity(dto, entity); 376 375 db.SubmitChanges(); 377 376 } … … 390 389 public DT.PluginData GetPluginData(Guid id) { 391 390 using (var db = CreateContext()) { 392 return Convert.ToDto(db.PluginDatas.SingleOrDefault(x => x.PluginDataId == id));391 return DT.Convert.ToDto(db.PluginDatas.SingleOrDefault(x => x.PluginDataId == id)); 393 392 } 394 393 } … … 396 395 public IEnumerable<DT.PluginData> GetPluginDatas(Expression<Func<PluginData, bool>> predicate) { 397 396 using (var db = CreateContext()) { 398 return db.PluginDatas.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();397 return db.PluginDatas.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); 399 398 } 400 399 } … … 402 401 public Guid AddPluginData(DT.PluginData dto) { 403 402 using (var db = CreateContext()) { 404 var entity = Convert.ToEntity(dto);403 var entity = DT.Convert.ToEntity(dto); 405 404 db.PluginDatas.InsertOnSubmit(entity); 406 405 db.SubmitChanges(); … … 412 411 using (var db = CreateContext()) { 413 412 var entity = db.PluginDatas.FirstOrDefault(x => x.PluginId == dto.PluginId); 414 if (entity == null) db.PluginDatas.InsertOnSubmit( Convert.ToEntity(dto));415 else Convert.ToEntity(dto, entity);413 if (entity == null) db.PluginDatas.InsertOnSubmit(DT.Convert.ToEntity(dto)); 414 else DT.Convert.ToEntity(dto, entity); 416 415 db.SubmitChanges(); 417 416 } … … 430 429 public DT.Slave GetSlave(Guid id) { 431 430 using (var db = CreateContext()) { 432 return Convert.ToDto(db.Resources.OfType<Slave>().SingleOrDefault(x => x.ResourceId == id));431 return DT.Convert.ToDto(db.Resources.OfType<Slave>().SingleOrDefault(x => x.ResourceId == id)); 433 432 } 434 433 } … … 436 435 public IEnumerable<DT.Slave> GetSlaves(Expression<Func<Slave, bool>> predicate) { 437 436 using (var db = CreateContext()) { 438 return db.Resources.OfType<Slave>().Where(predicate).Select(x => Convert.ToDto(x)).ToArray();437 return db.Resources.OfType<Slave>().Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); 439 438 } 440 439 } … … 442 441 public Guid AddSlave(DT.Slave dto) { 443 442 using (var db = CreateContext()) { 444 var entity = Convert.ToEntity(dto);443 var entity = DT.Convert.ToEntity(dto); 445 444 db.Resources.InsertOnSubmit(entity); 446 445 db.SubmitChanges(); … … 452 451 using (var db = CreateContext()) { 453 452 var entity = db.Resources.OfType<Slave>().FirstOrDefault(x => x.ResourceId == dto.Id); 454 if (entity == null) db.Resources.InsertOnSubmit( Convert.ToEntity(dto));455 else Convert.ToEntity(dto, entity);453 if (entity == null) db.Resources.InsertOnSubmit(DT.Convert.ToEntity(dto)); 454 else DT.Convert.ToEntity(dto, entity); 456 455 db.SubmitChanges(); 457 456 } … … 470 469 public DT.SlaveGroup GetSlaveGroup(Guid id) { 471 470 using (var db = CreateContext()) { 472 return Convert.ToDto(db.Resources.OfType<SlaveGroup>().SingleOrDefault(x => x.ResourceId == id));471 return DT.Convert.ToDto(db.Resources.OfType<SlaveGroup>().SingleOrDefault(x => x.ResourceId == id)); 473 472 } 474 473 } … … 476 475 public IEnumerable<DT.SlaveGroup> GetSlaveGroups(Expression<Func<SlaveGroup, bool>> predicate) { 477 476 using (var db = CreateContext()) { 478 return db.Resources.OfType<SlaveGroup>().Where(predicate).Select(x => Convert.ToDto(x)).ToArray();477 return db.Resources.OfType<SlaveGroup>().Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); 479 478 } 480 479 } … … 484 483 if (dto.Id == Guid.Empty) 485 484 dto.Id = Guid.NewGuid(); 486 var entity = Convert.ToEntity(dto);485 var entity = DT.Convert.ToEntity(dto); 487 486 db.Resources.InsertOnSubmit(entity); 488 487 db.SubmitChanges(); … … 494 493 using (var db = CreateContext()) { 495 494 var entity = db.Resources.OfType<SlaveGroup>().FirstOrDefault(x => x.ResourceId == dto.Id); 496 if (entity == null) db.Resources.InsertOnSubmit( Convert.ToEntity(dto));497 else Convert.ToEntity(dto, entity);495 if (entity == null) db.Resources.InsertOnSubmit(DT.Convert.ToEntity(dto)); 496 else DT.Convert.ToEntity(dto, entity); 498 497 db.SubmitChanges(); 499 498 } … … 517 516 public DT.Resource GetResource(Guid id) { 518 517 using (var db = CreateContext()) { 519 return Convert.ToDto(db.Resources.SingleOrDefault(x => x.ResourceId == id));518 return DT.Convert.ToDto(db.Resources.SingleOrDefault(x => x.ResourceId == id)); 520 519 } 521 520 } … … 523 522 public IEnumerable<DT.Resource> GetResources(Expression<Func<Resource, bool>> predicate) { 524 523 using (var db = CreateContext()) { 525 return db.Resources.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();524 return db.Resources.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); 526 525 } 527 526 } … … 529 528 public Guid AddResource(DT.Resource dto) { 530 529 using (var db = CreateContext()) { 531 var entity = Convert.ToEntity(dto);530 var entity = DT.Convert.ToEntity(dto); 532 531 db.Resources.InsertOnSubmit(entity); 533 532 db.SubmitChanges(); … … 539 538 using (var db = CreateContext()) { 540 539 var entity = db.Resources.FirstOrDefault(x => x.ResourceId == dto.Id); 541 if (entity == null) db.Resources.InsertOnSubmit( Convert.ToEntity(dto));542 else Convert.ToEntity(dto, entity);540 if (entity == null) db.Resources.InsertOnSubmit(DT.Convert.ToEntity(dto)); 541 else DT.Convert.ToEntity(dto, entity); 543 542 db.SubmitChanges(); 544 543 } … … 564 563 using (var db = CreateContext()) { 565 564 var job = db.Jobs.Where(x => x.JobId == jobId).Single(); 566 return job.AssignedResources.Select(x => Convert.ToDto(x.Resource)).ToArray();565 return job.AssignedResources.Select(x => DT.Convert.ToDto(x.Resource)).ToArray(); 567 566 } 568 567 } … … 575 574 var resources = new List<Resource>(); 576 575 CollectParentResources(resources, db.Resources.Where(r => r.ResourceId == resourceId).Single()); 577 return resources.Select(r => Convert.ToDto(r)).ToArray();576 return resources.Select(r => DT.Convert.ToDto(r)).ToArray(); 578 577 } 579 578 } … … 592 591 var childs = new List<DT.Resource>(); 593 592 foreach (var child in db.Resources.Where(x => x.ParentResourceId == resourceId)) { 594 childs.Add( Convert.ToDto(child));593 childs.Add(DT.Convert.ToDto(child)); 595 594 childs.AddRange(GetChildResources(child.ResourceId)); 596 595 } … … 608 607 j.StateLogs.OrderByDescending(x => x.DateTime).First().SlaveId.HasValue && 609 608 resources.Contains(j.StateLogs.OrderByDescending(x => x.DateTime).First().SlaveId.Value)); 610 return jobs.Select(j => Convert.ToDto(j)).ToArray();609 return jobs.Select(j => DT.Convert.ToDto(j)).ToArray(); 611 610 } 612 611 } … … 664 663 public DT.Downtime GetDowntime(Guid id) { 665 664 using (var db = CreateContext()) { 666 return Convert.ToDto(db.Downtimes.SingleOrDefault(x => x.DowntimeId == id));665 return DT.Convert.ToDto(db.Downtimes.SingleOrDefault(x => x.DowntimeId == id)); 667 666 } 668 667 } … … 670 669 public IEnumerable<DT.Downtime> GetDowntimes(Expression<Func<Downtime, bool>> predicate) { 671 670 using (var db = CreateContext()) { 672 return db.Downtimes.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();671 return db.Downtimes.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); 673 672 } 674 673 } … … 676 675 public Guid AddDowntime(DT.Downtime dto) { 677 676 using (var db = CreateContext()) { 678 var entity = Convert.ToEntity(dto);677 var entity = DT.Convert.ToEntity(dto); 679 678 db.Downtimes.InsertOnSubmit(entity); 680 679 db.SubmitChanges(); … … 686 685 using (var db = CreateContext()) { 687 686 var entity = db.Downtimes.FirstOrDefault(x => x.DowntimeId == dto.Id); 688 if (entity == null) db.Downtimes.InsertOnSubmit( Convert.ToEntity(dto));689 else Convert.ToEntity(dto, entity);687 if (entity == null) db.Downtimes.InsertOnSubmit(DT.Convert.ToEntity(dto)); 688 else DT.Convert.ToEntity(dto, entity); 690 689 db.SubmitChanges(); 691 690 } … … 704 703 public DT.Statistics GetStatistic(Guid id) { 705 704 using (var db = CreateContext()) { 706 return Convert.ToDto(db.Statistics.SingleOrDefault(x => x.StatisticsId == id));705 return DT.Convert.ToDto(db.Statistics.SingleOrDefault(x => x.StatisticsId == id)); 707 706 } 708 707 } … … 710 709 public IEnumerable<DT.Statistics> GetStatistics(Expression<Func<Statistics, bool>> predicate) { 711 710 using (var db = CreateContext()) { 712 return db.Statistics.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();711 return db.Statistics.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray(); 713 712 } 714 713 } … … 716 715 public Guid AddStatistics(DT.Statistics dto) { 717 716 using (var db = CreateContext()) { 718 var entity = Convert.ToEntity(dto);717 var entity = DT.Convert.ToEntity(dto); 719 718 db.Statistics.InsertOnSubmit(entity); 720 719 db.SubmitChanges(); 721 720 foreach (var slaveStat in dto.SlaveStatistics) { 722 721 slaveStat.Id = entity.StatisticsId; 723 db.SlaveStatistics.InsertOnSubmit( Convert.ToEntity(slaveStat));722 db.SlaveStatistics.InsertOnSubmit(DT.Convert.ToEntity(slaveStat)); 724 723 } 725 724 foreach (var userStat in dto.UserStatistics) { 726 725 userStat.Id = entity.StatisticsId; 727 db.UserStatistics.InsertOnSubmit( Convert.ToEntity(userStat));726 db.UserStatistics.InsertOnSubmit(DT.Convert.ToEntity(userStat)); 728 727 } 729 728 db.SubmitChanges(); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveService.cs
r6698 r6717 24 24 using System.Linq; 25 25 using System.ServiceModel; 26 using HeuristicLab.Services.Hive.Common; 27 using HeuristicLab.Services.Hive.Common.DataTransfer; 28 using HeuristicLab.Services.Hive.Common.ServiceContracts; 26 using HeuristicLab.Services.Hive.DataTransfer; 27 using HeuristicLab.Services.Hive.ServiceContracts; 28 using DA = HeuristicLab.Services.Hive.DataAccess; 29 using DT = HeuristicLab.Services.Hive.DataTransfer; 30 29 31 30 32 namespace HeuristicLab.Services.Hive { … … 36 38 [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, IgnoreExtensionDataObject = true)] 37 39 public class HiveService : IHiveService { 38 private DataAccess.IHiveDao dao {40 private IHiveDao dao { 39 41 get { return ServiceLocator.Instance.HiveDao; } 40 42 } … … 45 47 get { return ServiceLocator.Instance.AuthorizationManager; } 46 48 } 47 private ITransactionManager trans {49 private DataAccess.ITransactionManager trans { 48 50 get { return ServiceLocator.Instance.TransactionManager; } 49 51 } … … 69 71 } 70 72 dao.AddJobData(jobData); 71 dao.UpdateJobState(job.Id, JobState.Waiting, null, userManager.CurrentUserId, null);73 dao.UpdateJobState(job.Id, DA.JobState.Waiting, null, userManager.CurrentUserId, null); 72 74 return jobData.JobId; 73 75 }, false, true); … … 167 169 author.AuthorizeForJob(jobId, Permission.Full); 168 170 return trans.UseTransaction(() => { 169 Job job = dao.UpdateJobState(jobId, jobState, slaveId, userId, exception);171 Job job = dao.UpdateJobState(jobId, DataTransfer.Convert.ToEntity(jobState), slaveId, userId, exception); 170 172 171 173 if (job.Command.HasValue && job.Command.Value == Command.Pause && job.State == JobState.Paused) { … … 177 179 } else if (jobState == JobState.Paused && !job.Command.HasValue) { 178 180 // slave paused and uploaded the job (no user-command) -> set waiting. 179 job = dao.UpdateJobState(jobId, JobState.Waiting, slaveId, userId, exception);181 job = dao.UpdateJobState(jobId, DataTransfer.Convert.ToEntity(JobState.Waiting), slaveId, userId, exception); 180 182 } 181 183 … … 188 190 authen.AuthenticateForAnyRole(HiveRoles.Administrator); 189 191 var jobs = trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId)); 190 foreach (var job in jobs)192 foreach (var job in jobs) 191 193 author.AuthorizeForJob(job.Id, Permission.Read); 192 194 return jobs; … … 229 231 author.AuthorizeForJob(jobId, Permission.Full); 230 232 trans.UseTransaction(() => { 231 Job job = dao.UpdateJobState(jobId, JobState.Waiting, null, userManager.CurrentUserId, string.Empty);233 Job job = dao.UpdateJobState(jobId, DA.JobState.Waiting, null, userManager.CurrentUserId, string.Empty); 232 234 job.Command = null; 233 235 dao.UpdateJob(job); … … 242 244 var hiveExperiment = dao.GetHiveExperiments(x => 243 245 x.HiveExperimentId == id 244 && (x.OwnerUserId == userManager.CurrentUserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0)246 && (x.OwnerUserId == userManager.CurrentUserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0) 245 247 ).FirstOrDefault(); 246 248 if (hiveExperiment != null) { 247 hiveExperiment.Permission = dao.GetPermissionForExperiment(hiveExperiment.Id, userManager.CurrentUserId);249 hiveExperiment.Permission = DT.Convert.ToDto(dao.GetPermissionForExperiment(hiveExperiment.Id, userManager.CurrentUserId)); 248 250 hiveExperiment.OwnerUsername = userManager.GetUserById(hiveExperiment.OwnerUserId).UserName; 249 251 } … … 253 255 public IEnumerable<HiveExperiment> GetHiveExperiments() { 254 256 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 255 var hiveExperiments = dao.GetHiveExperiments(x => x.OwnerUserId == userManager.CurrentUserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0);257 var hiveExperiments = dao.GetHiveExperiments(x => x.OwnerUserId == userManager.CurrentUserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0); 256 258 foreach (var he in hiveExperiments) { 257 259 author.AuthorizeForExperiment(he.Id, Permission.Read); 258 he.Permission = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);260 he.Permission = DT.Convert.ToDto(dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId)); 259 261 he.OwnerUsername = userManager.GetUserById(he.OwnerUserId).UserName; 260 262 } … … 266 268 var hiveExperiments = dao.GetHiveExperiments(x => true); 267 269 foreach (var he in hiveExperiments) { // no authorization here, since this method is admin-only! (admin is allowed to read all jobs) 268 he.Permission = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);270 he.Permission = DT.Convert.ToDto(dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId)); 269 271 he.OwnerUsername = userManager.GetUserById(he.OwnerUserId).UserName; 270 272 } … … 304 306 HiveExperiment he = dao.GetHiveExperiment(hiveExperimentId); 305 307 if (he == null) throw new FaultException<FaultReason>(new FaultReason("Could not find hiveExperiment with id " + hiveExperimentId)); 306 Permission perm = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);308 Permission perm = DT.Convert.ToDto(dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId)); 307 309 if (perm != Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment")); 308 dao.SetHiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, permission);310 dao.SetHiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, DT.Convert.ToEntity(permission)); 309 311 }); 310 312 } … … 315 317 HiveExperiment he = dao.GetHiveExperiment(hiveExperimentId); 316 318 if (he == null) throw new FaultException<FaultReason>(new FaultReason("Could not find hiveExperiment with id " + hiveExperimentId)); 317 Permission perm = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);318 if (perm != Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment"));319 dao.SetHiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, Permission.NotAllowed);319 DA.Permission perm = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId); 320 if (perm != DA.Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment")); 321 dao.SetHiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, DA.Permission.NotAllowed); 320 322 }); 321 323 } … … 323 325 authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 324 326 return trans.UseTransaction(() => { 325 Permission currentUserPermission = dao.GetPermissionForExperiment(hiveExperimentId, userManager.CurrentUserId);326 if (currentUserPermission != Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to list permissions for this experiment"));327 DA.Permission currentUserPermission = dao.GetPermissionForExperiment(hiveExperimentId, userManager.CurrentUserId); 328 if (currentUserPermission != DA.Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to list permissions for this experiment")); 327 329 return dao.GetHiveExperimentPermissions(x => x.HiveExperimentId == hiveExperimentId); 328 330 }); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IAuthorizationManager.cs
r6463 r6717 21 21 22 22 using System; 23 using HeuristicLab.Services.Hive.Common.DataTransfer; 23 using HeuristicLab.Services.Hive.DataTransfer; 24 24 25 namespace HeuristicLab.Services.Hive { 25 26 public interface IAuthorizationManager { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IHiveDao.cs
r6703 r6717 23 23 using System.Collections.Generic; 24 24 using System.Linq.Expressions; 25 using HeuristicLab.Services.Hive. Common.DataTransfer;26 using DT = HeuristicLab.Services.Hive. Common.DataTransfer;25 using HeuristicLab.Services.Hive.DataAccess; 26 using DT = HeuristicLab.Services.Hive.DataTransfer; 27 27 28 namespace HeuristicLab.Services.Hive .DataAccess{28 namespace HeuristicLab.Services.Hive { 29 29 public interface IHiveDao { 30 30 #region Job Methods -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/AuthorizationManager.cs
r6463 r6717 22 22 using System; 23 23 using System.Security; 24 using HeuristicLab.Services.Hive.Common.DataTransfer; 24 using HeuristicLab.Services.Hive.DataAccess; 25 using DT = HeuristicLab.Services.Hive.DataTransfer; 26 25 27 26 28 namespace HeuristicLab.Services.Hive { … … 31 33 } 32 34 33 public void AuthorizeForJob(Guid jobId, Permission requiredPermission) {35 public void AuthorizeForJob(Guid jobId, DT.Permission requiredPermission) { 34 36 if (ServiceLocator.Instance.AuthenticationManager.IsInRole(HiveRoles.Slave)) return; // slave-users can access all jobs 35 37 36 38 Permission permission = ServiceLocator.Instance.HiveDao.GetPermissionForJob(jobId, ServiceLocator.Instance.UserManager.CurrentUserId); 37 if (permission == Permission.NotAllowed || (permission != requiredPermission && requiredPermission== Permission.Full))39 if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full)) 38 40 throw new SecurityException("Current user is not authorized to access job"); 39 41 } 40 42 41 public void AuthorizeForExperiment(Guid experimentId, Permission requiredPermission) {43 public void AuthorizeForExperiment(Guid experimentId, DT.Permission requiredPermission) { 42 44 Permission permission = ServiceLocator.Instance.HiveDao.GetPermissionForExperiment(experimentId, ServiceLocator.Instance.UserManager.CurrentUserId); 43 if (permission == Permission.NotAllowed || (permission != requiredPermission && requiredPermission == Permission.Full))45 if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full)) 44 46 throw new SecurityException("Current user is not authorized to access experiment"); 45 47 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/EventManager.cs
r6698 r6717 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Services.Hive.Common; 26 using HeuristicLab.Services.Hive.Common.DataTransfer; 25 using HeuristicLab.Services.Hive.DataAccess; 26 using HeuristicLab.Services.Hive.DataAccess; 27 using DT = HeuristicLab.Services.Hive.DataTransfer; 28 27 29 28 30 namespace HeuristicLab.Services.Hive { … … 31 33 /// </summary> 32 34 public class EventManager : IEventManager { 33 private DataAccess.IHiveDao dao {35 private IHiveDao dao { 34 36 get { return ServiceLocator.Instance.HiveDao; } 35 37 } … … 52 54 var slaves = dao.GetSlaves(x => x.SlaveState == SlaveState.Calculating || x.SlaveState == SlaveState.Idle); 53 55 54 var stats = new Statistics();56 var stats = new DataTransfer.Statistics(); 55 57 stats.TimeStamp = DateTime.Now; 56 var slaveStats = new List< SlaveStatistics>();58 var slaveStats = new List<DT.SlaveStatistics>(); 57 59 foreach (var slave in slaves) { 58 slaveStats.Add(new SlaveStatistics() {60 slaveStats.Add(new DT.SlaveStatistics() { 59 61 SlaveId = slave.Id, 60 62 Cores = slave.Cores.HasValue ? slave.Cores.Value : 0, … … 75 77 private void SetTimeoutSlavesOffline() { 76 78 var slaves = dao.GetSlaves(x => x.SlaveState != SlaveState.Offline); 77 foreach ( Slave slave in slaves) {78 if (!slave.LastHeartbeat.HasValue || (DateTime.Now - slave.LastHeartbeat.Value) > Settings.Default.SlaveHeartbeatTimeout) {79 slave.SlaveState = SlaveState.Offline;79 foreach (DT.Slave slave in slaves) { 80 if (!slave.LastHeartbeat.HasValue || (DateTime.Now - slave.LastHeartbeat.Value) > HeuristicLab.Services.Hive.Properties.Settings.Default.SlaveHeartbeatTimeout) { 81 slave.SlaveState = DT.SlaveState.Offline; 80 82 SetJobsWaiting(slave.Id); 81 83 dao.UpdateSlave(slave); … … 97 99 var jobs = dao.GetJobs(x => x.State == JobState.Calculating).Where(x => x.StateLog.Last().SlaveId == slaveId); 98 100 foreach (var j in jobs) { 99 Job job = dao.UpdateJobState(j.Id, JobState.Waiting, slaveId, null, "Slave timed out.");101 DT.Job job = dao.UpdateJobState(j.Id, JobState.Waiting, slaveId, null, "Slave timed out."); 100 102 job.Command = null; 101 103 dao.UpdateJob(job); … … 107 109 /// </summary> 108 110 private void SetTimeoutJobsWaiting() { 109 var jobs = dao.GetJobs(x => (x.State == JobState.Calculating && (DateTime.Now - x.LastHeartbeat) > Settings.Default.CalculatingJobHeartbeatTimeout)110 || (x.State == JobState.Transferring && (DateTime.Now - x.LastHeartbeat) > Settings.Default.TransferringJobHeartbeatTimeout));111 var jobs = dao.GetJobs(x => (x.State == JobState.Calculating && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.CalculatingJobHeartbeatTimeout) 112 || (x.State == JobState.Transferring && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.TransferringJobHeartbeatTimeout)); 111 113 foreach (var j in jobs) { 112 Job job = dao.UpdateJobState(j.Id, JobState.Waiting, null, null, "Slave timed out.");114 DT.Job job = dao.UpdateJobState(j.Id, JobState.Waiting, null, null, "Slave timed out."); 113 115 job.Command = null; 114 116 dao.UpdateJob(job); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs
r6463 r6717 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Services.Hive. Common;26 using HeuristicLab.Services.Hive.Common.DataTransfer;25 using HeuristicLab.Services.Hive.DataTransfer; 26 using DA = HeuristicLab.Services.Hive.DataAccess; 27 27 28 28 namespace HeuristicLab.Services.Hive { 29 29 public class HeartbeatManager { 30 private DataAccess.IHiveDao dao {30 private IHiveDao dao { 31 31 get { return ServiceLocator.Instance.HiveDao; } 32 32 } … … 75 75 if (dao.GetJob(job.Id).State != JobState.Waiting) return false; 76 76 77 job = dao.UpdateJobState(job.Id, JobState.Transferring, slave.Id, null, null);77 job = dao.UpdateJobState(job.Id, DataAccess.JobState.Transferring, slave.Id, null, null); 78 78 79 79 // from now on the job has some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout) … … 102 102 // job does not exist in db 103 103 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, jobProgress.Key)); 104 LogFactory.GetLogger(this.GetType().Namespace).Log("Job does not exist in DB: " + jobProgress.Key);104 DA.LogFactory.GetLogger(this.GetType().Namespace).Log("Job does not exist in DB: " + jobProgress.Key); 105 105 } else { 106 106 if (curJob.CurrentStateLog.SlaveId == Guid.Empty || curJob.CurrentStateLog.SlaveId != heartbeat.SlaveId) { 107 107 // assigned slave does not match heartbeat 108 108 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id)); 109 LogFactory.GetLogger(this.GetType().Namespace).Log("The slave " + heartbeat.SlaveId + " is not supposed to calculate Job: " + curJob);109 DA.LogFactory.GetLogger(this.GetType().Namespace).Log("The slave " + heartbeat.SlaveId + " is not supposed to calculate Job: " + curJob); 110 110 } else if (!JobIsAllowedToBeCalculatedBySlave(heartbeat.SlaveId, curJob)) { 111 111 // assigned resources ids of job do not match with slaveId (and parent resourceGroupIds); this might happen when slave is moved to different group -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/MessageContainer.cs
r6703 r6717 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 27 namespace HeuristicLab.Services.Hive .Common{27 namespace HeuristicLab.Services.Hive { 28 28 /// <summary> 29 29 /// The MessageContainer is a container class for Messages. Its two parts are: -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Properties/Settings.Designer.cs
r6703 r6717 2 2 // <auto-generated> 3 3 // This code was generated by a tool. 4 // Runtime Version:4.0.30319.2 254 // Runtime Version:4.0.30319.235 5 5 // 6 6 // Changes to this file may cause incorrect behavior and will be lost if … … 9 9 //------------------------------------------------------------------------------ 10 10 11 namespace HeuristicLab.Services.Hive. Common{11 namespace HeuristicLab.Services.Hive.Properties { 12 12 13 13 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs
r6703 r6717 24 24 using System.Net.Security; 25 25 using System.ServiceModel; 26 using HeuristicLab.Services.Hive. Common.DataTransfer;27 28 namespace HeuristicLab.Services.Hive. Common.ServiceContracts {26 using HeuristicLab.Services.Hive.DataTransfer; 27 28 namespace HeuristicLab.Services.Hive.ServiceContracts { 29 29 30 30 [ServiceContract(ProtectionLevel = ProtectionLevel.EncryptAndSign)] … … 38 38 Guid AddChildJob(Guid parentJobId, Job job, JobData jobData); 39 39 40 [OperationContract] 40 [OperationContract] 41 41 Job GetJob(Guid jobId); 42 42 43 [OperationContract] 43 [OperationContract] 44 44 IEnumerable<Job> GetJobs(); 45 45 46 [OperationContract] 46 [OperationContract] 47 47 IEnumerable<LightweightJob> GetLightweightJobs(IEnumerable<Guid> jobIds); 48 48 49 [OperationContract] 49 [OperationContract] 50 50 IEnumerable<LightweightJob> GetLightweightChildJobs(Guid? parentJobId, bool recursive, bool includeParent); 51 51 52 [OperationContract] 52 [OperationContract] 53 53 IEnumerable<LightweightJob> GetLightweightExperimentJobs(Guid experimentId); 54 54 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/ServiceFaults/PluginAlreadyExistsFault.cs
r6703 r6717 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab.Services.Hive .Common{25 namespace HeuristicLab.Services.Hive { 26 26 [DataContract] 27 27 public class PluginAlreadyExistsFault {
Note: See TracChangeset
for help on using the changeset viewer.