Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/11 13:54:57 (12 years ago)
Author:
spimming
Message:

#1680:

  • merged changes from trunk into branch

' removed pre-build event for multiple app.configs

Location:
branches/HeuristicLab.Hive.Azure
Files:
6 deleted
22 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive.Azure

  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3

    • Property svn:ignore
      •  

        old new  
        11obj
        22Plugin.cs
         3bin
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/ConcurrentTaskDownloader.cs

    r6976 r7215  
    4242    }
    4343
    44     public void DownloadTask(Task job, Action<Task, T> onFinishedAction) {
    45       Task<T> task = Task<TaskData>.Factory.StartNew((x) => DownloadTask(x), job.Id)
    46                                      .ContinueWith((x) => DeserializeTask(x.Result));
    47       task.ContinueWith((x) => OnTaskFinished(job, x, onFinishedAction), TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion);
    48       task.ContinueWith((x) => OnTaskFailed(job, x, onFinishedAction), TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnFaulted);
     44    public void DownloadTaskData(Task t, Action<Task, T> onFinishedAction) {
     45      Task<Tuple<Task, T>> task = Task<Tuple<Task, TaskData>>.Factory.StartNew(DownloadTaskData, t)
     46                                     .ContinueWith((y) => DeserializeTask(y.Result));
     47
     48      task.ContinueWith((x) => OnTaskFinished(x, onFinishedAction), TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion);
     49      task.ContinueWith((x) => OnTaskFailed(x, onFinishedAction), TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnFaulted);
    4950    }
    5051
    51     private void OnTaskFinished(Task job, Task<T> task, Action<Task, T> onFinishedAction) {
    52       onFinishedAction(job, task.Result);
     52    public void DownloadTaskDataAndTask(Guid taskId, Action<Task, T> onFinishedAction) {
     53      Task<Tuple<Task, T>> task = Task<Task>.Factory.StartNew(DownloadTask, taskId)
     54                                     .ContinueWith((x) => DownloadTaskData(x.Result))
     55                                     .ContinueWith((y) => DeserializeTask(y.Result));
     56
     57      task.ContinueWith((x) => OnTaskFinished(x, onFinishedAction), TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion);
     58      task.ContinueWith((x) => OnTaskFailed(x, onFinishedAction), TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnFaulted);
    5359    }
    54     private void OnTaskFailed(Task job, Task<T> task, Action<Task, T> onFinishedAction) {
     60
     61    private void OnTaskFinished(Task<Tuple<Task, T>> task, Action<Task, T> onFinishedAction) {
     62      onFinishedAction(task.Result.Item1, task.Result.Item2);
     63    }
     64    private void OnTaskFailed(Task<Tuple<Task, T>> task, Action<Task, T> onFinishedAction) {
    5565      task.Exception.Flatten().Handle((e) => { return true; });
    5666      OnExceptionOccured(task.Exception.Flatten());
    57       onFinishedAction(job, null);
     67      onFinishedAction(task.Result.Item1, null);
    5868    }
    5969
    60     protected TaskData DownloadTask(object taskId) {
     70    private Task DownloadTask(object taskId) {
     71      return HiveServiceLocator.Instance.CallHiveService(s => s.GetTask((Guid)taskId));
     72    }
     73
     74    protected Tuple<Task, TaskData> DownloadTaskData(object taskId) {
     75      return DownloadTaskData((Task)taskId);
     76    }
     77
     78    protected Tuple<Task, TaskData> DownloadTaskData(Task task) {
    6179      downloadSemaphore.WaitOne();
    62       deserializeSemaphore.WaitOne();
    6380      TaskData result;
    6481      try {
    6582        if (abort) return null;
    66         result = ServiceLocator.Instance.CallHiveService(s => s.GetTaskData((Guid)taskId));
    67       }
    68       finally {
     83        result = HiveServiceLocator.Instance.CallHiveService(s => s.GetTaskData(task.Id));
     84      } finally {
    6985        downloadSemaphore.Release();
    7086      }
    71       return result;
     87      return new Tuple<Task, TaskData>(task, result);
    7288    }
    7389
    74     protected T DeserializeTask(TaskData taskData) {
     90    protected Tuple<Task, T> DeserializeTask(Tuple<Task, TaskData> taskData) {
     91      deserializeSemaphore.WaitOne();
    7592      try {
    76         if (abort || taskData == null) return null;
    77         Task task = ServiceLocator.Instance.CallHiveService(s => s.GetTask(taskData.TaskId));
    78         if (task == null) return null;
    79         var deserializedJob = PersistenceUtil.Deserialize<T>(taskData.Data);
    80         taskData.Data = null; // reduce memory consumption.
    81         return deserializedJob;
    82       }
    83       finally {
     93        if (abort || taskData.Item2 == null || taskData.Item1 == null) return null;
     94        var deserializedJob = PersistenceUtil.Deserialize<T>(taskData.Item2.Data);
     95        taskData.Item2.Data = null; // reduce memory consumption.
     96        return new Tuple<Task, T>(taskData.Item1, deserializedJob);
     97      } finally {
    8498        deserializeSemaphore.Release();
    8599      }
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/HeuristicLab.Clients.Hive-3.3.csproj

    r6976 r7215  
    4040  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    4141    <DebugSymbols>true</DebugSymbols>
    42     <OutputPath>bin\x86\Debug\</OutputPath>
     42    <OutputPath>..\..\bin\</OutputPath>
    4343    <DefineConstants>DEBUG;TRACE</DefineConstants>
    4444    <DebugType>full</DebugType>
     
    5555  </PropertyGroup>
    5656  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    57     <OutputPath>bin\x86\Release\</OutputPath>
     57    <OutputPath>..\..\bin\</OutputPath>
    5858    <DefineConstants>TRACE</DefineConstants>
    5959    <Optimize>true</Optimize>
     
    6969    <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
    7070    <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
     71  </PropertyGroup>
     72  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
     73    <DebugSymbols>true</DebugSymbols>
     74    <OutputPath>..\..\bin\</OutputPath>
     75    <DefineConstants>DEBUG;TRACE</DefineConstants>
     76    <DebugType>full</DebugType>
     77    <PlatformTarget>x64</PlatformTarget>
     78    <CodeAnalysisLogFile>..\..\bin\HeuristicLab.Clients.Hive-3.3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
     79    <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
     80    <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
     81    <ErrorReport>prompt</ErrorReport>
     82    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     83    <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
     84    <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
     85    <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
     86  </PropertyGroup>
     87  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
     88    <OutputPath>..\..\bin\</OutputPath>
     89    <DefineConstants>TRACE</DefineConstants>
     90    <Optimize>true</Optimize>
     91    <DebugType>pdbonly</DebugType>
     92    <PlatformTarget>x64</PlatformTarget>
     93    <CodeAnalysisLogFile>..\..\bin\HeuristicLab.Clients.Hive-3.3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
     94    <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
     95    <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
     96    <ErrorReport>prompt</ErrorReport>
     97    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     98    <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
     99    <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
     100    <CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
    71101  </PropertyGroup>
    72102  <ItemGroup>
     
    98128    <Compile Include="StateLogList.cs" />
    99129    <Compile Include="StateLogListList.cs" />
    100     <None Include="app.config" />
     130    <None Include="app.config">
     131      <SubType>Designer</SubType>
     132    </None>
    101133    <None Include="Plugin.cs.frame" />
    102134    <Compile Include="Exceptions\AddTaskToHiveException.cs" />
     
    114146    </Compile>
    115147    <Compile Include="Exceptions\ResourceNotFoundException.cs" />
    116     <Compile Include="IServiceLocator.cs" />
     148    <Compile Include="IHiveServiceLocator.cs" />
    117149    <Compile Include="Tasks\EngineTask.cs" />
    118150    <Compile Include="Tasks\OptimizerTask.cs" />
     
    135167    <Compile Include="ServiceClients\Heartbeat.cs" />
    136168    <Compile Include="ServiceClients\HiveItem.cs" />
    137     <Compile Include="ServiceClients\JobData.cs" />
     169    <Compile Include="ServiceClients\TaskData.cs" />
    138170    <Compile Include="ServiceClients\Plugin.cs" />
    139171    <Compile Include="ServiceClients\PluginData.cs" />
     
    144176    <Compile Include="ServiceClients\Slave.cs" />
    145177    <Compile Include="ServiceClients\LightweightTask.cs" />
    146     <Compile Include="ServiceClients\ExecutorMessageContainer.cs" />
    147178    <Compile Include="ServiceClients\MessageContainer.cs" />
    148179    <Compile Include="ServiceClients\HiveServiceClient.cs" />
    149180    <Compile Include="ServiceClients\Task.cs" />
    150     <Compile Include="ServiceLocator.cs" />
     181    <Compile Include="HiveServiceLocator.cs" />
    151182    <None Include="HeuristicLab.snk" />
    152183    <None Include="ServiceClients\GenerateServiceClients.cmd" />
     
    185216      <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project>
    186217      <Name>HeuristicLab.Data-3.3</Name>
     218      <Private>False</Private>
    187219    </ProjectReference>
    188220    <ProjectReference Include="..\..\HeuristicLab.Hive\3.3\HeuristicLab.Hive-3.3.csproj">
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs

    r6976 r7215  
    7979        resources = new ItemList<Resource>();
    8080
    81         ServiceLocator.Instance.CallHiveService(service => {
     81        HiveServiceLocator.Instance.CallHiveService(service => {
    8282          service.GetSlaveGroups().ForEach(g => resources.Add(g));
    8383          service.GetSlaves().ForEach(s => resources.Add(s));
     
    101101          downtimes = new ItemList<Downtime>();
    102102
    103           ServiceLocator.Instance.CallHiveService(service => {
     103          HiveServiceLocator.Instance.CallHiveService(service => {
    104104            service.GetDowntimesForResource(downtimeForResourceId).ForEach(d => downtimes.Add(d));
    105105          });
     
    119119      if (item.Id == Guid.Empty) {
    120120        if (item is SlaveGroup) {
    121           item.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddSlaveGroup((SlaveGroup)item));
     121          item.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddSlaveGroup((SlaveGroup)item));
    122122        }
    123123        if (item is Slave) {
    124           item.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddSlave((Slave)item));
     124          item.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddSlave((Slave)item));
    125125        }
    126126        if (item is Downtime) {
    127           item.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddDowntime((Downtime)item));
     127          item.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddDowntime((Downtime)item));
    128128        }
    129129      } else {
    130130        if (item is SlaveGroup) {
    131           ServiceLocator.Instance.CallHiveService((s) => s.UpdateSlaveGroup((SlaveGroup)item));
     131          HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateSlaveGroup((SlaveGroup)item));
    132132        }
    133133        if (item is Slave) {
    134           ServiceLocator.Instance.CallHiveService((s) => s.UpdateSlave((Slave)item));
     134          HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateSlave((Slave)item));
    135135        }
    136136        if (item is Downtime) {
    137           ServiceLocator.Instance.CallHiveService((s) => s.UpdateDowntime((Downtime)item));
     137          HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateDowntime((Downtime)item));
    138138        }
    139139      }
     
    144144    public static void Delete(IHiveItem item) {
    145145      if (item is SlaveGroup) {
    146         ServiceLocator.Instance.CallHiveService((s) => s.DeleteSlaveGroup(item.Id));
     146        HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteSlaveGroup(item.Id));
    147147      } else if (item is Slave) {
    148         ServiceLocator.Instance.CallHiveService((s) => s.DeleteSlave(item.Id));
     148        HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteSlave(item.Id));
    149149      } else if (item is Downtime) {
    150         ServiceLocator.Instance.CallHiveService((s) => s.DeleteDowntime(item.Id));
     150        HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteDowntime(item.Id));
    151151      }
    152152    }
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r6976 r7215  
    8282
    8383      try {
    84         this.IsAllowedPrivileged = ServiceLocator.Instance.CallHiveService((s) => s.IsAllowedPrivileged());
     84        this.IsAllowedPrivileged = HiveServiceLocator.Instance.CallHiveService((s) => s.IsAllowedPrivileged());
    8585
    8686        var oldJobs = jobs ?? new ItemCollection<RefreshableJob>();
    8787        jobs = new HiveItemCollection<RefreshableJob>();
    88         var jobsLoaded = ServiceLocator.Instance.CallHiveService<IEnumerable<Job>>(s => s.GetJobs());
     88        var jobsLoaded = HiveServiceLocator.Instance.CallHiveService<IEnumerable<Job>>(s => s.GetJobs());
    8989
    9090        foreach (var j in jobsLoaded) {
     
    113113        jobs = null;
    114114        throw;
    115       }
    116       finally {
     115      } finally {
    117116        OnRefreshed();
    118117      }
     
    143142        if (item is JobPermission) {
    144143          var hep = (JobPermission)item;
    145           hep.GrantedUserId = ServiceLocator.Instance.CallHiveService((s) => s.GetUserIdByUsername(hep.GrantedUserName));
     144          hep.GrantedUserId = HiveServiceLocator.Instance.CallHiveService((s) => s.GetUserIdByUsername(hep.GrantedUserName));
    146145          if (hep.GrantedUserId == Guid.Empty) {
    147146            throw new ArgumentException(string.Format("The user {0} was not found.", hep.GrantedUserName));
    148147          }
    149           ServiceLocator.Instance.CallHiveService((s) => s.GrantPermission(hep.JobId, hep.GrantedUserId, hep.Permission));
     148          HiveServiceLocator.Instance.CallHiveService((s) => s.GrantPermission(hep.JobId, hep.GrantedUserId, hep.Permission));
    150149        }
    151150      } else {
    152151        if (item is Job)
    153           ServiceLocator.Instance.CallHiveService(s => s.UpdateJob((Job)item));
     152          HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJob((Job)item));
    154153      }
    155154    }
     
    173172    #region Delete
    174173    public static void Delete(IHiveItem item) {
    175       if (item.Id == Guid.Empty)
     174      if (item.Id == Guid.Empty && item.GetType() != typeof(JobPermission))
    176175        return;
    177176
    178177      if (item is Job)
    179         ServiceLocator.Instance.CallHiveService(s => s.DeleteJob(item.Id));
    180       if (item is RefreshableJob)
    181         ServiceLocator.Instance.CallHiveService(s => s.DeleteJob(item.Id));
     178        HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(item.Id));
     179      if (item is RefreshableJob) {
     180        RefreshableJob job = (RefreshableJob)item;
     181        if (job.RefreshAutomatically) {
     182          job.StopResultPolling();
     183        }
     184        HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(item.Id));
     185      }
    182186      if (item is JobPermission) {
    183187        var hep = (JobPermission)item;
    184         ServiceLocator.Instance.CallHiveService(s => s.RevokePermission(hep.JobId, hep.GrantedUserId));
     188        HiveServiceLocator.Instance.CallHiveService(s => s.RevokePermission(hep.JobId, hep.GrantedUserId));
    185189      }
    186190      item.Id = Guid.Empty;
     
    216220
    217221    public static void PauseJob(RefreshableJob refreshableJob) {
    218       ServiceLocator.Instance.CallHiveService(service => {
     222      HiveServiceLocator.Instance.CallHiveService(service => {
    219223        foreach (HiveTask task in refreshableJob.GetAllHiveTasks()) {
    220224          if (task.Task.State != TaskState.Finished && task.Task.State != TaskState.Aborted && task.Task.State != TaskState.Failed)
     
    226230
    227231    public static void StopJob(RefreshableJob refreshableJob) {
    228       ServiceLocator.Instance.CallHiveService(service => {
     232      HiveServiceLocator.Instance.CallHiveService(service => {
    229233        foreach (HiveTask task in refreshableJob.GetAllHiveTasks()) {
    230234          if (task.Task.State != TaskState.Finished && task.Task.State != TaskState.Aborted && task.Task.State != TaskState.Failed)
     
    232236        }
    233237      });
    234       // execution state does not need to be set. it will be set to Stopped, when all jobs have been downloaded
     238      refreshableJob.ExecutionState = ExecutionState.Stopped;
     239    }
     240
     241    public static void ResumeJob(RefreshableJob refreshableJob) {
     242      HiveServiceLocator.Instance.CallHiveService(service => {
     243        foreach (HiveTask task in refreshableJob.GetAllHiveTasks()) {
     244          if (task.Task.State == TaskState.Paused) {
     245            service.RestartTask(task.Task.Id);
     246          }
     247        }
     248      });
     249      refreshableJob.ExecutionState = ExecutionState.Started;
    235250    }
    236251
     
    247262        var resourceIds = new List<Guid>();
    248263        foreach (var resourceName in resourceNames) {
    249           Guid resourceId = ServiceLocator.Instance.CallHiveService((s) => s.GetResourceId(resourceName));
     264          Guid resourceId = HiveServiceLocator.Instance.CallHiveService((s) => s.GetResourceId(resourceName));
    250265          if (resourceId == Guid.Empty) {
    251266            throw new ResourceNotFoundException(string.Format("Could not find the resource '{0}'", resourceName));
     
    260275        // upload Job
    261276        refreshableJob.Progress.Status = "Uploading Job...";
    262         refreshableJob.Job.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddJob(refreshableJob.Job));
     277        refreshableJob.Job.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddJob(refreshableJob.Job));
    263278        bool isPrivileged = refreshableJob.Job.IsPrivileged;
    264         refreshableJob.Job = ServiceLocator.Instance.CallHiveService((s) => s.GetJob(refreshableJob.Job.Id)); // update owner and permissions
     279        refreshableJob.Job = HiveServiceLocator.Instance.CallHiveService((s) => s.GetJob(refreshableJob.Job.Id)); // update owner and permissions
    265280        refreshableJob.Job.IsPrivileged = isPrivileged;
    266281        cancellationToken.ThrowIfCancellationRequested();
     
    272287        // upload plugins
    273288        refreshableJob.Progress.Status = "Uploading plugins...";
    274         this.OnlinePlugins = ServiceLocator.Instance.CallHiveService((s) => s.GetPlugins());
     289        this.OnlinePlugins = HiveServiceLocator.Instance.CallHiveService((s) => s.GetPlugins());
    275290        this.AlreadyUploadedPlugins = new List<Plugin>();
    276         Plugin configFilePlugin = ServiceLocator.Instance.CallHiveService((s) => UploadConfigurationFile(s, onlinePlugins));
     291        Plugin configFilePlugin = HiveServiceLocator.Instance.CallHiveService((s) => UploadConfigurationFile(s, onlinePlugins));
    277292        this.alreadyUploadedPlugins.Add(configFilePlugin);
    278293        cancellationToken.ThrowIfCancellationRequested();
     
    297312        }
    298313        refreshableJob.Job.Modified = false;
    299       }
    300       finally {
     314      } finally {
    301315        refreshableJob.IsProgressing = false;
    302316      }
     
    359373          if (!cancellationToken.IsCancellationRequested) {
    360374            lock (pluginLocker) {
    361               ServiceLocator.Instance.CallHiveService((s) => hiveTask.Task.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins));
     375              HiveServiceLocator.Instance.CallHiveService((s) => hiveTask.Task.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins));
    362376            }
    363377          }
    364         }, -1, "Failed to upload plugins");
     378        }, Settings.Default.MaxRepeatServiceCalls, "Failed to upload plugins");
    365379        cancellationToken.ThrowIfCancellationRequested();
    366380        hiveTask.Task.PluginsNeededIds.Add(configPluginId);
     
    372386          if (!cancellationToken.IsCancellationRequested) {
    373387            if (parentHiveTask != null) {
    374               hiveTask.Task.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddChildTask(parentHiveTask.Task.Id, hiveTask.Task, taskData));
     388              hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddChildTask(parentHiveTask.Task.Id, hiveTask.Task, taskData));
    375389            } else {
    376               hiveTask.Task.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddTask(hiveTask.Task, taskData, groups.ToList()));
     390              hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddTask(hiveTask.Task, taskData, groups.ToList()));
    377391            }
    378392          }
    379         }, 50, "Failed to add task", log);
     393        }, Settings.Default.MaxRepeatServiceCalls, "Failed to add task", log);
    380394        cancellationToken.ThrowIfCancellationRequested();
    381395
     
    400414          if (!ae.InnerExceptions.All(e => e is TaskCanceledException)) throw ae; // for some reason the WaitAll throws a AggregateException containg a TaskCanceledException. i don't know where it comes from, however the tasks all finish properly, so for now just ignore it
    401415        }
    402       }
    403       finally {
     416      } finally {
    404417        if (!semaphoreReleased) taskUploadSemaphore.Release();
    405418      }
     
    420433        // fetch all task objects to create the full tree of tree of HiveTask objects
    421434        refreshableJob.Progress.Status = "Downloading list of tasks...";
    422         allTasks = ServiceLocator.Instance.CallHiveService(s => s.GetLightweightJobTasks(hiveExperiment.Id));
     435        allTasks = HiveServiceLocator.Instance.CallHiveService(s => s.GetLightweightJobTasks(hiveExperiment.Id));
    423436        totalJobCount = allTasks.Count();
    424437
     438        refreshableJob.Progress.Status = "Downloading tasks...";
    425439        TaskDownloader downloader = new TaskDownloader(allTasks.Select(x => x.Id));
    426440        downloader.StartAsync();
     
    436450        }
    437451        IDictionary<Guid, HiveTask> allHiveTasks = downloader.Results;
    438 
    439         refreshableJob.HiveTasks = new ItemCollection<HiveTask>(allHiveTasks.Values.Where(x => !x.Task.ParentTaskId.HasValue));
    440 
     452        var parents = allHiveTasks.Values.Where(x => !x.Task.ParentTaskId.HasValue);
     453
     454        refreshableJob.Progress.Status = "Downloading/deserializing complete. Displaying tasks...";
     455        // build child-task tree
     456        foreach (HiveTask hiveTask in parents) {
     457          BuildHiveJobTree(hiveTask, allTasks, allHiveTasks);
     458        }
     459
     460        refreshableJob.HiveTasks = new ItemCollection<HiveTask>(parents);
    441461        if (refreshableJob.IsFinished()) {
    442462          refreshableJob.ExecutionState = Core.ExecutionState.Stopped;
     
    444464          refreshableJob.ExecutionState = Core.ExecutionState.Started;
    445465        }
    446 
    447         // build child-task tree
    448         foreach (HiveTask hiveTask in refreshableJob.HiveTasks) {
    449           BuildHiveJobTree(hiveTask, allTasks, allHiveTasks);
    450         }
    451 
    452466        refreshableJob.OnLoaded();
    453       }
    454       finally {
     467      } finally {
    455468        refreshableJob.IsProgressing = false;
    456469      }
    457470    }
    458471
    459     private static void BuildHiveJobTree(HiveTask parentHiveJob, IEnumerable<LightweightTask> allJobs, IDictionary<Guid, HiveTask> allHiveJobs) {
    460       IEnumerable<LightweightTask> childTasks = from job in allJobs
    461                                                 where job.ParentTaskId.HasValue && job.ParentTaskId.Value == parentHiveJob.Task.Id
     472    private static void BuildHiveJobTree(HiveTask parentHiveTask, IEnumerable<LightweightTask> allTasks, IDictionary<Guid, HiveTask> allHiveTasks) {
     473      IEnumerable<LightweightTask> childTasks = from job in allTasks
     474                                                where job.ParentTaskId.HasValue && job.ParentTaskId.Value == parentHiveTask.Task.Id
    462475                                                orderby job.DateCreated ascending
    463476                                                select job;
    464477      foreach (LightweightTask task in childTasks) {
    465         HiveTask childHiveTask = allHiveJobs[task.Id];
    466         parentHiveJob.AddChildHiveJob(childHiveTask);
    467         BuildHiveJobTree(childHiveTask, allJobs, allHiveJobs);
     478        HiveTask childHiveTask = allHiveTasks[task.Id];
     479        parentHiveTask.AddChildHiveTask(childHiveTask);
     480        BuildHiveJobTree(childHiveTask, allTasks, allHiveTasks);
    468481      }
    469482    }
     
    482495
    483496    public static ItemTask LoadItemJob(Guid jobId) {
    484       TaskData taskData = ServiceLocator.Instance.CallHiveService(s => s.GetTaskData(jobId));
     497      TaskData taskData = HiveServiceLocator.Instance.CallHiveService(s => s.GetTaskData(jobId));
    485498      try {
    486499        return PersistenceUtil.Deserialize<ItemTask>(taskData.Data);
     
    507520
    508521    public static HiveItemCollection<JobPermission> GetJobPermissions(Guid jobId) {
    509       return ServiceLocator.Instance.CallHiveService((service) => {
     522      return HiveServiceLocator.Instance.CallHiveService((service) => {
    510523        IEnumerable<JobPermission> jps = service.GetJobPermissions(jobId);
    511524        foreach (var hep in jps) {
    512           hep.GrantedUserName = service.GetUsernameByUserId(hep.GrantedUserId);
     525          hep.UnmodifiedGrantedUserNameUpdate(service.GetUsernameByUserId(hep.GrantedUserId));
    513526        }
    514527        return new HiveItemCollection<JobPermission>(jps);
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/HiveJobs/EngineHiveTask.cs

    r6976 r7215  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Linq;
    2524using HeuristicLab.Common;
    2625using HeuristicLab.Core;
     
    5554      IEnumerable<Type> usedTypes;
    5655
    57       // clone operation and remove unnecessary scopes; don't do this earlier to avoid memory problems
    58       //lock (locker) {
    59         ((IAtomicOperation)ItemTask.InitialOperation).Scope.Parent = parentScopeClone;
    60         ItemTask.InitialOperation = (IOperation)ItemTask.InitialOperation.Clone();
    61         ((IAtomicOperation)ItemTask.InitialOperation).Scope.ClearParentScopes();
    62         jobData.Data = PersistenceUtil.Serialize(ItemTask, out usedTypes);
    63       //}
    64 
    65       // add type objects from object graph to work around ticket #1527
    66       var typeObjects = ItemTask.GetObjectGraphObjects().OfType<Type>();
    67       usedTypes = new List<Type>(usedTypes).Union(typeObjects);
     56      // clone operation and remove unnecessary scopes; don't do this earlier to avoid memory problems     
     57      ((IAtomicOperation)ItemTask.InitialOperation).Scope.Parent = parentScopeClone;
     58      ItemTask.InitialOperation = (IOperation)ItemTask.InitialOperation.Clone();
     59      ((IAtomicOperation)ItemTask.InitialOperation).Scope.ClearParentScopes();
     60      jobData.Data = PersistenceUtil.Serialize(ItemTask, out usedTypes);
    6861
    6962      PluginUtil.CollectDeclaringPlugins(plugins, usedTypes);
    70      
    7163      return jobData;
    7264    }
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/HiveJobs/HiveTask.cs

    r6976 r7215  
    7171          OnItemImageChanged();
    7272        }
    73 
    7473      }
    7574    }
     
    121120              hiveJob.IsControllable = value;
    122121            }
    123           }
    124           finally {
     122          } finally {
    125123            childHiveTasksLock.ExitReadLock();
    126124          }
     
    136134        try {
    137135          return childHiveTasks.AsReadOnly();
    138         }
    139         finally { childHiveTasksLock.ExitReadLock(); }
     136        } finally { childHiveTasksLock.ExitReadLock(); }
    140137      }
    141138    }
     
    145142
    146143    public StateLogList StateLog {
    147       get { return new StateLogList(this.task.StateLog); }
     144      get {
     145        var list = new StateLogList(this.task.StateLog);
     146        list.ForEach(s => { s.TaskName = itemTask.Name; });
     147        return list;
     148      }
    148149    }
    149150
     
    153154
    154155    #region Constructors and Cloning
     156    [StorableConstructor]
     157    protected HiveTask(bool deserializing) { }
     158
    155159    public HiveTask() {
    156       this.Task = new Task() { CoresNeeded = 1, MemoryNeeded = 0 };
     160      this.Task = new Task() { CoresNeeded = 1, MemoryNeeded = 128 };
    157161      task.State = TaskState.Offline;
    158162      this.childHiveTasks = new ItemList<HiveTask>();
     
    189193      try {
    190194        this.childHiveTasks = cloner.Clone(original.childHiveTasks);
    191       }
    192       finally { original.childHiveTasksLock.ExitReadLock(); }
     195      } finally { original.childHiveTasksLock.ExitReadLock(); }
    193196      this.syncTasksWithOptimizers = original.syncTasksWithOptimizers;
    194197      this.isFinishedTaskDownloaded = original.isFinishedTaskDownloaded;
     
    235238    }
    236239
    237     public virtual void AddChildHiveJob(HiveTask hiveJob) {
     240    public virtual void AddChildHiveTask(HiveTask hiveTask) {
    238241      childHiveTasksLock.EnterWriteLock();
    239242      try {
    240         this.childHiveTasks.Add(hiveJob);
    241       }
    242       finally { childHiveTasksLock.ExitWriteLock(); }
     243        this.childHiveTasks.Add(hiveTask);
     244      } finally { childHiveTasksLock.ExitWriteLock(); }
    243245    }
    244246
     
    337339        IsFinishedTaskDownloaded = false;
    338340      }
     341      if (e.PropertyName == "Priority" && Task != null) {
     342        foreach (var task in childHiveTasks) {
     343          task.Task.Priority = Task.Priority;
     344        }
     345      }
    339346    }
    340347    #endregion
     
    352359        }
    353360        return jobs;
    354       }
    355       finally { childHiveTasksLock.ExitReadLock(); }
     361      } finally { childHiveTasksLock.ExitReadLock(); }
    356362    }
    357363
     
    367373        }
    368374        return null;
    369       }
    370       finally { childHiveTasksLock.ExitWriteLock(); }
     375      } finally { childHiveTasksLock.ExitWriteLock(); }
    371376    }
    372377
     
    385390              return result;
    386391          }
    387         }
    388         finally { childHiveTasksLock.ExitReadLock(); }
     392        } finally { childHiveTasksLock.ExitReadLock(); }
    389393      }
    390394      return null;
     
    401405          child.RemoveByTaskId(jobId);
    402406        }
    403       }
    404       finally { childHiveTasksLock.ExitWriteLock(); }
     407      } finally { childHiveTasksLock.ExitWriteLock(); }
    405408    }
    406409
     
    453456        try {
    454457          foreach (var child in childHiveTasks) {
    455             ServiceLocator.Instance.CallHiveService(s => s.PauseTask(child.task.Id));
     458            HiveServiceLocator.Instance.CallHiveService(s => s.PauseTask(child.task.Id));
    456459          }
    457         }
    458         finally { childHiveTasksLock.ExitReadLock(); }
     460        } finally { childHiveTasksLock.ExitReadLock(); }
    459461      } else {
    460         ServiceLocator.Instance.CallHiveService(s => s.PauseTask(this.task.Id));
     462        HiveServiceLocator.Instance.CallHiveService(s => s.PauseTask(this.task.Id));
    461463      }
    462464    }
     
    467469        try {
    468470          foreach (var child in childHiveTasks) {
    469             ServiceLocator.Instance.CallHiveService(s => s.StopTask(child.task.Id));
     471            HiveServiceLocator.Instance.CallHiveService(s => s.StopTask(child.task.Id));
    470472          }
    471         }
    472         finally { childHiveTasksLock.ExitReadLock(); }
     473        } finally { childHiveTasksLock.ExitReadLock(); }
    473474      } else {
    474         ServiceLocator.Instance.CallHiveService(s => s.StopTask(this.task.Id));
     475        HiveServiceLocator.Instance.CallHiveService(s => s.StopTask(this.task.Id));
    475476      }
    476477    }
    477478
    478479    public void Restart() {
    479       ServiceLocator.Instance.CallHiveService(service => {
     480      HiveServiceLocator.Instance.CallHiveService(service => {
    480481        TaskData taskData = new TaskData();
    481482        taskData.TaskId = this.task.Id;
     
    515516    #region Constructors and Cloning
    516517    public HiveTask() : base() { }
     518    [StorableConstructor]
     519    protected HiveTask(bool deserializing) { }
    517520    public HiveTask(T itemJob) : base(itemJob, true) { }
    518     protected HiveTask(HiveTask original, Cloner cloner)
     521    protected HiveTask(HiveTask<T> original, Cloner cloner)
    519522      : base(original, cloner) {
    520523    }
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/HiveJobs/OptimizerHiveTask.cs

    r6976 r7215  
    6565            Optimization.Experiment experiment = (Optimization.Experiment)ItemTask.Item;
    6666            foreach (IOptimizer childOpt in experiment.Optimizers) {
    67               this.childHiveTasks.Add(new OptimizerHiveTask(childOpt));
     67              var optimizerHiveTask = new OptimizerHiveTask(childOpt);
     68              optimizerHiveTask.Task.Priority = Task.Priority; //inherit priority from parent
     69              this.childHiveTasks.Add(optimizerHiveTask);
    6870            }
    6971          } else if (ItemTask.Item is Optimization.BatchRun) {
     
    7173            if (batchRun.Optimizer != null) {
    7274              while (this.childHiveTasks.Count < batchRun.Repetitions) {
    73                 this.childHiveTasks.Add(new OptimizerHiveTask(batchRun.Optimizer));
     75                var optimizerHiveTask = new OptimizerHiveTask(batchRun.Optimizer);
     76                optimizerHiveTask.Task.Priority = Task.Priority;
     77                this.childHiveTasks.Add(optimizerHiveTask);
    7478              }
    7579              while (this.childHiveTasks.Count > batchRun.Repetitions) {
     
    136140            }
    137141          }
    138         }
    139         finally { childHiveTasksLock.ExitWriteLock(); }
     142        } finally { childHiveTasksLock.ExitWriteLock(); }
    140143      }
    141144    }
     
    152155            }
    153156          }
    154         }
    155         finally { childHiveTasksLock.ExitWriteLock(); }
     157        } finally { childHiveTasksLock.ExitWriteLock(); }
    156158      }
    157159    }
     
    163165            this.childHiveTasks.Remove(this.GetChildByOptimizer(item.Value));
    164166          }
    165         }
    166         finally { childHiveTasksLock.ExitWriteLock(); }
     167        } finally { childHiveTasksLock.ExitWriteLock(); }
    167168      }
    168169    }
     
    174175            this.childHiveTasks.Remove(this.GetChildByOptimizer(item.Value));
    175176          }
    176         }
    177         finally { childHiveTasksLock.ExitWriteLock(); }
     177        } finally { childHiveTasksLock.ExitWriteLock(); }
    178178      }
    179179    }
     
    205205          child.syncTasksWithOptimizers = true;
    206206        }
    207       }
    208       finally { childHiveTasksLock.ExitReadLock(); }
     207      } finally { childHiveTasksLock.ExitReadLock(); }
    209208      syncTasksWithOptimizers = true;
    210209    }
     
    268267          child.SetIndexInParentOptimizerList(this);
    269268        }
    270       }
    271       finally { childHiveTasksLock.ExitReadLock(); }
    272     }
    273 
    274     public override void AddChildHiveJob(HiveTask hiveJob) {
    275       base.AddChildHiveJob(hiveJob);
    276       var optimizerHiveJob = (OptimizerHiveTask)hiveJob;
     269      } finally { childHiveTasksLock.ExitReadLock(); }
     270    }
     271
     272    public override void AddChildHiveTask(HiveTask hiveTask) {
     273      base.AddChildHiveTask(hiveTask);
     274      var optimizerHiveJob = (OptimizerHiveTask)hiveTask;
    277275      syncTasksWithOptimizers = false;
    278276      if (this.ItemTask != null && optimizerHiveJob.ItemTask != null) {
     
    339337        }
    340338        return null;
    341       }
    342       finally { childHiveTasksLock.ExitReadLock(); }
     339      } finally { childHiveTasksLock.ExitReadLock(); }
    343340    }
    344341
     
    351348        }
    352349        return null;
    353       }
    354       finally { childHiveTasksLock.ExitReadLock(); }
     350      } finally { childHiveTasksLock.ExitReadLock(); }
    355351    }
    356352
     
    362358      int idx = run.Name.IndexOf("Run ") + 4;
    363359
    364       if (idx == -1 || runs.Count == 0)
     360      if (idx == 3 || runs.Count == 0)
    365361        return run.Name;
    366362
     
    379375    private static int GetRunNumber(string runName) {
    380376      int idx = runName.IndexOf("Run ") + 4;
    381       if (idx == -1) {
     377      if (idx == 3) {
    382378        return 0;
    383379      } else {
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/JobResultPoller.cs

    r6976 r7215  
    2727namespace HeuristicLab.Clients.Hive {
    2828  public class JobResultPoller {
    29     private bool stopRequested { get; set; }
     29    private bool stopRequested;
    3030    private AutoResetEvent waitHandle;
    3131    private Thread thread;
     
    9696        catch (Exception e) {
    9797          OnExceptionOccured(e);
    98         }
    99         finally {
     98        } finally {
    10099          IsPolling = false;
    101100        }
     
    106105
    107106    public IEnumerable<LightweightTask> FetchJobResults() {
    108       return ServiceLocator.Instance.CallHiveService(service => {
     107      return HiveServiceLocator.Instance.CallHiveService(service => {
    109108        var responses = new List<LightweightTask>();
    110109        responses.AddRange(service.GetLightweightJobTasks(jobId));
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/RefreshableJob.cs

    r6976 r7215  
    5151          OnJobChanged();
    5252          OnToStringChanged(this, EventArgs.Empty);
     53          job_ItemImageChanged(this, EventArgs.Empty);
    5354        }
    5455      }
     
    194195      this.Job = new Job();
    195196      this.log = new ThreadSafeLog();
    196       this.jobDownloader = new ConcurrentTaskDownloader<ItemTask>(2, 2);
     197      this.jobDownloader = new ConcurrentTaskDownloader<ItemTask>(Settings.Default.MaxParallelDownloads, Settings.Default.MaxParallelDownloads);
    197198      this.jobDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobDownloader_ExceptionOccured);
    198199      this.HiveTasks = new ItemCollection<HiveTask>();
     
    202203      this.Job = hiveExperiment;
    203204      this.log = new ThreadSafeLog();
    204       this.jobDownloader = new ConcurrentTaskDownloader<ItemTask>(2, 2);
     205      this.jobDownloader = new ConcurrentTaskDownloader<ItemTask>(Settings.Default.MaxParallelDownloads, Settings.Default.MaxParallelDownloads);
    205206      this.jobDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobDownloader_ExceptionOccured);
    206207      this.HiveTasks = new ItemCollection<HiveTask>();
     
    208209    protected RefreshableJob(RefreshableJob original, Cloner cloner) {
    209210      cloner.RegisterClonedObject(original, this);
    210       this.Job = original.Job;
     211      this.Job = cloner.Clone(original.Job);
    211212      this.IsControllable = original.IsControllable;
    212213      this.log = cloner.Clone(original.log);
    213214      this.RefreshAutomatically = false; // do not start results polling automatically
    214       this.jobDownloader = new ConcurrentTaskDownloader<ItemTask>(2, 2);
     215      this.jobDownloader = new ConcurrentTaskDownloader<ItemTask>(Settings.Default.MaxParallelDownloads, Settings.Default.MaxParallelDownloads);
    215216      this.jobDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobDownloader_ExceptionOccured);
    216217      this.HiveTasks = cloner.Clone(original.HiveTasks);
     
    230231    public void StartResultPolling() {
    231232      if (jobResultPoller == null) {
    232         jobResultPoller = new JobResultPoller(job.Id, /*ApplicationConstants.ResultPollingInterval*/new TimeSpan(0, 0, 5)); //TODO: find a better place for ApplicationConstants
     233        jobResultPoller = new JobResultPoller(job.Id, Settings.Default.ResultPollingInterval);
    233234        RegisterResultPollingEvents();
    234235        jobResultPoller.AutoResumeOnException = true;
     
    276277            log.LogMessage(string.Format("Downloading task {0}", lightweightTask.Id));
    277278            hiveTask.IsDownloading = true;
    278             jobDownloader.DownloadTask(hiveTask.Task, (localJob, itemJob) => {
     279            jobDownloader.DownloadTaskData(hiveTask.Task, (localJob, itemJob) => {
    279280              log.LogMessage(string.Format("Finished downloading task {0}", localJob.Id));
    280281              HiveTask localHiveTask = GetHiveJobById(localJob.Id);
     
    533534    public virtual void OnLoaded() {
    534535      this.UpdateTotalExecutionTime();
     536      this.OnStateLogListChanged();
    535537
    536538      if (this.ExecutionState != ExecutionState.Stopped) {
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/ServiceClients/JobPermission.cs

    r6976 r7215  
    3737    }
    3838
     39    public void UnmodifiedGrantedUserNameUpdate(string userName) {
     40      grantedUserName = userName;
     41    }
     42
    3943    public JobPermission() {
    4044      this.Permission = Permission.Read;
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/ServiceClients/PluginData.cs

    r6976 r7215  
    3131    protected PluginData(PluginData original, Cloner cloner)
    3232      : base(original, cloner) {
    33       if (original.Data != null)
     33      if (original.Data != null) {
    3434        this.Data = new byte[original.Data.Length];
    35       Array.Copy(original.Data, this.Data, original.Data.Length);
     35        Array.Copy(original.Data, this.Data, original.Data.Length);
     36      }
    3637      this.FileName = original.FileName;
    3738      this.PluginId = original.PluginId;
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/ServiceClients/StateLog.cs

    r6976 r7215  
    3838    }
    3939
     40    public string TaskName { get; set; }
     41
    4042    public override IDeepCloneable Clone(Cloner cloner) {
    4143      return new StateLog(this, cloner);
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/ServiceClients/Task.cs

    r6976 r7215  
    3434      this.CoresNeeded = original.CoresNeeded;
    3535      this.MemoryNeeded = original.MemoryNeeded;
    36       this.PluginsNeededIds = new List<Guid>(original.PluginsNeededIds);
     36      if (original.PluginsNeededIds != null) {
     37        this.PluginsNeededIds = new List<Guid>(original.PluginsNeededIds);
     38      }
    3739      this.LastHeartbeat = original.LastHeartbeat;
    3840      this.IsParentTask = original.IsParentTask;
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/Settings.Designer.cs

    r6976 r7215  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:4.0.30319.235
     4//     Runtime Version:4.0.30319.239
    55//
    66//     Changes to this file may cause incorrect behavior and will be lost if
     
    4141            }
    4242        }
     43       
     44        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     45        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     46        [global::System.Configuration.DefaultSettingValueAttribute("00:00:20")]
     47        public global::System.TimeSpan ResultPollingInterval {
     48            get {
     49                return ((global::System.TimeSpan)(this["ResultPollingInterval"]));
     50            }
     51        }
     52       
     53        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     54        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     55        [global::System.Configuration.DefaultSettingValueAttribute("2")]
     56        public int MaxParallelDownloads {
     57            get {
     58                return ((int)(this["MaxParallelDownloads"]));
     59            }
     60        }
     61       
     62        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     63        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     64        [global::System.Configuration.DefaultSettingValueAttribute("5")]
     65        public int MaxRepeatServiceCalls {
     66            get {
     67                return ((int)(this["MaxRepeatServiceCalls"]));
     68            }
     69        }
    4370    }
    4471}
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/Settings.settings

    r6976 r7215  
    99      <Value Profile="(Default)">HeuristicLab 3.3.exe</Value>
    1010    </Setting>
     11    <Setting Name="ResultPollingInterval" Type="System.TimeSpan" Scope="Application">
     12      <Value Profile="(Default)">00:00:20</Value>
     13    </Setting>
     14    <Setting Name="MaxParallelDownloads" Type="System.Int32" Scope="Application">
     15      <Value Profile="(Default)">2</Value>
     16    </Setting>
     17    <Setting Name="MaxRepeatServiceCalls" Type="System.Int32" Scope="Application">
     18      <Value Profile="(Default)">5</Value>
     19    </Setting>
    1120  </Settings>
    1221</SettingsFile>
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/TaskDownloader.cs

    r6976 r7215  
    2525using HeuristicLab.Clients.Hive.Jobs;
    2626using HeuristicLab.Common;
     27using System.Threading;
    2728
    2829namespace HeuristicLab.Clients.Hive {
     
    3334    private bool exceptionOccured = false;
    3435    private Exception currentException;
     36    private ReaderWriterLockSlim resultsLock = new ReaderWriterLockSlim();
    3537
    3638    public bool IsFinished {
    3739      get {
    38         return results.Count == taskIds.Count();
     40          try {       
     41              resultsLock.EnterReadLock();
     42              return results.Count == taskIds.Count();
     43          } finally { resultsLock.ExitReadLock(); }
    3944      }
    4045    }
     
    5156      }
    5257    }
    53    
     58
    5459    public int FinishedCount {
    5560      get {
    56         return results.Count;
     61            try {
     62              resultsLock.EnterReadLock();
     63              return results.Count;
     64             } finally { resultsLock.ExitReadLock(); }
    5765      }
    5866    }
     
    6068    public IDictionary<Guid, HiveTask> Results {
    6169      get {
    62         return results;
     70            try {
     71              resultsLock.EnterReadLock();
     72              return results;
     73            } finally { resultsLock.ExitReadLock(); }
    6374      }
    6475    }
     
    6677    public TaskDownloader(IEnumerable<Guid> jobIds) {
    6778      this.taskIds = jobIds;
    68       this.taskDownloader = new ConcurrentTaskDownloader<ItemTask>(2, 2);
     79      this.taskDownloader = new ConcurrentTaskDownloader<ItemTask>(Settings.Default.MaxParallelDownloads, Settings.Default.MaxParallelDownloads);
    6980      this.taskDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(taskDownloader_ExceptionOccured);
    7081      this.results = new Dictionary<Guid, HiveTask>();
    7182    }
    72    
     83
    7384    public void StartAsync() {
    7485      foreach (Guid taskId in taskIds) {
    75         Task task = ServiceLocator.Instance.CallHiveService(s => s.GetTask(taskId));
    76 
    77         taskDownloader.DownloadTask(task,
     86        taskDownloader.DownloadTaskDataAndTask(taskId,
    7887          (localJob, itemJob) => {
    7988            if (localJob != null && itemJob != null) {
     
    8594              }
    8695              hiveTask.Task = localJob;
    87               this.results.Add(localJob.Id, hiveTask);
     96              try {
     97                resultsLock.EnterWriteLock();
     98                this.results.Add(localJob.Id, hiveTask);
     99              } finally { resultsLock.ExitWriteLock(); }
    88100            }
    89101          });
    90       }     
     102      }
    91103    }
    92104
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/Tasks/ItemTask.cs

    r6976 r7215  
    150150
    151151    #region INamedItem Members
    152     public abstract bool CanChangeDescription { get; }
     152    public abstract new bool CanChangeDescription { get; }
    153153
    154     public abstract bool CanChangeName { get; }
     154    public abstract new bool CanChangeName { get; }
    155155
    156     public abstract string Description { get; set; }
     156    public abstract new string Description { get; set; }
    157157
    158     public abstract string Name { get; set; }
     158    public abstract new string Name { get; set; }
    159159    #endregion
    160160
    161161    #region Events
    162     public event EventHandler DescriptionChanged;
    163     protected virtual void OnDescriptionChanged() {
    164       var handler = DescriptionChanged;
    165       if (handler != null) handler(this, EventArgs.Empty);
    166     }
    167     public event EventHandler ItemImageChanged;
    168     protected virtual void OnItemImageChanged() {
    169       var handler = ItemImageChanged;
    170       if (handler != null) handler(this, EventArgs.Empty);
    171     }
    172     public event EventHandler ToStringChanged;
    173     protected virtual void OnToStringChanged() {
    174       var handler = ToStringChanged;
    175       if (handler != null) handler(this, EventArgs.Empty);
    176     }
    177     public event EventHandler NameChanged;
    178     protected virtual void OnNameChanged() {
    179       var handler = NameChanged;
    180       if (handler != null) handler(this, EventArgs.Empty);
    181     }
    182     public event EventHandler<CancelEventArgs<string>> NameChanging;
    183     protected virtual void OnNameChanging(string value, bool cancel) {
    184       var handler = NameChanging;
    185       if (handler != null) handler(this, new CancelEventArgs<string>(value, cancel));
    186     }
    187162    public event EventHandler ExecutionTimeChanged;
    188163    protected virtual void OnExecutionTimeChanged() {
     
    198173
    199174    #region IItem Members
    200     public virtual string ItemDescription {
     175    public virtual new string ItemDescription {
    201176      get { return item.ItemDescription; }
    202177    }
    203178
    204     public virtual Image ItemImage {
     179    public virtual new Image ItemImage
     180    {
    205181      get { return item.ItemImage; }
    206182    }
    207183
    208     public virtual string ItemName {
     184    public virtual new string ItemName
     185    {
    209186      get { return item.ItemName; }
    210187    }
    211188
    212     public virtual Version ItemVersion {
     189    public virtual new Version ItemVersion
     190    {
    213191      get { return item.ItemVersion; }
    214192    }
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/Tasks/OptimizerTask.cs

    r6976 r7215  
    142142
    143143    protected void optimizer_NameChanging(object sender, CancelEventArgs<string> e) {
    144       this.OnNameChanging(e.Value, e.Cancel);
     144      OnNameChanging(new CancelEventArgs<string>(e.Value, e.Cancel));
    145145    }
    146146
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/Util/PersistenceUtil.cs

    r6976 r7215  
    2929  public static class PersistenceUtil {
    3030    public static byte[] Serialize(object obj, out IEnumerable<Type> types) {
    31       MemoryStream memStream = new MemoryStream();
    32       XmlGenerator.Serialize(obj, memStream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, out types);
    33       byte[] jobByteArray = memStream.ToArray();
    34       memStream.Dispose();
    35       return jobByteArray;
     31      using (MemoryStream memStream = new MemoryStream()) {
     32        XmlGenerator.Serialize(obj, memStream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, out types);
     33        byte[] jobByteArray = memStream.ToArray();
     34        return jobByteArray;
     35      }
    3636    }
    3737
    3838    public static byte[] Serialize(object obj) {
    39       MemoryStream memStream = new MemoryStream();
    40       XmlGenerator.Serialize(obj, memStream);
    41       byte[] jobByteArray = memStream.ToArray();
    42       memStream.Dispose();
    43       return jobByteArray;
     39      using (MemoryStream memStream = new MemoryStream()) {
     40        XmlGenerator.Serialize(obj, memStream);
     41        byte[] jobByteArray = memStream.ToArray();
     42        return jobByteArray;
     43      }
    4444    }
    4545
    4646    public static T Deserialize<T>(byte[] sjob) {
    47       MemoryStream memStream = new MemoryStream(sjob);
    48       T job = XmlParser.Deserialize<T>(memStream);
    49       memStream.Dispose();
    50       return job;
     47      using (MemoryStream memStream = new MemoryStream(sjob)) {
     48        T job = XmlParser.Deserialize<T>(memStream);
     49        return job;
     50      }
    5151    }
    5252  }
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/app.config

    r6976 r7215  
    1414        <value>HeuristicLab 3.3.exe</value>
    1515      </setting>
     16      <setting name="ResultPollingInterval" serializeAs="String">
     17        <value>00:00:20</value>
     18      </setting>
     19      <setting name="MaxParallelDownloads" serializeAs="String">
     20        <value>2</value>
     21      </setting>
     22      <setting name="MaxRepeatServiceCalls" serializeAs="String">
     23        <value>5</value>
     24      </setting>
    1625    </HeuristicLab.Clients.Hive.Settings>
    1726  </applicationSettings>
    1827  <system.serviceModel>
     28    <behaviors>
     29      <endpointBehaviors>
     30        <behavior name="HiveBehaviorConfiguration">
     31          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
     32        </behavior>
     33      </endpointBehaviors>
     34    </behaviors>
    1935    <bindings>
    2036      <wsHttpBinding>
     
    4864    </bindings>
    4965    <client>
    50       <endpoint address="http://services.heuristiclab.com/Hive-3.3/HiveService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_Hive" contract="HeuristicLab.Clients.Hive.IHiveService" name="wsHttpBinding_IHiveService">
     66      <endpoint address="http://services.heuristiclab.com/Hive-3.3/HiveService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_Hive" contract="HeuristicLab.Clients.Hive.IHiveService" name="wsHttpBinding_IHiveService" behaviorConfiguration="HiveBehaviorConfiguration">
    5167        <identity>
    5268          <certificate encodedValue="AwAAAAEAAAAUAAAAwK1+2oAmcy/mI2P2QjyiJRh0y60gAAAAAQAAACoCAAAwggImMIIBj6ADAgECAhAIkseQ2EEhgU720qJA61gqMA0GCSqGSIb3DQEBBAUAMCQxIjAgBgNVBAMTGXNlcnZpY2VzLmhldXJpc3RpY2xhYi5jb20wHhcNMTAwNTExMTExNDAyWhcNMzkxMjMxMjM1OTU5WjAkMSIwIAYDVQQDExlzZXJ2aWNlcy5oZXVyaXN0aWNsYWIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq26Bwmwc7k+4W30qLQ2j+FInEL5BuH6opDY6CSlrtt3xQS/anrhvpbf3QghLDVINzcHkzbPmm/SguG4F85QLB6xO+tJaOvRo0iEK5g3c307vMIru7FJwk/OhplEQ5J1hbDgL3zOJlrWlgtqRVxCtVdF3XroI9BctOt1NkeKv9ewIDAQABo1kwVzBVBgNVHQEETjBMgBCjbgdYd4j5JgUuJ1Wo/GxroSYwJDEiMCAGA1UEAxMZc2VydmljZXMuaGV1cmlzdGljbGFiLmNvbYIQCJLHkNhBIYFO9tKiQOtYKjANBgkqhkiG9w0BAQQFAAOBgQAb/2xk2uQad68shSPl/uixWgvFI8WkxOTBopOLaLtDxwCeZ3mWVHdV9VnixHtThubnEBXAhYOCQSIXWtQuXFWO+gH3YyjTRJY5kTmXyuvBRTn3/so5SrQ7Rdlm9hf6E5YVX3tCjAy7ybUyaDUkQfmH5vmvgvpMzRfsJ1qhnUpJiQ=="/>
Note: See TracChangeset for help on using the changeset viewer.