Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/20/11 14:16:53 (13 years ago)
Author:
cneumuel
Message:

#1233

  • renamed UptimeCalendar and Appointment to Downtime
  • added service methods to delete plugins and get plugin by hash
  • made reverted TransactionManager change, made it non-static and added interface
  • moved magic numbers to application settings
Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4
Files:
1 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HeuristicLab.Clients.Hive-3.4.csproj

    r6431 r6452  
    120120    <None Include="app_services.config" />
    121121    <None Include="app.config" />
    122     <None Include="ClassDiagram2.cd" />
     122    <None Include="ClassDiagram.cd" />
    123123    <None Include="HeuristicLabClientsHivePlugin.cs.frame" />
    124124    <Compile Include="Exceptions\AddJobToHiveException.cs" />
     
    151151    <Compile Include="Exceptions\ServiceClientFactoryException.cs" />
    152152    <Compile Include="ScopeExtensions.cs" />
    153     <Compile Include="ServiceClients\Appointment.cs" />
     153    <Compile Include="ServiceClients\Downtime.cs" />
    154154    <Compile Include="ServiceClients\HiveItemCollection.cs" />
    155155    <Compile Include="ServiceClients\IHiveItem.cs" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HiveClient.cs

    r6444 r6452  
    192192    private Semaphore jobUploadSemaphore = new Semaphore(4, 4); // todo: take magic number into config
    193193    private static object jobCountLocker = new object();
     194    private static object pluginLocker = new object();
    194195    private void UploadExperiment(RefreshableHiveExperiment refreshableHiveExperiment, CancellationToken cancellationToken) {
    195196      try {
     
    285286          jobCount[0]++;
    286287        }
    287         JobData jobData = null;
    288         List<IPluginDescription> plugins = null;
    289 
    290         TryAndRepeat(() => { // workaround for persistence bug (thread-safe access to bitmaps) - remove later
    291           if (hiveJob.ItemJob.ComputeInParallel && (hiveJob.ItemJob.Item is Optimization.Experiment || hiveJob.ItemJob.Item is Optimization.BatchRun)) {
    292             hiveJob.Job.IsParentJob = true;
    293             hiveJob.Job.FinishWhenChildJobsFinished = true;
    294             jobData = hiveJob.GetAsJobData(true, out plugins);
    295           } else {
    296             hiveJob.Job.IsParentJob = false;
    297             hiveJob.Job.FinishWhenChildJobsFinished = false;
    298             jobData = hiveJob.GetAsJobData(false, out plugins);
    299           }
    300         }, 30, "Could not serialize job");
     288        JobData jobData;
     289        List<IPluginDescription> plugins;
     290
     291        if (hiveJob.ItemJob.ComputeInParallel && (hiveJob.ItemJob.Item is Optimization.Experiment || hiveJob.ItemJob.Item is Optimization.BatchRun)) {
     292          hiveJob.Job.IsParentJob = true;
     293          hiveJob.Job.FinishWhenChildJobsFinished = true;
     294          jobData = hiveJob.GetAsJobData(true, out plugins);
     295        } else {
     296          hiveJob.Job.IsParentJob = false;
     297          hiveJob.Job.FinishWhenChildJobsFinished = false;
     298          jobData = hiveJob.GetAsJobData(false, out plugins);
     299        }
    301300        cancellationToken.ThrowIfCancellationRequested();
    302301
    303302        TryAndRepeat(() => {
    304303          if (!cancellationToken.IsCancellationRequested) {
    305             ServiceLocator.Instance.CallHiveService((s) => hiveJob.Job.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins));
     304            lock (pluginLocker) {
     305              ServiceLocator.Instance.CallHiveService((s) => hiveJob.Job.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins));
     306            }
    306307          }
    307308        }, -1, "Failed to upload plugins");
     
    333334            var arguments = (Tuple<HiveJob, HiveJob>)tuple;
    334335            UploadJobWithChildren(progress, arguments.Item1, arguments.Item2, groups, jobCount, totalJobCount, configPluginId, hiveExperimentId, log, isPrivileged, cancellationToken);
    335           }, new Tuple<HiveJob, HiveJob>(child, hiveJob ))
     336          }, new Tuple<HiveJob, HiveJob>(child, hiveJob))
    336337          .ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted));
    337338        }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveServiceClient.cs

    r6426 r6452  
    8282  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.StateLog))]
    8383  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Job))]
    84   [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Appointment))]
     84  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Downtime))]
    8585  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.PluginData))]
    8686  public partial class HiveItem : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
     
    938938      "nsfer")]
    939939  [System.SerializableAttribute()]
    940   public partial class Appointment : HeuristicLab.Clients.Hive.HiveItem {
     940  public partial class Downtime : HeuristicLab.Clients.Hive.HiveItem {
    941941
    942942    [System.Runtime.Serialization.OptionalFieldAttribute()]
     
    15061506
    15071507    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AddAppointment", ReplyAction = "http://tempuri.org/IHiveService/AddAppointmentResponse")]
    1508     System.Guid AddAppointment(HeuristicLab.Clients.Hive.Appointment appointment);
     1508    System.Guid AddAppointment(HeuristicLab.Clients.Hive.Downtime appointment);
    15091509
    15101510    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/DeleteAppointment", ReplyAction = "http://tempuri.org/IHiveService/DeleteAppointmentResponse")]
     
    15121512
    15131513    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/UpdateAppointment", ReplyAction = "http://tempuri.org/IHiveService/UpdateAppointmentResponse")]
    1514     void UpdateAppointment(HeuristicLab.Clients.Hive.Appointment appointment);
     1514    void UpdateAppointment(HeuristicLab.Clients.Hive.Downtime appointment);
    15151515
    15161516    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/GetScheduleForResource", ReplyAction = "http://tempuri.org/IHiveService/GetScheduleForResourceResponse")]
    1517     System.Collections.Generic.List<HeuristicLab.Clients.Hive.Appointment> GetScheduleForResource(System.Guid resourceId);
     1517    System.Collections.Generic.List<HeuristicLab.Clients.Hive.Downtime> GetScheduleForResource(System.Guid resourceId);
    15181518
    15191519    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IHiveService/AddJob", ReplyAction = "http://tempuri.org/IHiveService/AddJobResponse")]
     
    16941694    }
    16951695
    1696     public System.Guid AddAppointment(HeuristicLab.Clients.Hive.Appointment appointment) {
     1696    public System.Guid AddAppointment(HeuristicLab.Clients.Hive.Downtime appointment) {
    16971697      return base.Channel.AddAppointment(appointment);
    16981698    }
     
    17021702    }
    17031703
    1704     public void UpdateAppointment(HeuristicLab.Clients.Hive.Appointment appointment) {
     1704    public void UpdateAppointment(HeuristicLab.Clients.Hive.Downtime appointment) {
    17051705      base.Channel.UpdateAppointment(appointment);
    17061706    }
    17071707
    1708     public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Appointment> GetScheduleForResource(System.Guid resourceId) {
     1708    public System.Collections.Generic.List<HeuristicLab.Clients.Hive.Downtime> GetScheduleForResource(System.Guid resourceId) {
    17091709      return base.Channel.GetScheduleForResource(resourceId);
    17101710    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/Util/PluginUtil.cs

    r6444 r6452  
    3030namespace HeuristicLab.Clients.Hive {
    3131  public static class PluginUtil {
    32     private static object locker = new object();
    3332
    3433    /// <summary>
     
    4140    /// <returns></returns>
    4241    public static List<Guid> GetPluginDependencies(IHiveService service, List<Plugin> onlinePlugins, List<Plugin> alreadyUploadedPlugins, IEnumerable<IPluginDescription> neededPlugins) {
    43       lock (locker) {
    44         var pluginIds = new List<Guid>();
    45         Dictionary<IPluginDescription, byte[]> checksumsNeededPlugins = CalcChecksumsForPlugins(neededPlugins);
     42      var pluginIds = new List<Guid>();
     43      Dictionary<IPluginDescription, byte[]> checksumsNeededPlugins = CalcChecksumsForPlugins(neededPlugins);
    4644
    47         foreach (var neededPlugin in checksumsNeededPlugins) {
    48           Plugin foundPlugin = alreadyUploadedPlugins.FirstOrDefault(p => p.Hash.SequenceEqual(neededPlugin.Value));
     45      foreach (var neededPlugin in checksumsNeededPlugins) {
     46        Plugin foundPlugin = alreadyUploadedPlugins.FirstOrDefault(p => p.Hash.SequenceEqual(neededPlugin.Value));
     47        if (foundPlugin == null) {
     48          foundPlugin = onlinePlugins.FirstOrDefault(p => {
     49            if (p.Hash != null) {
     50              return p.Hash.SequenceEqual(neededPlugin.Value);
     51            } else {
     52              return false;
     53            }
     54          });
     55
    4956          if (foundPlugin == null) {
    50             foundPlugin = onlinePlugins.FirstOrDefault(p => {
    51               if (p.Hash != null) {
    52                 return p.Hash.SequenceEqual(neededPlugin.Value);
    53               } else {
    54                 return false;
    55               }
    56             });
    57 
    58             if (foundPlugin == null) {
    59               Plugin p = CreatePlugin(neededPlugin.Key, neededPlugin.Value);
    60               List<PluginData> pd = CreatePluginDatas(neededPlugin.Key);
    61               try {
    62                 p.Id = service.AddPlugin(p, pd);
    63                 alreadyUploadedPlugins.Add(p);
    64                 pluginIds.Add(p.Id);
    65               }
    66               catch (FaultException<PluginAlreadyExistsFault> fault) {
    67                 onlinePlugins.Add(service.GetPlugin(fault.Detail.Id));
    68               }
    69             } else {
    70               pluginIds.Add(foundPlugin.Id);
     57            Plugin p = CreatePlugin(neededPlugin.Key, neededPlugin.Value);
     58            List<PluginData> pd = CreatePluginDatas(neededPlugin.Key);
     59            try {
     60              p.Id = service.AddPlugin(p, pd);
     61              alreadyUploadedPlugins.Add(p);
     62              pluginIds.Add(p.Id);
     63            }
     64            catch (FaultException<PluginAlreadyExistsFault> fault) {
     65              onlinePlugins.Add(service.GetPlugin(fault.Detail.Id));
    7166            }
    7267          } else {
    7368            pluginIds.Add(foundPlugin.Id);
    7469          }
     70        } else {
     71          pluginIds.Add(foundPlugin.Id);
    7572        }
    76         return pluginIds;
    7773      }
     74      return pluginIds;
    7875    }
    7976
Note: See TracChangeset for help on using the changeset viewer.