Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6000


Ignore:
Timestamp:
04/11/11 15:32:27 (13 years ago)
Author:
cneumuel
Message:

#1233

  • added GetPlugin service method
  • fixed minor issues with double plugins in database
  • worked on HiveEngine
  • fixed wrong role name for Hive User
  • fixed bug in group assignment of slaves
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
10 added
13 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Tests/Mocks/MockHiveService.cs

    r5779 r6000  
    266266    }
    267267
     268    public Plugin GetPlugin(Guid pluginId) {
     269      if (plugins == null)
     270        plugins = ReadPluginsFromServerCache();
     271      return plugins.SingleOrDefault(x => x.Id == pluginId);
     272    }
     273
    268274    public List<Plugin> GetPlugins() {
    269275      if (plugins == null)
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ExperimentManager/ExperimentManagerClient.cs

    r5958 r6000  
    5050    }
    5151
    52     private IEnumerable<Plugin> onlinePlugins;
    53     public IEnumerable<Plugin> OnlinePlugins {
     52    private List<Plugin> onlinePlugins;
     53    public List<Plugin> OnlinePlugins {
    5454      get { return onlinePlugins; }
    5555      set { onlinePlugins = value; }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/PluginUtil.cs

    r5958 r6000  
    2424using System.IO;
    2525using System.Linq;
     26using System.ServiceModel;
    2627using HeuristicLab.PluginInfrastructure;
    2728
     
    3839    /// <param name="useLocalPlugins">If true, the plugins which are already online are ignored. All local plugins are uploaded, but only once.</param>
    3940    /// <returns></returns>
    40     public static List<Guid> GetPluginDependencies(IHiveService service, IEnumerable<Plugin> onlinePlugins, List<Plugin> alreadyUploadedPlugins, IEnumerable<IPluginDescription> neededPlugins, bool useLocalPlugins) {
     41    public static List<Guid> GetPluginDependencies(IHiveService service, List<Plugin> onlinePlugins, List<Plugin> alreadyUploadedPlugins, IEnumerable<IPluginDescription> neededPlugins, bool useLocalPlugins) {
    4142      var pluginIds = new List<Guid>();
    4243      foreach (var neededPlugin in neededPlugins) {
    43         Plugin foundPlugin = alreadyUploadedPlugins.SingleOrDefault(p => p.Name == neededPlugin.Name && p.Version == neededPlugin.Version);
     44        Plugin foundPlugin = alreadyUploadedPlugins.FirstOrDefault(p => p.Name == neededPlugin.Name && p.Version == neededPlugin.Version);
    4445        if (foundPlugin == null) {
    45           foundPlugin = onlinePlugins.SingleOrDefault(p => p.Name == neededPlugin.Name && p.Version == neededPlugin.Version);
     46          foundPlugin = onlinePlugins.FirstOrDefault(p => p.Name == neededPlugin.Name && p.Version == neededPlugin.Version);
    4647          if (useLocalPlugins || foundPlugin == null) {
    4748            Plugin p = CreatePlugin(neededPlugin, useLocalPlugins);
    4849            List<PluginData> pd = CreatePluginDatas(neededPlugin);
    49             p.Id = service.AddPlugin(p, pd);
    50             alreadyUploadedPlugins.Add(p);
    51             pluginIds.Add(p.Id);
     50            try {
     51              p.Id = service.AddPlugin(p, pd);
     52              alreadyUploadedPlugins.Add(p);
     53              pluginIds.Add(p.Id);
     54            }
     55            catch (FaultException<PluginAlreadyExistsFault> fault) {
     56              onlinePlugins.Add(service.GetPlugin(fault.Detail.Id));
     57            }
    5258          } else {
    5359            pluginIds.Add(foundPlugin.Id);
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveServiceClient.cs

    r5955 r6000  
    16731673    }
    16741674   
     1675    [System.Diagnostics.DebuggerStepThroughAttribute()]
     1676    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
     1677    [System.Runtime.Serialization.DataContractAttribute(Name="PluginAlreadyExistsFault", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.Common")]
     1678    [System.SerializableAttribute()]
     1679    public partial class PluginAlreadyExistsFault : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
     1680    {
     1681       
     1682        [System.NonSerializedAttribute()]
     1683        private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
     1684       
     1685        [System.Runtime.Serialization.OptionalFieldAttribute()]
     1686        private System.Guid IdField;
     1687       
     1688        public System.Runtime.Serialization.ExtensionDataObject ExtensionData
     1689        {
     1690            get
     1691            {
     1692                return this.extensionDataField;
     1693            }
     1694            set
     1695            {
     1696                this.extensionDataField = value;
     1697            }
     1698        }
     1699       
     1700        [System.Runtime.Serialization.DataMemberAttribute()]
     1701        public System.Guid Id
     1702        {
     1703            get
     1704            {
     1705                return this.IdField;
     1706            }
     1707            set
     1708            {
     1709                if ((this.IdField.Equals(value) != true))
     1710                {
     1711                    this.IdField = value;
     1712                    this.RaisePropertyChanged("Id");
     1713                }
     1714            }
     1715        }
     1716       
     1717        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
     1718       
     1719        protected void RaisePropertyChanged(string propertyName)
     1720        {
     1721            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
     1722            if ((propertyChanged != null))
     1723            {
     1724                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
     1725            }
     1726        }
     1727    }
     1728   
    16751729    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    16761730    [System.ServiceModel.ServiceContractAttribute(ConfigurationName="HeuristicLab.Clients.Hive.IHiveService")]
     
    16781732    {
    16791733       
     1734        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddAppointment", ReplyAction="http://tempuri.org/IHiveService/AddAppointmentResponse")]
     1735        System.Guid AddAppointment(HeuristicLab.Clients.Hive.Appointment appointment);
     1736       
    16801737        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/DeleteAppointment", ReplyAction="http://tempuri.org/IHiveService/DeleteAppointmentResponse")]
    16811738        void DeleteAppointment(System.Guid appointmentId);
     
    17591816        System.Collections.Generic.List<HeuristicLab.Clients.Hive.MessageContainer> Heartbeat([System.ServiceModel.MessageParameterAttribute(Name="heartbeat")] HeuristicLab.Clients.Hive.Heartbeat heartbeat1);
    17601817       
     1818        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetPlugin", ReplyAction="http://tempuri.org/IHiveService/GetPluginResponse")]
     1819        HeuristicLab.Clients.Hive.Plugin GetPlugin(System.Guid pluginId);
     1820       
    17611821        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddPlugin", ReplyAction="http://tempuri.org/IHiveService/AddPluginResponse")]
     1822        [System.ServiceModel.FaultContractAttribute(typeof(HeuristicLab.Clients.Hive.PluginAlreadyExistsFault), Action="http://tempuri.org/IHiveService/AddPluginPluginAlreadyExistsFaultFault", Name="PluginAlreadyExistsFault", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.Common")]
    17621823        System.Guid AddPlugin(HeuristicLab.Clients.Hive.Plugin plugin, System.Collections.Generic.List<HeuristicLab.Clients.Hive.PluginData> pluginData);
    17631824       
     
    18091870        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/TriggerLifecycle", ReplyAction="http://tempuri.org/IHiveService/TriggerLifecycleResponse")]
    18101871        void TriggerLifecycle(bool force);
    1811        
    1812         [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddAppointment", ReplyAction="http://tempuri.org/IHiveService/AddAppointmentResponse")]
    1813         System.Guid AddAppointment(HeuristicLab.Clients.Hive.Appointment appointment);
    18141872    }
    18151873   
     
    18481906        }
    18491907       
     1908        public System.Guid AddAppointment(HeuristicLab.Clients.Hive.Appointment appointment)
     1909        {
     1910            return base.Channel.AddAppointment(appointment);
     1911        }
     1912       
    18501913        public void DeleteAppointment(System.Guid appointmentId)
    18511914        {
     
    19832046        }
    19842047       
     2048        public HeuristicLab.Clients.Hive.Plugin GetPlugin(System.Guid pluginId)
     2049        {
     2050            return base.Channel.GetPlugin(pluginId);
     2051        }
     2052       
    19852053        public System.Guid AddPlugin(HeuristicLab.Clients.Hive.Plugin plugin, System.Collections.Generic.List<HeuristicLab.Clients.Hive.PluginData> pluginData)
    19862054        {
     
    20672135            base.Channel.TriggerLifecycle(force);
    20682136        }
    2069        
    2070         public System.Guid AddAppointment(HeuristicLab.Clients.Hive.Appointment appointment)
    2071         {
    2072             return base.Channel.AddAppointment(appointment);
    2073         }
    20742137    }
    20752138}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/Plugin.cs

    r5955 r6000  
    3939      return new Plugin(this, cloner);
    4040    }
     41
     42    public override string ToString() {
     43      return string.Format("{0}-{1}", this.Name, this.Version.ToString()) + (this.IsLocal ? ", Local" : string.Empty);
     44    }
    4145  }
    4246}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Hive 3.4.sln

    r5958 r6000  
    3434  ProjectSection(WebsiteProperties) = preProject
    3535    TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0"
    36     ProjectReferences = "{CF9DA321-AC1B-4FD3-9EC3-67BC6B861BDE}|HeuristicLab.Services.Hive-3.4.dll;{14424A16-48D4-445E-80BF-DDF617548BBB}|HeuristicLab.Services.Hive.Common-3.4.dll;{EC2C8109-6E1E-4C88-9A2B-908CFF2EF4AC}|HeuristicLab.Services.Hive.DataAccess-3.4.dll;"
     36    ProjectReferences = "{CF9DA321-AC1B-4FD3-9EC3-67BC6B861BDE}|HeuristicLab.Services.Hive-3.4.dll;{14424A16-48D4-445E-80BF-DDF617548BBB}|HeuristicLab.Services.Hive.Common-3.4.dll;{EC2C8109-6E1E-4C88-9A2B-908CFF2EF4AC}|HeuristicLab.Services.Hive.DataAccess-3.4.dll;{F98A1740-9AC9-4D36-A582-6A2D0D06978D}|HeuristicLab.Hive-3.4.dll;"
    3737    Debug.AspNetCompiler.VirtualPath = "/Hive-3.4"
    3838    Debug.AspNetCompiler.PhysicalPath = "HeuristicLab.Services.Hive.Web\Hive-3.4\"
     
    9292EndProject
    9393Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.HiveEngine-3.4", "HeuristicLab.HiveEngine\3.4\HeuristicLab.HiveEngine-3.4.csproj", "{2C036542-5451-4A23-AFF6-87575C7BAFE7}"
     94EndProject
     95Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.HiveEngine.Test", "HeuristicLab.HiveEngine.Test\HeuristicLab.HiveEngine.Test.csproj", "{87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}"
    9496EndProject
    9597Global
     
    386388    {2C036542-5451-4A23-AFF6-87575C7BAFE7}.Release|x86.ActiveCfg = Release|x86
    387389    {2C036542-5451-4A23-AFF6-87575C7BAFE7}.Release|x86.Build.0 = Release|x86
     390    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     391    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
     392    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
     393    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}.Debug|Mixed Platforms.Build.0 = Debug|x86
     394    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}.Debug|x64.ActiveCfg = Debug|x86
     395    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}.Debug|x86.ActiveCfg = Debug|x86
     396    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}.Debug|x86.Build.0 = Debug|x86
     397    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}.Release|Any CPU.ActiveCfg = Release|x86
     398    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}.Release|Mixed Platforms.ActiveCfg = Release|x86
     399    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}.Release|Mixed Platforms.Build.0 = Release|x86
     400    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}.Release|x64.ActiveCfg = Release|x86
     401    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}.Release|x86.ActiveCfg = Release|x86
     402    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5}.Release|x86.Build.0 = Release|x86
    388403  EndGlobalSection
    389404  GlobalSection(SolutionProperties) = preSolution
     
    413428    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB} = {9963403B-3CB9-48E0-9FEB-B1CE12C31601}
    414429    {2C036542-5451-4A23-AFF6-87575C7BAFE7} = {4596C5BB-CAB1-4C01-891F-4890F9F16CF8}
     430    {87D9FBB9-8E54-4770-9C84-B4B571D9EDD5} = {4596C5BB-CAB1-4C01-891F-4890F9F16CF8}
    415431  EndGlobalSection
    416432EndGlobal
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4

    • Property svn:ignore set to
      bin
      obj
      HeuristicLab.HiveEngine-3.4.csproj.vs10x
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/EngineJob.cs

    r5958 r6000  
    3333      this.initialOperation = initialOperation;
    3434      this.engine = engine;
    35       this.engine.Prepare(initialOperation);
    3635      RegisterEngineEvents();
    3736    }
     
    4241      : base(original, cloner) {
    4342      this.engine = cloner.Clone(original.engine);
     43      this.initialOperation = cloner.Clone(original.initialOperation);
    4444      RegisterEngineEvents();
    4545    }
     
    6060
    6161    public override void Start() {
     62      engine.Prepare(initialOperation);
    6263      engine.Start();
    6364    }
    6465   
    6566    public override void Pause() {
    66       throw new NotImplementedException();
     67      engine.Pause();
    6768    }
    6869
     
    8081    }
    8182
    82     void engine_ExceptionOccurred(object sender, EventArgs<Exception> e) {
     83    private void engine_ExceptionOccurred(object sender, EventArgs<Exception> e) {
    8384      OnJobFailed(e);
    8485    }
    8586
    86     void engine_Stopped(object sender, EventArgs e) {
     87    private void engine_Stopped(object sender, EventArgs e) {
    8788      OnJobStopped();
    8889    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/HiveEngine.cs

    r5958 r6000  
    4646    }
    4747
    48     private IEnumerable<Plugin> onlinePlugins;
    49     public IEnumerable<Plugin> OnlinePlugins {
     48    private List<Plugin> onlinePlugins;
     49    public List<Plugin> OnlinePlugins {
    5050      get { return onlinePlugins; }
    5151      set { onlinePlugins = value; }
    5252    }
    53    
     53
    5454    private List<Plugin> alreadyUploadedPlugins;
    5555    public List<Plugin> AlreadyUploadedPlugins {
     
    102102      TaskScheduler.UnobservedTaskException += new EventHandler<UnobservedTaskExceptionEventArgs>(TaskScheduler_UnobservedTaskException);
    103103
    104       this.OnlinePlugins = ServiceLocator.Instance.CallHiveService(s => s.GetPlugins());
     104      this.OnlinePlugins = ServiceLocator.Instance.CallHiveService(s => s.GetPlugins()).Where(x => x.IsLocal == false).ToList();
    105105      this.AlreadyUploadedPlugins = new List<Plugin>();
    106106
     
    123123
    124124            IScope[] scopes = ExecuteOnHive(jobs, parentScopeClone, cancellationToken);
    125 
     125            //IScope[] scopes = ExecuteLocally(jobs, parentScopeClone, cancellationToken);
     126           
    126127            for (int i = 0; i < coll.Count; i++) {
    127128              if (coll[i] is IAtomicOperation) {
     
    183184      target.SubScopes.AddRange(source.SubScopes);
    184185      // TODO: validate if parent scopes match - otherwise source is invalid
     186    }
     187
     188    private IScope[] ExecuteLocally(EngineJob[] jobs, IScope parentScopeClone, CancellationToken cancellationToken) {
     189      IScope[] scopes = new Scope[jobs.Length];
     190
     191      for (int i = 0; i < jobs.Length; i++) {
     192        var job = (EngineJob)jobs[i].Clone();
     193        job.Start();
     194        while (job.ExecutionState != ExecutionState.Stopped) {
     195          Thread.Sleep(100);
     196        }
     197        scopes[i] = ((IAtomicOperation)job.InitialOperation).Scope;
     198      }
     199
     200      return scopes;
    185201    }
    186202
     
    444460    /// </summary>
    445461    private static void TryAndRepeat(Action action, int repetitions, string errorMessage) {
    446       while (repetitions > 0) {
    447         try { action(); }
    448         catch (Exception e) {
    449           repetitions--;
    450           if (repetitions == 0) {
    451             throw new HiveEngineException(errorMessage, e);
    452           }
    453         }
    454       }
    455     }
    456 
    457     private static void TryAndRepeat(Action action) {
    458       TryAndRepeat(action, -1, string.Empty);
     462      try { action(); }
     463      catch (Exception e) {
     464        repetitions--;
     465        if (repetitions <= 0)
     466          throw new HiveEngineException(errorMessage, e);
     467        TryAndRepeat(action, repetitions, errorMessage);
     468      }
    459469    }
    460470  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/HeuristicLab.Services.Hive.Common-3.4.csproj

    r5852 r6000  
    9595  <ItemGroup>
    9696    <Compile Include="ApplicationConstants.cs" />
     97    <Compile Include="ServiceFaults\PluginAlreadyExistsFault.cs" />
    9798    <None Include="HeuristicLabServicesHiveCommonPlugin.cs.frame" />
    9899    <Compile Include="DataTransfer\Appointment.cs" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/ServiceContracts/IHiveService.cs

    r5779 r6000  
    101101    #region Plugin Methods
    102102    [OperationContract]
     103    Plugin GetPlugin(Guid pluginId);
     104    [OperationContract]
     105    [FaultContract(typeof(PluginAlreadyExistsFault))]
    103106    Guid AddPlugin(Plugin plugin, List<PluginData> pluginData);
    104107    [OperationContract]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveRoles.cs

    r5028 r6000  
    2525    public const string Administrator = "Hive Administrator";
    2626    public const string Slave = "Hive Slave";
    27     public const string Client = "Hive Client";
     27    public const string Client = "Hive User";
    2828  }
    2929}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs

    r5793 r6000  
    250250          dao.AddSlave(slaveInfo);
    251251        } else {
    252           dao.UpdateSlave(slaveInfo);
     252          var dbSlave = dao.GetSlave(slaveInfo.Id);
     253
     254          dbSlave.Name = slaveInfo.Name;
     255          dbSlave.Description = slaveInfo.Description;
     256
     257          dbSlave.Cores = slaveInfo.Cores;
     258          dbSlave.CpuArchitecture = slaveInfo.CpuArchitecture;
     259          dbSlave.CpuSpeed = slaveInfo.CpuSpeed;
     260          dbSlave.FreeCores = slaveInfo.FreeCores;
     261          dbSlave.FreeMemory = slaveInfo.FreeMemory;
     262          dbSlave.Memory = slaveInfo.Memory;
     263          dbSlave.OperatingSystem = slaveInfo.OperatingSystem;
     264         
     265          dbSlave.LastHeartbeat = DateTime.Now;         
     266          dbSlave.SlaveState = SlaveState.Idle;
     267
     268          // don't update those properties:
     269          // dbSlave.IsAllowedToCalculate = slaveInfo.IsAllowedToCalculate;
     270          // dbSlave.ParentResourceId = slaveInfo.ParentResourceId;
     271
     272          dao.UpdateSlave(dbSlave);
    253273        }
    254274      });
     
    282302        plugin.UserId = auth.UserId;
    283303        plugin.DateCreated = DateTime.Now;
     304        if (!plugin.IsLocal) {
     305          var existing = dao.GetPlugins(x => x.Name == plugin.Name && x.Version == plugin.Version.ToString() && !x.IsLocal);
     306          if (existing.Count() > 0) {
     307            // a plugin with the same name and version already exists.
     308            throw new FaultException<PluginAlreadyExistsFault>(new PluginAlreadyExistsFault(existing.Single().Id));
     309          }
     310        }
    284311        Guid pluginId = dao.AddPlugin(plugin);
    285312        foreach (PluginData pluginData in pluginDatas) {
     
    289316        return pluginId;
    290317      });
     318    }
     319
     320    [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
     321    [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
     322    [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
     323    public Plugin GetPlugin(Guid pluginId) {
     324      return dao.GetPlugin(pluginId);
    291325    }
    292326
Note: See TracChangeset for help on using the changeset viewer.