Changeset 4649 for branches/HeuristicLab.Hive/sources
- Timestamp:
- 10/28/10 14:52:56 (14 years ago)
- Location:
- branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New
- Files:
-
- 5 added
- 6 deleted
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Clients.Hive/3.3/HeuristicLab.Clients.Hive-3.3.csproj
r4629 r4649 76 76 <Compile Include="Exceptions\JobResultPollingException.cs" /> 77 77 <Compile Include="Exceptions\OptimizerNotFoundException.cs" /> 78 <Compile Include="HiveExperiment\HiveExperimentList.cs" />79 <Compile Include="HiveExperiment\HiveJobList.cs" />80 <Compile Include="Jobs\JobList.cs" />81 78 <Compile Include="Jobs\OptimizerJob.cs" /> 82 79 <Compile Include="HeuristicLabClientsHivePlugin.cs" /> 83 80 <Compile Include="HiveExperiment\HiveClient.cs" /> 84 <Compile Include="HiveExperiment\HiveJob .cs" />85 <Compile Include="HiveExperiment\HiveExperiment .cs" />81 <Compile Include="HiveExperiment\HiveJobClient.cs" /> 82 <Compile Include="HiveExperiment\HiveExperimentClient.cs" /> 86 83 <Compile Include="HiveExperiment\JobResultPoller.cs" /> 87 84 <Compile Include="Progress\IProgress.cs" /> -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Clients.Hive/3.3/HiveExperiment/HiveClient.cs
r4629 r4649 38 38 private bool currentlyUpdating; 39 39 40 private ILog log; 41 public ILog Log { 42 get { return log; } 43 } 44 45 private HiveExperimentList hiveExperiments; 46 public HiveExperimentList HiveExperiments { 40 private ItemList<HiveExperimentClient> hiveExperiments; 41 public ItemList<HiveExperimentClient> HiveExperiments { 47 42 get { return hiveExperiments; } 48 43 set { … … 74 69 private void RegisterHiveExperimentsEvent() { 75 70 if (hiveExperiments != null) { 76 hiveExperiments.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<HiveExperiment >>(hiveExperiments_ItemsRemoved);71 hiveExperiments.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<HiveExperimentClient>>(hiveExperiments_ItemsRemoved); 77 72 } 78 73 } … … 80 75 private void DeRegisterHiveExperimentsEvents() { 81 76 if (hiveExperiments != null) { 82 hiveExperiments.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<HiveExperiment >>(hiveExperiments_ItemsRemoved);77 hiveExperiments.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<HiveExperimentClient>>(hiveExperiments_ItemsRemoved); 83 78 } 84 79 } 85 80 86 81 public HiveClient() { 87 this.log = new Log();82 88 83 } 89 84 90 85 public override IDeepCloneable Clone(Cloner cloner) { 91 86 HiveClient clone = (HiveClient)base.Clone(cloner); 92 clone.log = (ILog)cloner.Clone(this.log); 93 clone.hiveExperiments = (HiveExperimentList)cloner.Clone(this.hiveExperiments); 87 clone.hiveExperiments = (ItemList<HiveExperimentClient>)cloner.Clone(this.hiveExperiments); 94 88 return clone; 95 89 } … … 100 94 IsProgressing = true; 101 95 if (this.HiveExperiments == null) { 102 this.HiveExperiments = new HiveExperimentList();96 this.HiveExperiments = new ItemList<HiveExperimentClient>(); 103 97 } 104 98 using (var service = ServiceLocator.Instance.ServicePool.GetService()) { … … 121 115 private void RefreshExperimentList(IEnumerable<DT.HiveExperiment> hiveExperiments) { 122 116 foreach (DT.HiveExperiment hiveExperimentDto in hiveExperiments) { 123 DT.HiveExperiment hiveExperiment = GetHiveExperiment(hiveExperimentDto.Id);117 HiveExperimentClient hiveExperiment = GetHiveExperiment(hiveExperimentDto.Id); 124 118 if (hiveExperiment == null) { 125 119 // not yet there, create new 126 this.HiveExperiments.Add(new HiveExperiment (hiveExperimentDto));120 this.HiveExperiments.Add(new HiveExperimentClient(hiveExperimentDto)); 127 121 } else { 128 122 // update … … 132 126 } 133 127 134 private DT.HiveExperiment GetHiveExperiment(Guid hiveExperimentId) { 135 return this.HiveExperiments.SingleOrDefault(he => he.Id.Equals(hiveExperimentId)); 136 } 137 138 private void LogMessage(string message) { 139 // HeuristicLab.Log is not Thread-Safe, so lock on every call 140 lock (locker) { 141 log.LogMessage(message); 142 } 128 private HiveExperimentClient GetHiveExperiment(Guid hiveExperimentId) { 129 return this.HiveExperiments.SingleOrDefault(he => he.HiveExperimentId.Equals(hiveExperimentId)); 143 130 } 144 131 … … 149 136 } 150 137 151 void hiveExperiments_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<HiveExperiment >> e) {138 void hiveExperiments_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<HiveExperimentClient>> e) { 152 139 if (!currentlyUpdating) { 153 140 using (Disposable<IHiveService> service = ServiceLocator.Instance.ServicePool.GetService()) { 154 foreach (IndexedItem<HiveExperiment > item in e.Items) {141 foreach (IndexedItem<HiveExperimentClient> item in e.Items) { 155 142 if (item.Value.HiveExperimentId != Guid.Empty) { 156 143 service.Obj.DeleteHiveExperiment(item.Value.HiveExperimentId); -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Clients.Hive/3.3/ServiceClients/GenerateServiceClients.cmd
r4629 r4649 7 7 8 8 svcutil.exe ^ 9 http://localhost:900 1/HiveService/mex ^9 http://localhost:9000/HiveService/mex ^ 10 10 /out:HiveServiceClient ^ 11 11 /namespace:*,HeuristicLab.Clients.Hive ^ 12 12 /targetClientVersion:Version35 ^ 13 13 /enableDataBinding ^ 14 /config:..\app.config ^ 15 /reference:..\..\..\HeuristicLab.Services.Hive.Common\3.3\bin\debug\HeuristicLab.Services.Hive.Common-3.3.dll 14 /config:..\app.config 16 15 17 16 echo. -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Clients.Hive/3.3/ServiceClients/ServiceClientFactory.cs
r4629 r4649 105 105 106 106 private void RegisterServiceEvents() { 107 disposableService. OnDisposing += new EventHandler(disposableService_OnDisposing);107 disposableService.Disposing += disposableService_Disposing; 108 108 ((ICommunicationObject)disposableService.Obj).Faulted += new EventHandler(WcfServicePool_Faulted); 109 109 } 110 110 111 111 private void DeregisterServiceEvents() { 112 disposableService. OnDisposing -= new EventHandler(disposableService_OnDisposing);112 disposableService.Disposing -= disposableService_Disposing; 113 113 ((ICommunicationObject)disposableService.Obj).Faulted -= new EventHandler(WcfServicePool_Faulted); 114 114 } … … 122 122 } 123 123 124 private void disposableService_ OnDisposing(object sender, EventArgse) {124 private void disposableService_Disposing(object sender, EventArgs<T> e) { 125 125 DisposeService(); 126 126 } -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Clients.Hive/3.3/app.config
r4629 r4649 3 3 <system.serviceModel> 4 4 <bindings> 5 < netTcpBinding>6 <binding name=" TcpEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00"7 receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"8 trans ferMode="Streamed" transactionProtocol="OleTransactions"9 hostNameComparisonMode="StrongWildcard" listenBacklog="10"10 m axBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"11 maxReceivedMessageSize="65536">5 <wsHttpBinding> 6 <binding name="HttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00" 7 receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" 8 transactionFlow="false" hostNameComparisonMode="StrongWildcard" 9 maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 10 messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 11 allowCookies="false"> 12 12 <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 13 13 maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 14 14 <reliableSession ordered="true" inactivityTimeout="00:10:00" 15 15 enabled="false" /> 16 <security mode="TransportWithMessageCredential"> 17 <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 18 <message clientCredentialType="UserName" algorithmSuite="Default" /> 16 <security mode="Message"> 17 <transport clientCredentialType="Windows" proxyCredentialType="None" 18 realm="" /> 19 <message clientCredentialType="Windows" negotiateServiceCredential="true" 20 algorithmSuite="Default" /> 19 21 </security> 20 22 </binding> 21 </ netTcpBinding>23 </wsHttpBinding> 22 24 </bindings> 23 25 <client> 24 <endpoint address=" net.tcp://localhost:9000/HiveService" binding="netTcpBinding"25 bindingConfiguration=" TcpEndpoint" contract="HeuristicLab.Services.Hive.Common.ServiceContracts.IHiveService"26 name=" TcpEndpoint">26 <endpoint address="http://localhost:9000/HiveService" binding="wsHttpBinding" 27 bindingConfiguration="HttpBinding" contract="HeuristicLab.Clients.Hive.IHiveService" 28 name="HttpBinding"> 27 29 <identity> 28 < dns value="localhost" />30 <userPrincipalName value="S0920454044@hagenberg.fhooe.at" /> 29 31 </identity> 30 32 </endpoint> -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.Common/3.3/DataTransfer/HiveExperiment.cs
r4629 r4649 30 30 public class HiveExperiment : NamedHiveItem { 31 31 [DataMember] 32 public string ResourceIds { get; set; }33 [DataMember]34 32 public Guid UserId { get; set; } 35 33 [DataMember] … … 37 35 38 36 public override string ToString() { 39 return base.ToString() + "Name: " + Name + ", Description: " + Description + ", ResourceIds: " + ResourceIds;37 return base.ToString() + "Name: " + Name + ", Description: " + Description; 40 38 } 41 39 42 40 public override IDeepCloneable Clone(Cloner cloner) { 43 41 var clone = (HiveExperiment)base.Clone(cloner); 44 clone.ResourceIds = this.ResourceIds;45 42 clone.RootJobId = this.RootJobId; 46 43 clone.UserId = this.UserId; -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.Common/3.3/DataTransfer/HiveItem.cs
r4629 r4649 8 8 namespace HeuristicLab.Services.Hive.Common.DataTransfer { 9 9 [DataContract] 10 public abstract class HiveItem : IDeepCloneable { 10 [Serializable] 11 public abstract class HiveItem : HiveItemBase { 11 12 [DataMember] 12 13 public Guid Id { get; set; } 13 14 14 15 public virtual IDeepCloneable Clone(Cloner cloner) { 15 HiveItem clone = (HiveItem)Activator.CreateInstance(this.GetType(), true); 16 cloner.RegisterClonedObject(this, clone); 16 HiveItem clone = (HiveItem)base.Clone(cloner); 17 17 clone.Id = this.Id; 18 18 return clone; 19 19 } 20 21 public object Clone() {22 return Clone(new Cloner());23 }24 20 } 25 21 } -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.Common/3.3/DataTransfer/Job.cs
r4629 r4649 27 27 28 28 namespace HeuristicLab.Services.Hive.Common.DataTransfer { 29 30 29 [DataContract] 31 30 [Serializable] … … 40 39 public int MemoryNeeded { get; set; } 41 40 [DataMember] 42 public List<Guid> PluginsNeededIds { get; set; } 43 [DataMember] 44 public List<Guid> AssignedResourceIds { get; set; } 45 [DataMember] 46 public Guid ProjectId { get; set; } 41 public Guid? ProjectId { get; set; } 47 42 48 43 public override string ToString() { 49 return base.ToString() + "State: " + State + ", [SlaveId : " + SlaveId + " ] , DateCreated: " + DateCreated + ", DateCalculated: " + DateCalculated +50 "Priority: " + Priority + ", CoresNeeded: " + CoresNeeded + "AssignedResources: " + AssignedResourceIds;44 return base.ToString() + "State: " + JobState + ", [SlaveId : " + SlaveId + " ] , DateCreated: " + DateCreated + ", DateCalculated: " + DateCalculated + 45 "Priority: " + Priority + ", CoresNeeded: " + CoresNeeded; 51 46 } 52 47 53 48 public Job() { 54 PluginsNeededIds = new List<Guid>();55 AssignedResourceIds = new List<Guid>();56 49 } 57 50 … … 62 55 clone.CoresNeeded = this.CoresNeeded; 63 56 clone.MemoryNeeded = this.MemoryNeeded; 64 clone.PluginsNeededIds = new List<Guid>(this.PluginsNeededIds);65 clone.AssignedResourceIds = new List<Guid>(this.AssignedResourceIds);66 57 clone.ProjectId = this.ProjectId; 67 58 return clone; -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.Common/3.3/DataTransfer/JobData.cs
r4629 r4649 28 28 [DataContract] 29 29 [Serializable] 30 public class JobData : HiveItem {30 public class JobData : HiveItemBase { 31 31 [DataMember] 32 32 public Guid JobId { get; set; } -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.Common/3.3/DataTransfer/JobState.cs
r4615 r4649 23 23 namespace HeuristicLab.Services.Hive.Common.DataTransfer { 24 24 public enum JobState { 25 /// <summary>26 /// Job is actively calculated on a Slave25 /// <summary> 26 /// A job is offline as long as he is not yet submitted to the hive 27 27 /// </summary> 28 Calculating,28 Offline, 29 29 30 30 /// <summary> … … 33 33 Waiting, 34 34 35 /// <summary> 36 /// The job is paused and waits on the server to be sent back to a Slave when all of its child jobs are Finished. 37 /// </summary> 38 WaitingForChildJobs, 39 40 /// <summary> 41 /// Job is actively calculated on a Slave 42 /// </summary> 43 Calculating, 44 35 45 /// <summary> 36 46 /// Job as finished and is ready to be collected by the Client … … 46 56 /// Job as been aborted due to an error. Results are ready to be collected 47 57 /// </summary> 48 Failed, 49 50 /// <summary> 51 /// The job is paused and waits on the server to be sent back to a Slave when all of its child jobs are Finished. 52 /// </summary> 53 WaitForChildJobs 58 Failed 54 59 }; 55 60 … … 67 72 public static bool IsWaiting(this JobState jobState) { 68 73 return jobState == JobState.Waiting || 69 jobState == JobState.Wait ForChildJobs;74 jobState == JobState.WaitingForChildJobs; 70 75 } 71 76 -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.Common/3.3/DataTransfer/LightweightJob.cs
r4629 r4649 29 29 public class LightweightJob : HiveItem { 30 30 [DataMember] 31 public Guid SlaveId { get; set; }31 public Guid? SlaveId { get; set; } 32 32 [DataMember] 33 public JobState State { get; set; }33 public JobState JobState { get; set; } 34 34 [DataMember] 35 public TimeSpan ExecutionTime { get; set; }35 public TimeSpan? ExecutionTime { get; set; } 36 36 [DataMember] 37 37 public String Exception { get; set; } … … 45 45 public Guid? ParentJobId { get; set; } 46 46 47 public LightweightJob() { } 47 public LightweightJob() { 48 JobState = DataTransfer.JobState.Offline; 49 } 48 50 49 51 public LightweightJob(Job job) { 50 52 this.SlaveId = job.SlaveId; 51 this. State = job.State;53 this.JobState = job.JobState; 52 54 this.ExecutionTime = job.ExecutionTime; 53 55 this.Exception = job.Exception; … … 61 63 var clone = (LightweightJob)base.Clone(cloner); 62 64 clone.SlaveId = this.SlaveId; 63 clone. State = this.State;65 clone.JobState = this.JobState; 64 66 clone.ExecutionTime = this.ExecutionTime; 65 67 clone.Exception = this.Exception; -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.Common/3.3/DataTransfer/Slave.cs
r4629 r4649 33 33 public int? FreeCores { get; set; } 34 34 [DataMember] 35 public int? CpuSpeed PerCore{ get; set; }35 public int? CpuSpeed { get; set; } 36 36 [DataMember] 37 37 public int? Memory { get; set; } … … 39 39 public int? FreeMemory { get; set; } 40 40 [DataMember] 41 public SlaveState S tate { get; set; }41 public SlaveState SlaveState { get; set; } 42 42 [DataMember] 43 public CalendarState CalendarSyncStat us{ get; set; }43 public CalendarState CalendarSyncState { get; set; } 44 44 [DataMember] 45 public Guid SlaveConfigId { get; set; }45 public Guid? SlaveConfigId { get; set; } 46 46 [DataMember] 47 47 public bool IsAllowedToCalculate { get; set; } 48 48 49 public Slave() { 50 SlaveState = DataTransfer.SlaveState.Idle; 51 } 52 49 53 public override string ToString() { 50 return base.ToString() + ", NrOfCores: " + Cores + ", NrOfFreeCores " + FreeCores + ", State: " + S tate;54 return base.ToString() + ", NrOfCores: " + Cores + ", NrOfFreeCores " + FreeCores + ", State: " + SlaveState; 51 55 } 52 56 … … 55 59 clone.Cores = this.Cores; 56 60 clone.FreeCores = this.FreeCores; 57 clone.CpuSpeed PerCore = this.CpuSpeedPerCore;61 clone.CpuSpeed = this.CpuSpeed; 58 62 clone.Memory = this.Memory; 59 63 clone.FreeMemory = this.FreeMemory; 60 clone.S tate = this.State;61 clone.CalendarSyncStat us = this.CalendarSyncStatus;64 clone.SlaveState = this.SlaveState; 65 clone.CalendarSyncState = this.CalendarSyncState; 62 66 clone.SlaveConfigId = this.SlaveConfigId; 63 67 clone.IsAllowedToCalculate = this.IsAllowedToCalculate; -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.Common/3.3/DataTransfer/SlaveGroup.cs
r4629 r4649 30 30 public class SlaveGroup : Resource { 31 31 [DataMember] 32 public List<Guid> ResourcesIds { get; set; } 32 public List<Guid> ChildResourcesIds { get; set; } 33 [DataMember] 34 public List<Guid> ParentResourcesIds { get; set; } 33 35 34 36 public SlaveGroup() { 35 ResourcesIds = new List<Guid>();37 ChildResourcesIds = new List<Guid>(); 36 38 } 37 39 38 40 public override IDeepCloneable Clone(Cloner cloner) { 39 41 var clone = (SlaveGroup)base.Clone(cloner); 40 clone.ResourcesIds = new List<Guid>(this.ResourcesIds); 42 clone.ChildResourcesIds = new List<Guid>(this.ChildResourcesIds); 43 clone.ParentResourcesIds = new List<Guid>(this.ParentResourcesIds); 41 44 return clone; 42 45 } -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.Common/3.3/Disposable.cs
r4598 r4649 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 24 24 25 namespace HeuristicLab.Services.Hive.Common { … … 34 35 35 36 public void Dispose() { 36 if ( OnDisposing != null)37 OnDisposing(this, new EventArgs());37 if (Disposing != null) 38 Disposing(this, new EventArgs<T>(obj)); 38 39 } 39 40 40 public event EventHandler OnDisposing;41 public event EventHandler<EventArgs<T>> Disposing; 41 42 } 42 43 } -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.Common/3.3/HeuristicLab.Services.Hive.Common-3.3.csproj
r4629 r4649 67 67 <Compile Include="DataTransfer\HiveExperiment.cs" /> 68 68 <Compile Include="DataTransfer\HiveItem.cs" /> 69 <Compile Include="DataTransfer\HiveItemBase.cs" /> 69 70 <Compile Include="DataTransfer\HivePluginData.cs" /> 70 71 <Compile Include="DataTransfer\HivePlugin.cs" /> -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.Common/3.3/ServiceContracts/IHiveService.cs
r4629 r4649 156 156 #region Slave Methods 157 157 [OperationContract] 158 Guid AddSlave(Slave slave); 159 160 [OperationContract] 158 161 Guid AddSlaveGroup(SlaveGroup slaveGroup); 159 162 -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/Convert.cs
r4598 r4649 24 24 using System.Linq; 25 25 using DT = HeuristicLab.Services.Hive.Common.DataTransfer; 26 using System; 26 27 27 28 namespace HeuristicLab.Services.Hive.DataAccess { 28 29 public static class Convert { 29 30 31 30 #region Job 32 31 public static DT.Job ToDto(Job source) { 33 32 if (source == null) return null; 34 return new DT.Job { Id = source.JobId };// todo 33 return new DT.Job { 34 Id = source.JobId, 35 CoresNeeded = source.CoresNeeded, 36 DateCalculated = source.DateCalculated, 37 DateCreated = source.DateCreated, 38 DateFinished = source.DateFinished, 39 Exception = source.Exception, 40 ExecutionTime = source.ExecutionTime, 41 MemoryNeeded = source.MemoryNeeded, 42 ParentJobId = source.ParentJobId, 43 Priority = source.Priority, 44 ProjectId = source.ProjectId, 45 SlaveId = source.SlaveId, 46 JobState = source.JobState, 47 UserId = source.UserId 48 }; 35 49 } 36 50 public static Job ToEntity(DT.Job source) { 37 51 if (source == null) return null; 38 return new Job { JobId = source.Id };// todo 52 var entity = new Job(); ToEntity(source, entity); 53 return entity; 39 54 } 40 55 public static void ToEntity(DT.Job source, Job target) { 41 56 if ((source != null) && (target != null)) { 42 target.JobId = source.Id;// todo 57 target.JobId = source.Id; 58 target.CoresNeeded = source.CoresNeeded; 59 target.DateCalculated = source.DateCalculated; 60 target.DateCreated = source.DateCreated; 61 target.DateFinished = source.DateFinished; 62 target.Exception = source.Exception; 63 target.ExecutionTime = source.ExecutionTime; 64 target.MemoryNeeded = source.MemoryNeeded; 65 target.ParentJobId = source.ParentJobId; 66 target.Priority = source.Priority; 67 target.ProjectId = source.ProjectId; 68 target.SlaveId = source.SlaveId; 69 target.JobState = source.JobState; 70 target.UserId = source.UserId; 43 71 } 44 72 } … … 48 76 public static DT.JobData ToDto(JobData source) { 49 77 if (source == null) return null; 50 return new DT.JobData { JobId = source.JobId };// todo78 return new DT.JobData { JobId = source.JobId, Data = source.Data.ToArray() }; 51 79 } 52 80 public static JobData ToEntity(DT.JobData source) { 53 81 if (source == null) return null; 54 return new JobData { JobId = source.Id };// todo 82 var entity = new JobData(); ToEntity(source, entity); 83 return entity; 55 84 } 56 85 public static void ToEntity(DT.JobData source, JobData target) { 57 86 if ((source != null) && (target != null)) { 58 target.JobId = source. Id;// todo87 target.JobId = source.JobId; target.Data = new Binary(source.Data); 59 88 } 60 89 } 61 90 #endregion 62 91 63 92 #region HiveExperiment 64 93 public static DT.HiveExperiment ToDto(HiveExperiment source) { 65 94 if (source == null) return null; 66 return new DT.HiveExperiment { Id = source.HiveExperimentId };// todo95 return new DT.HiveExperiment { Id = source.HiveExperimentId, Description = source.Description, Name = source.Name, RootJobId = source.RootJobId, UserId = source.UserId }; 67 96 } 68 97 public static HiveExperiment ToEntity(DT.HiveExperiment source) { 69 98 if (source == null) return null; 70 return new HiveExperiment { HiveExperimentId = source.Id };// todo 99 var entity = new HiveExperiment(); ToEntity(source, entity); 100 return entity; 71 101 } 72 102 public static void ToEntity(DT.HiveExperiment source, HiveExperiment target) { 73 103 if ((source != null) && (target != null)) { 74 target.HiveExperimentId = source.Id; // todo104 target.HiveExperimentId = source.Id; target.Description = source.Description; target.Name = source.Name; target.RootJobId = source.RootJobId; target.UserId = source.UserId; 75 105 } 76 106 } … … 80 110 public static DT.Slave ToDto(Slave source) { 81 111 if (source == null) return null; 82 return new DT.Slave { Id = source.ResourceId };// todo112 return new DT.Slave { Id = source.ResourceId, CalendarSyncState = source.CalendarSyncState, Cores = source.Cores, CpuSpeed = source.CpuSpeed, FreeCores = source.FreeCores, FreeMemory = source.FreeMemory, IsAllowedToCalculate = source.IsAllowedToCalculate, Memory = source.Memory, Name = source.Name, SlaveConfigId = source.SlaveConfigId, SlaveState = source.SlaveState }; 83 113 } 84 114 public static Slave ToEntity(DT.Slave source) { 85 115 if (source == null) return null; 86 return new Slave { ResourceId = source.Id };// todo 116 var entity = new Slave(); ToEntity(source, entity); 117 return entity; 87 118 } 88 119 public static void ToEntity(DT.Slave source, Slave target) { 89 120 if ((source != null) && (target != null)) { 90 target.ResourceId = source.Id; // todo121 target.ResourceId = source.Id; target.CalendarSyncState = source.CalendarSyncState; target.Cores = source.Cores; target.CpuSpeed = source.CpuSpeed; target.FreeCores = source.FreeCores; target.FreeMemory = source.FreeMemory; target.IsAllowedToCalculate = source.IsAllowedToCalculate; target.Memory = source.Memory; target.Name = source.Name; target.SlaveConfigId = source.SlaveConfigId; target.SlaveState = source.SlaveState; 91 122 } 92 123 } … … 96 127 public static DT.SlaveGroup ToDto(SlaveGroup source) { 97 128 if (source == null) return null; 98 return new DT.SlaveGroup { Id = source.ResourceId };// todo129 return new DT.SlaveGroup { Id = source.ResourceId, Name = source.Name, ChildResourcesIds = source.SlaveGroup_Resources_Children.Select(x => x.ResourceId).ToList(), ParentResourcesIds = source.SlaveGroup_Resources_Parents.Select(x => x.ResourceId).ToList() }; 99 130 } 100 131 public static SlaveGroup ToEntity(DT.SlaveGroup source) { 101 132 if (source == null) return null; 102 return new SlaveGroup { ResourceId = source.Id };// todo 133 var entity = new SlaveGroup(); ToEntity(source, entity); 134 return entity; 103 135 } 104 136 public static void ToEntity(DT.SlaveGroup source, SlaveGroup target) { 105 137 if ((source != null) && (target != null)) { 106 target.ResourceId = source.Id;// todo 138 target.ResourceId = source.Id; 139 target.Name = source.Name; 140 //target.SlaveGroup_Resources_Children = // TODO: see how working with groups will work, then decide how to handle enumerations in here 141 //target.SlaveGroup_Resources_Parents = 107 142 } 108 143 } … … 112 147 public static DT.Resource ToDto(Resource source) { 113 148 if (source == null) return null; 114 return new DT.Resource { Id = source.ResourceId };// todo149 return new DT.Resource { Id = source.ResourceId, Name = source.Name }; 115 150 } 116 151 public static Resource ToEntity(DT.Resource source) { 117 152 if (source == null) return null; 118 return new Resource { ResourceId = source.Id };// todo 153 var entity = new Resource(); ToEntity(source, entity); 154 return entity; 119 155 } 120 156 public static void ToEntity(DT.Resource source, Resource target) { 121 157 if ((source != null) && (target != null)) { 122 target.ResourceId = source.Id; // todo158 target.ResourceId = source.Id; target.Name = source.Name; 123 159 } 124 160 } -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/HeuristicLab.Services.Hive.DataAccess-3.3.csproj
r4629 r4649 61 61 </ItemGroup> 62 62 <ItemGroup> 63 <Compile Include="ContextFactory.cs" />64 63 <Compile Include="Convert.cs" /> 65 64 <Compile Include="HeuristicLabServicesHiveDataAccessPlugin.cs" /> … … 82 81 </Compile> 83 82 <Compile Include="Tools\CreateHiveDatabaseApplication.cs" /> 83 <Compile Include="TransactionManager.cs" /> 84 84 </ItemGroup> 85 85 <ItemGroup> -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDao.cs
r4629 r4649 8 8 using DT = HeuristicLab.Services.Hive.Common.DataTransfer; 9 9 using HeuristicLab.Services.Hive.Common.DataTransfer; 10 using HeuristicLab.Services.Hive.DataAccess.Properties; 10 11 11 12 public class HiveDao : IHiveDao { 12 p rivate IContextFactory<HiveDataContext> contextFactory;13 private DataAccess.HiveDataContext db { get { return contextFactory.CurrentContext; } }14 15 public HiveDao(IContextFactory<HiveDataContext> contextFactory) { 16 this.contextFactory = contextFactory;13 public HiveDataContext CreateContext() { 14 return new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString); 15 } 16 17 public HiveDao() { 17 18 } 18 19 19 20 #region Job Methods 20 21 public DT.Job GetJob(Guid id) { 21 return Convert.ToDto(db.Jobs.SingleOrDefault(x => x.JobId == id)); 22 using (var db = CreateContext()) { 23 return Convert.ToDto(db.Jobs.SingleOrDefault(x => x.JobId == id)); 24 } 22 25 } 23 26 24 27 public IEnumerable<DT.Job> GetJobs(Expression<Func<Job, bool>> predicate) { 25 return db.Jobs.Where(predicate).Select(x => Convert.ToDto(x)); 28 using (var db = CreateContext()) { 29 return db.Jobs.Where(predicate).Select(x => Convert.ToDto(x)).ToArray(); 30 } 26 31 } 27 32 28 33 public Guid AddJob(DT.Job dto) { 29 var entity = Convert.ToEntity(dto); 30 db.Jobs.InsertOnSubmit(entity); 31 db.SubmitChanges(); 32 return entity.JobId; 34 using (var db = CreateContext()) { 35 var entity = Convert.ToEntity(dto); 36 db.Jobs.InsertOnSubmit(entity); 37 db.SubmitChanges(); 38 return entity.JobId; 39 } 33 40 } 34 41 35 42 public void UpdateJob(DT.Job dto) { 36 var entity = db.Jobs.FirstOrDefault(x => x.JobId == dto.Id); 37 if (entity == null) db.Jobs.InsertOnSubmit(Convert.ToEntity(dto)); 38 else Convert.ToEntity(dto, entity); 39 db.SubmitChanges(); 43 using (var db = CreateContext()) { 44 var entity = db.Jobs.FirstOrDefault(x => x.JobId == dto.Id); 45 if (entity == null) db.Jobs.InsertOnSubmit(Convert.ToEntity(dto)); 46 else Convert.ToEntity(dto, entity); 47 db.SubmitChanges(); 48 } 40 49 } 41 50 42 51 public void DeleteJob(Guid id) { 43 var entity = db.Jobs.FirstOrDefault(x => x.JobId == id); 44 if (entity != null) db.Jobs.DeleteOnSubmit(entity); 45 db.SubmitChanges(); 52 using (var db = CreateContext()) { 53 var entity = db.Jobs.FirstOrDefault(x => x.JobId == id); 54 if (entity != null) db.Jobs.DeleteOnSubmit(entity); 55 db.SubmitChanges(); 56 } 46 57 } 47 58 48 59 public IEnumerable<DT.Job> GetAvailableParentJobs(Guid slaveId) { 49 // todo: slaveId is unused! 50 var query = from ar in db.AssignedResources 51 where ar.Job.JobState == JobState.WaitForChildJobs && 52 (from child in db.Jobs 53 where child.ParentJobId == ar.Job.JobId 54 select child.JobState == JobState.Finished).All(x => x) && 55 (from child in db.Jobs // avoid returning WaitForChildJobs jobs where no child-jobs exist (yet) 56 where child.ParentJobId == ar.Job.JobId 57 select child).Count() > 0 58 orderby ar.Job.Priority descending 59 select Convert.ToDto(ar.Job); 60 return query; 60 using (var db = CreateContext()) { 61 // todo: slaveId is unused! 62 var query = from ar in db.AssignedResources 63 where ar.Job.JobState == JobState.WaitingForChildJobs && 64 (from child in db.Jobs 65 where child.ParentJobId == ar.Job.JobId 66 select child.JobState == JobState.Finished).All(x => x) && 67 (from child in db.Jobs // avoid returning WaitForChildJobs jobs where no child-jobs exist (yet) 68 where child.ParentJobId == ar.Job.JobId 69 select child).Count() > 0 70 orderby ar.Job.Priority descending 71 select Convert.ToDto(ar.Job); 72 return query; 73 } 61 74 } 62 75 63 76 public IEnumerable<DT.Job> GetAvailableJobs(DT.Slave slave) { 64 var query = from j in db.Jobs 65 where j.JobState == JobState.Waiting && j.CoresNeeded <= slave.FreeCores && j.MemoryNeeded <= slave.FreeMemory 66 orderby j.Priority descending 67 select Convert.ToDto(j); 68 return query.Union(GetAvailableParentJobs(slave.Id)).OrderByDescending(x => x.Priority).ToArray(); 77 using (var db = CreateContext()) { 78 var query = from j in db.Jobs 79 where j.JobState == JobState.Waiting && j.CoresNeeded <= slave.FreeCores && j.MemoryNeeded <= slave.FreeMemory 80 orderby j.Priority descending 81 select Convert.ToDto(j); 82 return query.Union(GetAvailableParentJobs(slave.Id)).OrderByDescending(x => x.Priority).ToArray(); 83 } 69 84 } 70 85 #endregion … … 73 88 74 89 public DT.JobData GetJobData(Guid id) { 75 return Convert.ToDto(db.JobDatas.SingleOrDefault(x => x.JobId == id)); 90 using (var db = CreateContext()) { 91 return Convert.ToDto(db.JobDatas.SingleOrDefault(x => x.JobId == id)); 92 } 76 93 } 77 94 78 95 public IEnumerable<DT.JobData> GetJobDatas(Expression<Func<JobData, bool>> predicate) { 79 return db.JobDatas.Where(predicate).Select(x => Convert.ToDto(x)); 96 using (var db = CreateContext()) { 97 return db.JobDatas.Where(predicate).Select(x => Convert.ToDto(x)).ToArray(); 98 } 80 99 } 81 100 82 101 public Guid AddJobData(DT.JobData dto) { 83 var entity = Convert.ToEntity(dto); 84 db.JobDatas.InsertOnSubmit(entity); 85 db.SubmitChanges(); 86 return entity.JobId; 102 using (var db = CreateContext()) { 103 var entity = Convert.ToEntity(dto); 104 db.JobDatas.InsertOnSubmit(entity); 105 db.SubmitChanges(); 106 return entity.JobId; 107 } 87 108 } 88 109 89 110 public void UpdateJobData(DT.JobData dto) { 90 var entity = db.JobDatas.FirstOrDefault(x => x.JobId == dto.Id); 91 if (entity == null) db.JobDatas.InsertOnSubmit(Convert.ToEntity(dto)); 92 else Convert.ToEntity(dto, entity); 93 db.SubmitChanges(); 111 using (var db = CreateContext()) { 112 var entity = db.JobDatas.FirstOrDefault(x => x.JobId == dto.JobId); 113 if (entity == null) db.JobDatas.InsertOnSubmit(Convert.ToEntity(dto)); 114 else Convert.ToEntity(dto, entity); 115 db.SubmitChanges(); 116 } 94 117 } 95 118 96 119 public void DeleteJobData(Guid id) { 97 var entity = db.JobDatas.FirstOrDefault(x => x.JobId == id); // check if all the byte[] is loaded into memory here. otherwise work around to delete without loading it 98 if (entity != null) db.JobDatas.DeleteOnSubmit(entity); 99 db.SubmitChanges(); 120 using (var db = CreateContext()) { 121 var entity = db.JobDatas.FirstOrDefault(x => x.JobId == id); // check if all the byte[] is loaded into memory here. otherwise work around to delete without loading it 122 if (entity != null) db.JobDatas.DeleteOnSubmit(entity); 123 db.SubmitChanges(); 124 } 100 125 } 101 126 #endregion … … 103 128 #region HiveExperiment Methods 104 129 public DT.HiveExperiment GetHiveExperiment(Guid id) { 105 return Convert.ToDto(db.HiveExperiments.SingleOrDefault(x => x.HiveExperimentId == id)); 130 using (var db = CreateContext()) { 131 return Convert.ToDto(db.HiveExperiments.SingleOrDefault(x => x.HiveExperimentId == id)); 132 } 106 133 } 107 134 108 135 public IEnumerable<DT.HiveExperiment> GetHiveExperiments(Expression<Func<HiveExperiment, bool>> predicate) { 109 return db.HiveExperiments.Where(predicate).Select(x => Convert.ToDto(x)); 136 using (var db = CreateContext()) { 137 return db.HiveExperiments.Where(predicate).Select(x => Convert.ToDto(x)).ToArray(); 138 } 110 139 } 111 140 112 141 public Guid AddHiveExperiment(DT.HiveExperiment dto) { 113 var entity = Convert.ToEntity(dto); 114 db.HiveExperiments.InsertOnSubmit(entity); 115 db.SubmitChanges(); 116 return entity.HiveExperimentId; 142 using (var db = CreateContext()) { 143 var entity = Convert.ToEntity(dto); 144 db.HiveExperiments.InsertOnSubmit(entity); 145 db.SubmitChanges(); 146 return entity.HiveExperimentId; 147 } 117 148 } 118 149 119 150 public void UpdateHiveExperiment(DT.HiveExperiment dto) { 120 var entity = db.HiveExperiments.FirstOrDefault(x => x.HiveExperimentId == dto.Id); 121 if (entity == null) db.HiveExperiments.InsertOnSubmit(Convert.ToEntity(dto)); 122 else Convert.ToEntity(dto, entity); 123 db.SubmitChanges(); 151 using (var db = CreateContext()) { 152 var entity = db.HiveExperiments.FirstOrDefault(x => x.HiveExperimentId == dto.Id); 153 if (entity == null) db.HiveExperiments.InsertOnSubmit(Convert.ToEntity(dto)); 154 else Convert.ToEntity(dto, entity); 155 db.SubmitChanges(); 156 } 124 157 } 125 158 126 159 public void DeleteHiveExperiment(Guid id) { 127 var entity = db.HiveExperiments.FirstOrDefault(x => x.HiveExperimentId == id); 128 if (entity != null) db.HiveExperiments.DeleteOnSubmit(entity); 129 db.SubmitChanges(); 130 } 131 #endregion 132 160 using (var db = CreateContext()) { 161 var entity = db.HiveExperiments.FirstOrDefault(x => x.HiveExperimentId == id); 162 if (entity != null) db.HiveExperiments.DeleteOnSubmit(entity); 163 db.SubmitChanges(); 164 } 165 } 166 #endregion 133 167 134 168 #region Slave Methods 135 169 public DT.Slave GetSlave(Guid id) { 136 return Convert.ToDto(db.Resources.OfType<Slave>().SingleOrDefault(x => x.ResourceId == id)); 170 using (var db = CreateContext()) { 171 return Convert.ToDto(db.Resources.OfType<Slave>().SingleOrDefault(x => x.ResourceId == id)); 172 } 137 173 } 138 174 139 175 public IEnumerable<DT.Slave> GetSlaves(Expression<Func<Slave, bool>> predicate) { 140 return db.Resources.OfType<Slave>().Where(predicate).Select(x => Convert.ToDto(x)); 176 using (var db = CreateContext()) { 177 return db.Resources.OfType<Slave>().Where(predicate).Select(x => Convert.ToDto(x)).ToArray(); 178 } 141 179 } 142 180 143 181 public Guid AddSlave(DT.Slave dto) { 144 var entity = Convert.ToEntity(dto); 145 db.Resources.InsertOnSubmit(entity); 146 db.SubmitChanges(); 147 return entity.ResourceId; 182 using (var db = CreateContext()) { 183 var entity = Convert.ToEntity(dto); 184 db.Resources.InsertOnSubmit(entity); 185 db.SubmitChanges(); 186 return entity.ResourceId; 187 } 148 188 } 149 189 150 190 public void UpdateSlave(DT.Slave dto) { 151 var entity = db.Resources.OfType<Slave>().FirstOrDefault(x => x.ResourceId == dto.Id); 152 if (entity == null) db.Resources.InsertOnSubmit(Convert.ToEntity(dto)); 153 else Convert.ToEntity(dto, entity); 154 db.SubmitChanges(); 191 using (var db = CreateContext()) { 192 var entity = db.Resources.OfType<Slave>().FirstOrDefault(x => x.ResourceId == dto.Id); 193 if (entity == null) db.Resources.InsertOnSubmit(Convert.ToEntity(dto)); 194 else Convert.ToEntity(dto, entity); 195 db.SubmitChanges(); 196 } 155 197 } 156 198 157 199 public void DeleteSlave(Guid id) { 158 var entity = db.Resources.OfType<Slave>().FirstOrDefault(x => x.ResourceId == id); 159 if (entity != null) db.Resources.DeleteOnSubmit(entity); 160 db.SubmitChanges(); 200 using (var db = CreateContext()) { 201 var entity = db.Resources.OfType<Slave>().FirstOrDefault(x => x.ResourceId == id); 202 if (entity != null) db.Resources.DeleteOnSubmit(entity); 203 db.SubmitChanges(); 204 } 161 205 } 162 206 #endregion … … 164 208 #region SlaveGroup Methods 165 209 public DT.SlaveGroup GetSlaveGroup(Guid id) { 166 return Convert.ToDto(db.Resources.OfType<SlaveGroup>().SingleOrDefault(x => x.ResourceId == id)); 210 using (var db = CreateContext()) { 211 return Convert.ToDto(db.Resources.OfType<SlaveGroup>().SingleOrDefault(x => x.ResourceId == id)); 212 } 167 213 } 168 214 169 215 public IEnumerable<DT.SlaveGroup> GetSlaveGroups(Expression<Func<SlaveGroup, bool>> predicate) { 170 return db.Resources.OfType<SlaveGroup>().Where(predicate).Select(x => Convert.ToDto(x)); 216 using (var db = CreateContext()) { 217 return db.Resources.OfType<SlaveGroup>().Where(predicate).Select(x => Convert.ToDto(x)).ToArray(); 218 } 171 219 } 172 220 173 221 public Guid AddSlaveGroup(DT.SlaveGroup dto) { 174 var entity = Convert.ToEntity(dto); 175 db.Resources.InsertOnSubmit(entity); 176 db.SubmitChanges(); 177 return entity.ResourceId; 222 using (var db = CreateContext()) { 223 var entity = Convert.ToEntity(dto); 224 db.Resources.InsertOnSubmit(entity); 225 db.SubmitChanges(); 226 return entity.ResourceId; 227 } 178 228 } 179 229 180 230 public void UpdateSlaveGroup(DT.SlaveGroup dto) { 181 var entity = db.Resources.OfType<SlaveGroup>().FirstOrDefault(x => x.ResourceId == dto.Id); 182 if (entity == null) db.Resources.InsertOnSubmit(Convert.ToEntity(dto)); 183 else Convert.ToEntity(dto, entity); 184 db.SubmitChanges(); 231 using (var db = CreateContext()) { 232 var entity = db.Resources.OfType<SlaveGroup>().FirstOrDefault(x => x.ResourceId == dto.Id); 233 if (entity == null) db.Resources.InsertOnSubmit(Convert.ToEntity(dto)); 234 else Convert.ToEntity(dto, entity); 235 db.SubmitChanges(); 236 } 185 237 } 186 238 187 239 public void DeleteSlaveGroup(Guid id) { 188 var entity = db.Resources.OfType<SlaveGroup>().FirstOrDefault(x => x.ResourceId == id); 189 if (entity != null) db.Resources.DeleteOnSubmit(entity); 190 db.SubmitChanges(); 240 using (var db = CreateContext()) { 241 var entity = db.Resources.OfType<SlaveGroup>().FirstOrDefault(x => x.ResourceId == id); 242 if (entity != null) db.Resources.DeleteOnSubmit(entity); 243 db.SubmitChanges(); 244 } 191 245 } 192 246 #endregion … … 194 248 #region Resource Methods 195 249 public DT.Resource GetResource(Guid id) { 196 return Convert.ToDto(db.Resources.SingleOrDefault(x => x.ResourceId == id)); 250 using (var db = CreateContext()) { 251 return Convert.ToDto(db.Resources.SingleOrDefault(x => x.ResourceId == id)); 252 } 197 253 } 198 254 199 255 public IEnumerable<DT.Resource> GetResources(Expression<Func<Resource, bool>> predicate) { 200 return db.Resources.Where(predicate).Select(x => Convert.ToDto(x)); 256 using (var db = CreateContext()) { 257 return db.Resources.Where(predicate).Select(x => Convert.ToDto(x)).ToArray(); 258 } 201 259 } 202 260 203 261 public Guid AddResource(DT.Resource dto) { 204 var entity = Convert.ToEntity(dto); 205 db.Resources.InsertOnSubmit(entity); 206 db.SubmitChanges(); 207 return entity.ResourceId; 262 using (var db = CreateContext()) { 263 var entity = Convert.ToEntity(dto); 264 db.Resources.InsertOnSubmit(entity); 265 db.SubmitChanges(); 266 return entity.ResourceId; 267 } 208 268 } 209 269 210 270 public void UpdateResource(DT.Resource dto) { 211 var entity = db.Resources.FirstOrDefault(x => x.ResourceId == dto.Id); 212 if (entity == null) db.Resources.InsertOnSubmit(Convert.ToEntity(dto)); 213 else Convert.ToEntity(dto, entity); 214 db.SubmitChanges(); 271 using (var db = CreateContext()) { 272 var entity = db.Resources.FirstOrDefault(x => x.ResourceId == dto.Id); 273 if (entity == null) db.Resources.InsertOnSubmit(Convert.ToEntity(dto)); 274 else Convert.ToEntity(dto, entity); 275 db.SubmitChanges(); 276 } 215 277 } 216 278 217 279 public void DeleteResource(Guid id) { 218 var entity = db.Resources.FirstOrDefault(x => x.ResourceId == id); 219 if (entity != null) db.Resources.DeleteOnSubmit(entity); 220 db.SubmitChanges(); 280 using (var db = CreateContext()) { 281 var entity = db.Resources.FirstOrDefault(x => x.ResourceId == id); 282 if (entity != null) db.Resources.DeleteOnSubmit(entity); 283 db.SubmitChanges(); 284 } 221 285 } 222 286 #endregion … … 224 288 #region Authorization Methods 225 289 public bool IsUserAuthorizedForJobs(Guid userId, params Guid[] jobIds) { 226 var userIds = from job in db.Jobs // this needs to be fast!227 where jobIds.Contains(job.JobId)228 select job.UserId;229 return userIds.All(x => x == userId);230 }231 #endregion232 233 290 using (var db = CreateContext()) { 291 var userIds = from job in db.Jobs // this needs to be fast! 292 where jobIds.Contains(job.JobId) 293 select job.UserId; 294 return userIds.All(x => x == userId); 295 } 296 } 297 #endregion 234 298 } 235 299 } -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml
r4615 r4649 70 70 <Association Name="Resource_UptimeCalendar" Member="UptimeCalendars" ThisKey="ResourceId" OtherKey="ResourceId" Type="UptimeCalendar" /> 71 71 <Type Name="Slave" InheritanceCode="Slave" IsInheritanceDefault="true"> 72 <Column Name="C PUSpeed" Type="System.Int32" DbType="Int" CanBeNull="true" />72 <Column Name="CpuSpeed" Storage="_CPUSpeed" Type="System.Int32" DbType="Int" CanBeNull="true" /> 73 73 <Column Name="Memory" Type="System.Int32" DbType="Int" CanBeNull="true" /> 74 74 <Column Name="Login" Type="System.DateTime" DbType="DateTime" CanBeNull="true" /> 75 <Column Name="S tatus" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" />76 <Column Name="CalendarSyncStat us" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" />75 <Column Name="SlaveState" Storage="_Status" Type="global::HeuristicLab.Services.Hive.Common.DataTransfer.SlaveState" DbType="VarChar(15)" CanBeNull="true" /> 76 <Column Name="CalendarSyncState" Storage="_CalendarSyncStatus" Type="global::HeuristicLab.Services.Hive.Common.DataTransfer.CalendarState" DbType="VarChar(MAX)" CanBeNull="true" /> 77 77 <Column Name="UseCalendarFromResourceId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" /> 78 78 <Column Name="SlaveConfigId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" /> 79 <Column Name=" NumberOfCores" Type="System.Int32" DbType="Int" CanBeNull="true" />80 <Column Name=" NumberOfFreeCores" Type="System.Int32" DbType="Int" CanBeNull="true" />79 <Column Name="Cores" Storage="_NumberOfCores" Type="System.Int32" DbType="Int" CanBeNull="true" /> 80 <Column Name="FreeCores" Storage="_NumberOfFreeCores" Type="System.Int32" DbType="Int" CanBeNull="true" /> 81 81 <Column Name="FreeMemory" Type="System.Int32" DbType="Int" CanBeNull="true" /> 82 82 <Column Name="IsAllowedToCalculate" Type="System.Boolean" DbType="Bit" CanBeNull="false" /> -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.designer.cs
r4615 r4649 1569 1569 private System.Nullable<System.DateTime> _Login; 1570 1570 1571 private string_Status;1572 1573 private string_CalendarSyncStatus;1571 private global::HeuristicLab.Services.Hive.Common.DataTransfer.SlaveState _Status; 1572 1573 private global::HeuristicLab.Services.Hive.Common.DataTransfer.CalendarState _CalendarSyncStatus; 1574 1574 1575 1575 private System.Nullable<System.Guid> _UseCalendarFromResourceId; … … 1595 1595 partial void OnValidate(System.Data.Linq.ChangeAction action); 1596 1596 partial void OnCreated(); 1597 partial void OnC PUSpeedChanging(System.Nullable<int> value);1598 partial void OnC PUSpeedChanged();1597 partial void OnCpuSpeedChanging(System.Nullable<int> value); 1598 partial void OnCpuSpeedChanged(); 1599 1599 partial void OnMemoryChanging(System.Nullable<int> value); 1600 1600 partial void OnMemoryChanged(); 1601 1601 partial void OnLoginChanging(System.Nullable<System.DateTime> value); 1602 1602 partial void OnLoginChanged(); 1603 partial void OnS tatusChanging(stringvalue);1604 partial void OnS tatusChanged();1605 partial void OnCalendarSyncStat usChanging(stringvalue);1606 partial void OnCalendarSyncStat usChanged();1603 partial void OnSlaveStateChanging(global::HeuristicLab.Services.Hive.Common.DataTransfer.SlaveState value); 1604 partial void OnSlaveStateChanged(); 1605 partial void OnCalendarSyncStateChanging(global::HeuristicLab.Services.Hive.Common.DataTransfer.CalendarState value); 1606 partial void OnCalendarSyncStateChanged(); 1607 1607 partial void OnUseCalendarFromResourceIdChanging(System.Nullable<System.Guid> value); 1608 1608 partial void OnUseCalendarFromResourceIdChanged(); 1609 1609 partial void OnSlaveConfigIdChanging(System.Nullable<System.Guid> value); 1610 1610 partial void OnSlaveConfigIdChanged(); 1611 partial void On NumberOfCoresChanging(System.Nullable<int> value);1612 partial void On NumberOfCoresChanged();1613 partial void On NumberOfFreeCoresChanging(System.Nullable<int> value);1614 partial void On NumberOfFreeCoresChanged();1611 partial void OnCoresChanging(System.Nullable<int> value); 1612 partial void OnCoresChanged(); 1613 partial void OnFreeCoresChanging(System.Nullable<int> value); 1614 partial void OnFreeCoresChanged(); 1615 1615 partial void OnFreeMemoryChanging(System.Nullable<int> value); 1616 1616 partial void OnFreeMemoryChanged(); … … 1628 1628 1629 1629 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CPUSpeed", DbType="Int")] 1630 public System.Nullable<int> C PUSpeed1630 public System.Nullable<int> CpuSpeed 1631 1631 { 1632 1632 get … … 1638 1638 if ((this._CPUSpeed != value)) 1639 1639 { 1640 this.OnC PUSpeedChanging(value);1640 this.OnCpuSpeedChanging(value); 1641 1641 this.SendPropertyChanging(); 1642 1642 this._CPUSpeed = value; 1643 this.SendPropertyChanged("C PUSpeed");1644 this.OnC PUSpeedChanged();1643 this.SendPropertyChanged("CpuSpeed"); 1644 this.OnCpuSpeedChanged(); 1645 1645 } 1646 1646 } … … 1687 1687 } 1688 1688 1689 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Status", DbType="VarChar( MAX)")]1690 public string Status1689 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Status", DbType="VarChar(15)", CanBeNull=true)] 1690 public global::HeuristicLab.Services.Hive.Common.DataTransfer.SlaveState SlaveState 1691 1691 { 1692 1692 get … … 1698 1698 if ((this._Status != value)) 1699 1699 { 1700 this.OnS tatusChanging(value);1700 this.OnSlaveStateChanging(value); 1701 1701 this.SendPropertyChanging(); 1702 1702 this._Status = value; 1703 this.SendPropertyChanged("S tatus");1704 this.OnS tatusChanged();1705 } 1706 } 1707 } 1708 1709 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CalendarSyncStatus", DbType="VarChar(MAX)" )]1710 public string CalendarSyncStatus1703 this.SendPropertyChanged("SlaveState"); 1704 this.OnSlaveStateChanged(); 1705 } 1706 } 1707 } 1708 1709 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CalendarSyncStatus", DbType="VarChar(MAX)", CanBeNull=true)] 1710 public global::HeuristicLab.Services.Hive.Common.DataTransfer.CalendarState CalendarSyncState 1711 1711 { 1712 1712 get … … 1718 1718 if ((this._CalendarSyncStatus != value)) 1719 1719 { 1720 this.OnCalendarSyncStat usChanging(value);1720 this.OnCalendarSyncStateChanging(value); 1721 1721 this.SendPropertyChanging(); 1722 1722 this._CalendarSyncStatus = value; 1723 this.SendPropertyChanged("CalendarSyncStat us");1724 this.OnCalendarSyncStat usChanged();1723 this.SendPropertyChanged("CalendarSyncState"); 1724 this.OnCalendarSyncStateChanged(); 1725 1725 } 1726 1726 } … … 1772 1772 1773 1773 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_NumberOfCores", DbType="Int")] 1774 public System.Nullable<int> NumberOfCores1774 public System.Nullable<int> Cores 1775 1775 { 1776 1776 get … … 1782 1782 if ((this._NumberOfCores != value)) 1783 1783 { 1784 this.On NumberOfCoresChanging(value);1784 this.OnCoresChanging(value); 1785 1785 this.SendPropertyChanging(); 1786 1786 this._NumberOfCores = value; 1787 this.SendPropertyChanged(" NumberOfCores");1788 this.On NumberOfCoresChanged();1787 this.SendPropertyChanged("Cores"); 1788 this.OnCoresChanged(); 1789 1789 } 1790 1790 } … … 1792 1792 1793 1793 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_NumberOfFreeCores", DbType="Int")] 1794 public System.Nullable<int> NumberOfFreeCores1794 public System.Nullable<int> FreeCores 1795 1795 { 1796 1796 get … … 1802 1802 if ((this._NumberOfFreeCores != value)) 1803 1803 { 1804 this.On NumberOfFreeCoresChanging(value);1804 this.OnFreeCoresChanging(value); 1805 1805 this.SendPropertyChanging(); 1806 1806 this._NumberOfFreeCores = value; 1807 this.SendPropertyChanged(" NumberOfFreeCores");1808 this.On NumberOfFreeCoresChanged();1807 this.SendPropertyChanged("FreeCores"); 1808 this.OnFreeCoresChanged(); 1809 1809 } 1810 1810 } -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/Tools/CreateHiveDatabaseApplication.cs
r4629 r4649 27 27 28 28 public override void Run() { 29 CreateDataContext<HiveDataContext> contextCreator = new CreateDataContext<HiveDataContext>(ContextFactory<HiveDataContext>.CreateHiveContext); 30 IContextFactory<HiveDataContext> contextFactory = new ContextFactory<HiveDataContext>(contextCreator); 31 32 using (contextFactory.GetContext(false)) { 33 if (contextFactory.CurrentContext.DatabaseExists()) 34 contextFactory.CurrentContext.DeleteDatabase(); 35 contextFactory.CurrentContext.CreateDatabase(); 29 var dao = new HiveDao(); 30 using (var db = dao.CreateContext()) { 31 if (db.DatabaseExists()) 32 db.DeleteDatabase(); 33 db.CreateDatabase(); 36 34 } 37 35 } -
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/MergeConfigs.cmd
r4629 r4649 6 6 copy "%SolutionDir%HeuristicLab 3.3.exe.config" "%TargetDir%" 7 7 8 %SolutionDir%ConfigMerger "% SolutionDir%HeuristicLab.Hive-3.3.dll.config" "HeuristicLab 3.3.exe.config"9 10 copy " HeuristicLab 3.3.exe.config" "%target%"8 %SolutionDir%ConfigMerger "%TargetDir%HeuristicLab.Hive-3.3.dll.config" "%TargetDir%HeuristicLab 3.3.exe.config" 9 copy "%TargetDir%HeuristicLab 3.3.exe.config" "asdf.config" 10 copy "%TargetDir%HeuristicLab 3.3.exe.config" "%target%"
Note: See TracChangeset
for help on using the changeset viewer.