Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3217 for trunk


Ignore:
Timestamp:
03/25/10 17:14:05 (14 years ago)
Author:
gkronber
Message:

Defined PluginDescription data contract as IsReference and changed caching scheme of plugin descriptions in the plugin store to use the plugin id as key. #951 (Refreshing the list of plugins and products of the deployment service is very slow)

Location:
trunk/sources/HeuristicLab.Services.Deployment/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Services.Deployment/3.3/PluginDescription.cs

    r3084 r3217  
    2727
    2828namespace HeuristicLab.Services.Deployment {
    29   [DataContract(Name = "PluginDescription")]
     29  [DataContract(Name = "PluginDescription", IsReference = true)]
    3030  public class PluginDescription {
    3131
     
    3434    public string Name {
    3535      get { return name; }
     36      set {
     37        if (string.IsNullOrEmpty(value)) throw new ArgumentException();
     38        name = value;
     39      }
    3640    }
    3741
     
    4044    public Version Version {
    4145      get { return version; }
     46      set {
     47        if (value == null) throw new ArgumentNullException();
     48        version = value;
     49      }
    4250    }
    4351
     
    4654    public string ContactName {
    4755      get { return contactName; }
     56      set {
     57        if (value == null) throw new ArgumentNullException();
     58        contactName = value;
     59      }
    4860    }
    4961
     
    5264    public string ContactEmail {
    5365      get { return contactEmail; }
     66      set {
     67        if (value == null) throw new ArgumentNullException();
     68        contactEmail = value;
     69      }
    5470    }
    5571
     
    5874    public string LicenseText {
    5975      get { return licenseText; }
     76      set {
     77        if (value == null) throw new ArgumentNullException();
     78        licenseText = value;
     79      }
    6080    }
    6181
     
    6484    public List<PluginDescription> Dependencies {
    6585      get { return dependencies; }
     86      set {
     87        if (value == null) throw new ArgumentNullException();
     88        dependencies = value;
     89      }
    6690    }
    6791
    68     public PluginDescription(string name, Version version, IEnumerable<PluginDescription> dependencies, 
     92    public PluginDescription(string name, Version version, IEnumerable<PluginDescription> dependencies,
    6993      string contactName, string contactEmail, string license) {
    7094      if (string.IsNullOrEmpty(name)) throw new ArgumentException("name is empty");
  • trunk/sources/HeuristicLab.Services.Deployment/3.3/PluginStore.cs

    r3084 r3217  
    4545                                where plugin.Id == pair.PluginId
    4646                                select plugin
    47                   select MakeProductDescription(ctx, p, plugins)).ToList();
     47                  select MakeProductDescription(ctx, p, plugins.ToList())).ToList();
    4848        }
    4949      }
     
    169169
    170170      // delete cached entry
    171       if (pluginDescriptions.ContainsKey(pluginEntity)) pluginDescriptions.Remove(pluginEntity);
     171      if (pluginDescriptions.ContainsKey(pluginEntity.Id)) pluginDescriptions.Remove(pluginEntity.Id);
    172172
    173173      DeleteOldDependencies(ctx, pluginEntity);
     
    195195
    196196    #region product <-> productDescription transformation
    197     private ProductDescription MakeProductDescription(PluginStoreClassesDataContext ctx, Product p, IQueryable<Plugin> plugins) {
     197    private ProductDescription MakeProductDescription(PluginStoreClassesDataContext ctx, Product p, IEnumerable<Plugin> plugins) {
    198198      var desc = new ProductDescription(p.Name, new Version(p.Version), from plugin in plugins
    199199                                                                        select MakePluginDescription(ctx, plugin));
     
    210210    #region plugin <-> pluginDescription transformation
    211211    // cache for plugin descriptions
    212     private Dictionary<Plugin, PluginDescription> pluginDescriptions = new Dictionary<Plugin, PluginDescription>();
     212    private Dictionary<long, PluginDescription> pluginDescriptions = new Dictionary<long, PluginDescription>();
    213213    private PluginDescription MakePluginDescription(PluginStoreClassesDataContext ctx, Plugin plugin) {
    214       if (!pluginDescriptions.ContainsKey(plugin)) {
     214      if (!pluginDescriptions.ContainsKey(plugin.Id)) {
    215215        // no cached description -> create new
    216         var desc = new PluginDescription(plugin.Name,
    217           new Version(plugin.Version),
    218           from dep in GetDependencies(ctx, plugin)
    219           select MakePluginDescription(ctx, dep),
    220           plugin.ContactName ?? string.Empty,
    221           plugin.ContactEmail ?? string.Empty,
    222           plugin.License ?? string.Empty
    223           );
    224         pluginDescriptions[plugin] = desc;
    225       }
    226       return pluginDescriptions[plugin];
     216        var desc = new PluginDescription(plugin.Name, new Version(plugin.Version));
     217        pluginDescriptions[plugin.Id] = desc; // and add to cache
     218
     219        // fill remaining properties of plugin description
     220        desc.Dependencies = new List<PluginDescription>(from dep in GetDependencies(ctx, plugin) select MakePluginDescription(ctx, dep));
     221        desc.ContactEmail = plugin.ContactEmail ?? string.Empty;
     222        desc.ContactName = plugin.ContactName ?? string.Empty;
     223        desc.LicenseText = plugin.License ?? string.Empty;
     224      }
     225      return pluginDescriptions[plugin.Id];
    227226    }
    228227
Note: See TracChangeset for help on using the changeset viewer.