- Timestamp:
- 12/20/11 13:54:57 (13 years ago)
- Location:
- branches/HeuristicLab.Hive.Azure
- Files:
-
- 6 deleted
- 22 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive.Azure
- Property svn:ignore
-
old new 4 4 *.suo 5 5 *.vsp 6 Doxygen 6 7 Google.ProtocolBuffers-0.9.1.dll 7 8 HeuristicLab 3.3.5.1.ReSharper.user 8 9 HeuristicLab 3.3.6.0.ReSharper.user 9 10 HeuristicLab.4.5.resharper.user 11 HeuristicLab.ExtLibs.6.0.ReSharper.user 10 12 HeuristicLab.resharper.user 11 13 ProtoGen.exe … … 16 18 bin 17 19 protoc.exe 18 HeuristicLab.ExtLibs.6.0.ReSharper.user19 Doxygen
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3
- Property svn:ignore
-
old new 1 1 obj 2 2 Plugin.cs 3 bin
-
- Property svn:ignore
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/ConcurrentTaskDownloader.cs
r6976 r7215 42 42 } 43 43 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); 49 50 } 50 51 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); 53 59 } 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) { 55 65 task.Exception.Flatten().Handle((e) => { return true; }); 56 66 OnExceptionOccured(task.Exception.Flatten()); 57 onFinishedAction( job, null);67 onFinishedAction(task.Result.Item1, null); 58 68 } 59 69 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) { 61 79 downloadSemaphore.WaitOne(); 62 deserializeSemaphore.WaitOne();63 80 TaskData result; 64 81 try { 65 82 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 { 69 85 downloadSemaphore.Release(); 70 86 } 71 return result;87 return new Tuple<Task, TaskData>(task, result); 72 88 } 73 89 74 protected T DeserializeTask(TaskData taskData) { 90 protected Tuple<Task, T> DeserializeTask(Tuple<Task, TaskData> taskData) { 91 deserializeSemaphore.WaitOne(); 75 92 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 { 84 98 deserializeSemaphore.Release(); 85 99 } -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/HeuristicLab.Clients.Hive-3.3.csproj
r6976 r7215 40 40 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> 41 41 <DebugSymbols>true</DebugSymbols> 42 <OutputPath> bin\x86\Debug\</OutputPath>42 <OutputPath>..\..\bin\</OutputPath> 43 43 <DefineConstants>DEBUG;TRACE</DefineConstants> 44 44 <DebugType>full</DebugType> … … 55 55 </PropertyGroup> 56 56 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> 57 <OutputPath> bin\x86\Release\</OutputPath>57 <OutputPath>..\..\bin\</OutputPath> 58 58 <DefineConstants>TRACE</DefineConstants> 59 59 <Optimize>true</Optimize> … … 69 69 <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories> 70 70 <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> 71 101 </PropertyGroup> 72 102 <ItemGroup> … … 98 128 <Compile Include="StateLogList.cs" /> 99 129 <Compile Include="StateLogListList.cs" /> 100 <None Include="app.config" /> 130 <None Include="app.config"> 131 <SubType>Designer</SubType> 132 </None> 101 133 <None Include="Plugin.cs.frame" /> 102 134 <Compile Include="Exceptions\AddTaskToHiveException.cs" /> … … 114 146 </Compile> 115 147 <Compile Include="Exceptions\ResourceNotFoundException.cs" /> 116 <Compile Include="I ServiceLocator.cs" />148 <Compile Include="IHiveServiceLocator.cs" /> 117 149 <Compile Include="Tasks\EngineTask.cs" /> 118 150 <Compile Include="Tasks\OptimizerTask.cs" /> … … 135 167 <Compile Include="ServiceClients\Heartbeat.cs" /> 136 168 <Compile Include="ServiceClients\HiveItem.cs" /> 137 <Compile Include="ServiceClients\ JobData.cs" />169 <Compile Include="ServiceClients\TaskData.cs" /> 138 170 <Compile Include="ServiceClients\Plugin.cs" /> 139 171 <Compile Include="ServiceClients\PluginData.cs" /> … … 144 176 <Compile Include="ServiceClients\Slave.cs" /> 145 177 <Compile Include="ServiceClients\LightweightTask.cs" /> 146 <Compile Include="ServiceClients\ExecutorMessageContainer.cs" />147 178 <Compile Include="ServiceClients\MessageContainer.cs" /> 148 179 <Compile Include="ServiceClients\HiveServiceClient.cs" /> 149 180 <Compile Include="ServiceClients\Task.cs" /> 150 <Compile Include=" ServiceLocator.cs" />181 <Compile Include="HiveServiceLocator.cs" /> 151 182 <None Include="HeuristicLab.snk" /> 152 183 <None Include="ServiceClients\GenerateServiceClients.cmd" /> … … 185 216 <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project> 186 217 <Name>HeuristicLab.Data-3.3</Name> 218 <Private>False</Private> 187 219 </ProjectReference> 188 220 <ProjectReference Include="..\..\HeuristicLab.Hive\3.3\HeuristicLab.Hive-3.3.csproj"> -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs
r6976 r7215 79 79 resources = new ItemList<Resource>(); 80 80 81 ServiceLocator.Instance.CallHiveService(service => {81 HiveServiceLocator.Instance.CallHiveService(service => { 82 82 service.GetSlaveGroups().ForEach(g => resources.Add(g)); 83 83 service.GetSlaves().ForEach(s => resources.Add(s)); … … 101 101 downtimes = new ItemList<Downtime>(); 102 102 103 ServiceLocator.Instance.CallHiveService(service => {103 HiveServiceLocator.Instance.CallHiveService(service => { 104 104 service.GetDowntimesForResource(downtimeForResourceId).ForEach(d => downtimes.Add(d)); 105 105 }); … … 119 119 if (item.Id == Guid.Empty) { 120 120 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)); 122 122 } 123 123 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)); 125 125 } 126 126 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)); 128 128 } 129 129 } else { 130 130 if (item is SlaveGroup) { 131 ServiceLocator.Instance.CallHiveService((s) => s.UpdateSlaveGroup((SlaveGroup)item));131 HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateSlaveGroup((SlaveGroup)item)); 132 132 } 133 133 if (item is Slave) { 134 ServiceLocator.Instance.CallHiveService((s) => s.UpdateSlave((Slave)item));134 HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateSlave((Slave)item)); 135 135 } 136 136 if (item is Downtime) { 137 ServiceLocator.Instance.CallHiveService((s) => s.UpdateDowntime((Downtime)item));137 HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateDowntime((Downtime)item)); 138 138 } 139 139 } … … 144 144 public static void Delete(IHiveItem item) { 145 145 if (item is SlaveGroup) { 146 ServiceLocator.Instance.CallHiveService((s) => s.DeleteSlaveGroup(item.Id));146 HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteSlaveGroup(item.Id)); 147 147 } else if (item is Slave) { 148 ServiceLocator.Instance.CallHiveService((s) => s.DeleteSlave(item.Id));148 HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteSlave(item.Id)); 149 149 } else if (item is Downtime) { 150 ServiceLocator.Instance.CallHiveService((s) => s.DeleteDowntime(item.Id));150 HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteDowntime(item.Id)); 151 151 } 152 152 } -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r6976 r7215 82 82 83 83 try { 84 this.IsAllowedPrivileged = ServiceLocator.Instance.CallHiveService((s) => s.IsAllowedPrivileged());84 this.IsAllowedPrivileged = HiveServiceLocator.Instance.CallHiveService((s) => s.IsAllowedPrivileged()); 85 85 86 86 var oldJobs = jobs ?? new ItemCollection<RefreshableJob>(); 87 87 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()); 89 89 90 90 foreach (var j in jobsLoaded) { … … 113 113 jobs = null; 114 114 throw; 115 } 116 finally { 115 } finally { 117 116 OnRefreshed(); 118 117 } … … 143 142 if (item is JobPermission) { 144 143 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)); 146 145 if (hep.GrantedUserId == Guid.Empty) { 147 146 throw new ArgumentException(string.Format("The user {0} was not found.", hep.GrantedUserName)); 148 147 } 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)); 150 149 } 151 150 } else { 152 151 if (item is Job) 153 ServiceLocator.Instance.CallHiveService(s => s.UpdateJob((Job)item));152 HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJob((Job)item)); 154 153 } 155 154 } … … 173 172 #region Delete 174 173 public static void Delete(IHiveItem item) { 175 if (item.Id == Guid.Empty )174 if (item.Id == Guid.Empty && item.GetType() != typeof(JobPermission)) 176 175 return; 177 176 178 177 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 } 182 186 if (item is JobPermission) { 183 187 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)); 185 189 } 186 190 item.Id = Guid.Empty; … … 216 220 217 221 public static void PauseJob(RefreshableJob refreshableJob) { 218 ServiceLocator.Instance.CallHiveService(service => {222 HiveServiceLocator.Instance.CallHiveService(service => { 219 223 foreach (HiveTask task in refreshableJob.GetAllHiveTasks()) { 220 224 if (task.Task.State != TaskState.Finished && task.Task.State != TaskState.Aborted && task.Task.State != TaskState.Failed) … … 226 230 227 231 public static void StopJob(RefreshableJob refreshableJob) { 228 ServiceLocator.Instance.CallHiveService(service => {232 HiveServiceLocator.Instance.CallHiveService(service => { 229 233 foreach (HiveTask task in refreshableJob.GetAllHiveTasks()) { 230 234 if (task.Task.State != TaskState.Finished && task.Task.State != TaskState.Aborted && task.Task.State != TaskState.Failed) … … 232 236 } 233 237 }); 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; 235 250 } 236 251 … … 247 262 var resourceIds = new List<Guid>(); 248 263 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)); 250 265 if (resourceId == Guid.Empty) { 251 266 throw new ResourceNotFoundException(string.Format("Could not find the resource '{0}'", resourceName)); … … 260 275 // upload Job 261 276 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)); 263 278 bool isPrivileged = refreshableJob.Job.IsPrivileged; 264 refreshableJob.Job = ServiceLocator.Instance.CallHiveService((s) => s.GetJob(refreshableJob.Job.Id)); // update owner and permissions279 refreshableJob.Job = HiveServiceLocator.Instance.CallHiveService((s) => s.GetJob(refreshableJob.Job.Id)); // update owner and permissions 265 280 refreshableJob.Job.IsPrivileged = isPrivileged; 266 281 cancellationToken.ThrowIfCancellationRequested(); … … 272 287 // upload plugins 273 288 refreshableJob.Progress.Status = "Uploading plugins..."; 274 this.OnlinePlugins = ServiceLocator.Instance.CallHiveService((s) => s.GetPlugins());289 this.OnlinePlugins = HiveServiceLocator.Instance.CallHiveService((s) => s.GetPlugins()); 275 290 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)); 277 292 this.alreadyUploadedPlugins.Add(configFilePlugin); 278 293 cancellationToken.ThrowIfCancellationRequested(); … … 297 312 } 298 313 refreshableJob.Job.Modified = false; 299 } 300 finally { 314 } finally { 301 315 refreshableJob.IsProgressing = false; 302 316 } … … 359 373 if (!cancellationToken.IsCancellationRequested) { 360 374 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)); 362 376 } 363 377 } 364 }, -1, "Failed to upload plugins");378 }, Settings.Default.MaxRepeatServiceCalls, "Failed to upload plugins"); 365 379 cancellationToken.ThrowIfCancellationRequested(); 366 380 hiveTask.Task.PluginsNeededIds.Add(configPluginId); … … 372 386 if (!cancellationToken.IsCancellationRequested) { 373 387 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)); 375 389 } 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())); 377 391 } 378 392 } 379 }, 50, "Failed to add task", log);393 }, Settings.Default.MaxRepeatServiceCalls, "Failed to add task", log); 380 394 cancellationToken.ThrowIfCancellationRequested(); 381 395 … … 400 414 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 401 415 } 402 } 403 finally { 416 } finally { 404 417 if (!semaphoreReleased) taskUploadSemaphore.Release(); 405 418 } … … 420 433 // fetch all task objects to create the full tree of tree of HiveTask objects 421 434 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)); 423 436 totalJobCount = allTasks.Count(); 424 437 438 refreshableJob.Progress.Status = "Downloading tasks..."; 425 439 TaskDownloader downloader = new TaskDownloader(allTasks.Select(x => x.Id)); 426 440 downloader.StartAsync(); … … 436 450 } 437 451 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); 441 461 if (refreshableJob.IsFinished()) { 442 462 refreshableJob.ExecutionState = Core.ExecutionState.Stopped; … … 444 464 refreshableJob.ExecutionState = Core.ExecutionState.Started; 445 465 } 446 447 // build child-task tree448 foreach (HiveTask hiveTask in refreshableJob.HiveTasks) {449 BuildHiveJobTree(hiveTask, allTasks, allHiveTasks);450 }451 452 466 refreshableJob.OnLoaded(); 453 } 454 finally { 467 } finally { 455 468 refreshableJob.IsProgressing = false; 456 469 } 457 470 } 458 471 459 private static void BuildHiveJobTree(HiveTask parentHive Job, IEnumerable<LightweightTask> allJobs, IDictionary<Guid, HiveTask> allHiveJobs) {460 IEnumerable<LightweightTask> childTasks = from job in all Jobs461 where job.ParentTaskId.HasValue && job.ParentTaskId.Value == parentHive Job.Task.Id472 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 462 475 orderby job.DateCreated ascending 463 476 select job; 464 477 foreach (LightweightTask task in childTasks) { 465 HiveTask childHiveTask = allHive Jobs[task.Id];466 parentHive Job.AddChildHiveJob(childHiveTask);467 BuildHiveJobTree(childHiveTask, all Jobs, allHiveJobs);478 HiveTask childHiveTask = allHiveTasks[task.Id]; 479 parentHiveTask.AddChildHiveTask(childHiveTask); 480 BuildHiveJobTree(childHiveTask, allTasks, allHiveTasks); 468 481 } 469 482 } … … 482 495 483 496 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)); 485 498 try { 486 499 return PersistenceUtil.Deserialize<ItemTask>(taskData.Data); … … 507 520 508 521 public static HiveItemCollection<JobPermission> GetJobPermissions(Guid jobId) { 509 return ServiceLocator.Instance.CallHiveService((service) => {522 return HiveServiceLocator.Instance.CallHiveService((service) => { 510 523 IEnumerable<JobPermission> jps = service.GetJobPermissions(jobId); 511 524 foreach (var hep in jps) { 512 hep. GrantedUserName = service.GetUsernameByUserId(hep.GrantedUserId);525 hep.UnmodifiedGrantedUserNameUpdate(service.GetUsernameByUserId(hep.GrantedUserId)); 513 526 } 514 527 return new HiveItemCollection<JobPermission>(jps); -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/HiveJobs/EngineHiveTask.cs
r6976 r7215 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq;25 24 using HeuristicLab.Common; 26 25 using HeuristicLab.Core; … … 55 54 IEnumerable<Type> usedTypes; 56 55 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); 68 61 69 62 PluginUtil.CollectDeclaringPlugins(plugins, usedTypes); 70 71 63 return jobData; 72 64 } -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/HiveJobs/HiveTask.cs
r6976 r7215 71 71 OnItemImageChanged(); 72 72 } 73 74 73 } 75 74 } … … 121 120 hiveJob.IsControllable = value; 122 121 } 123 } 124 finally { 122 } finally { 125 123 childHiveTasksLock.ExitReadLock(); 126 124 } … … 136 134 try { 137 135 return childHiveTasks.AsReadOnly(); 138 } 139 finally { childHiveTasksLock.ExitReadLock(); } 136 } finally { childHiveTasksLock.ExitReadLock(); } 140 137 } 141 138 } … … 145 142 146 143 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 } 148 149 } 149 150 … … 153 154 154 155 #region Constructors and Cloning 156 [StorableConstructor] 157 protected HiveTask(bool deserializing) { } 158 155 159 public HiveTask() { 156 this.Task = new Task() { CoresNeeded = 1, MemoryNeeded = 0};160 this.Task = new Task() { CoresNeeded = 1, MemoryNeeded = 128 }; 157 161 task.State = TaskState.Offline; 158 162 this.childHiveTasks = new ItemList<HiveTask>(); … … 189 193 try { 190 194 this.childHiveTasks = cloner.Clone(original.childHiveTasks); 191 } 192 finally { original.childHiveTasksLock.ExitReadLock(); } 195 } finally { original.childHiveTasksLock.ExitReadLock(); } 193 196 this.syncTasksWithOptimizers = original.syncTasksWithOptimizers; 194 197 this.isFinishedTaskDownloaded = original.isFinishedTaskDownloaded; … … 235 238 } 236 239 237 public virtual void AddChildHive Job(HiveTask hiveJob) {240 public virtual void AddChildHiveTask(HiveTask hiveTask) { 238 241 childHiveTasksLock.EnterWriteLock(); 239 242 try { 240 this.childHiveTasks.Add(hiveJob); 241 } 242 finally { childHiveTasksLock.ExitWriteLock(); } 243 this.childHiveTasks.Add(hiveTask); 244 } finally { childHiveTasksLock.ExitWriteLock(); } 243 245 } 244 246 … … 337 339 IsFinishedTaskDownloaded = false; 338 340 } 341 if (e.PropertyName == "Priority" && Task != null) { 342 foreach (var task in childHiveTasks) { 343 task.Task.Priority = Task.Priority; 344 } 345 } 339 346 } 340 347 #endregion … … 352 359 } 353 360 return jobs; 354 } 355 finally { childHiveTasksLock.ExitReadLock(); } 361 } finally { childHiveTasksLock.ExitReadLock(); } 356 362 } 357 363 … … 367 373 } 368 374 return null; 369 } 370 finally { childHiveTasksLock.ExitWriteLock(); } 375 } finally { childHiveTasksLock.ExitWriteLock(); } 371 376 } 372 377 … … 385 390 return result; 386 391 } 387 } 388 finally { childHiveTasksLock.ExitReadLock(); } 392 } finally { childHiveTasksLock.ExitReadLock(); } 389 393 } 390 394 return null; … … 401 405 child.RemoveByTaskId(jobId); 402 406 } 403 } 404 finally { childHiveTasksLock.ExitWriteLock(); } 407 } finally { childHiveTasksLock.ExitWriteLock(); } 405 408 } 406 409 … … 453 456 try { 454 457 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)); 456 459 } 457 } 458 finally { childHiveTasksLock.ExitReadLock(); } 460 } finally { childHiveTasksLock.ExitReadLock(); } 459 461 } else { 460 ServiceLocator.Instance.CallHiveService(s => s.PauseTask(this.task.Id));462 HiveServiceLocator.Instance.CallHiveService(s => s.PauseTask(this.task.Id)); 461 463 } 462 464 } … … 467 469 try { 468 470 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)); 470 472 } 471 } 472 finally { childHiveTasksLock.ExitReadLock(); } 473 } finally { childHiveTasksLock.ExitReadLock(); } 473 474 } else { 474 ServiceLocator.Instance.CallHiveService(s => s.StopTask(this.task.Id));475 HiveServiceLocator.Instance.CallHiveService(s => s.StopTask(this.task.Id)); 475 476 } 476 477 } 477 478 478 479 public void Restart() { 479 ServiceLocator.Instance.CallHiveService(service => {480 HiveServiceLocator.Instance.CallHiveService(service => { 480 481 TaskData taskData = new TaskData(); 481 482 taskData.TaskId = this.task.Id; … … 515 516 #region Constructors and Cloning 516 517 public HiveTask() : base() { } 518 [StorableConstructor] 519 protected HiveTask(bool deserializing) { } 517 520 public HiveTask(T itemJob) : base(itemJob, true) { } 518 protected HiveTask(HiveTask original, Cloner cloner)521 protected HiveTask(HiveTask<T> original, Cloner cloner) 519 522 : base(original, cloner) { 520 523 } -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/HiveJobs/OptimizerHiveTask.cs
r6976 r7215 65 65 Optimization.Experiment experiment = (Optimization.Experiment)ItemTask.Item; 66 66 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); 68 70 } 69 71 } else if (ItemTask.Item is Optimization.BatchRun) { … … 71 73 if (batchRun.Optimizer != null) { 72 74 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); 74 78 } 75 79 while (this.childHiveTasks.Count > batchRun.Repetitions) { … … 136 140 } 137 141 } 138 } 139 finally { childHiveTasksLock.ExitWriteLock(); } 142 } finally { childHiveTasksLock.ExitWriteLock(); } 140 143 } 141 144 } … … 152 155 } 153 156 } 154 } 155 finally { childHiveTasksLock.ExitWriteLock(); } 157 } finally { childHiveTasksLock.ExitWriteLock(); } 156 158 } 157 159 } … … 163 165 this.childHiveTasks.Remove(this.GetChildByOptimizer(item.Value)); 164 166 } 165 } 166 finally { childHiveTasksLock.ExitWriteLock(); } 167 } finally { childHiveTasksLock.ExitWriteLock(); } 167 168 } 168 169 } … … 174 175 this.childHiveTasks.Remove(this.GetChildByOptimizer(item.Value)); 175 176 } 176 } 177 finally { childHiveTasksLock.ExitWriteLock(); } 177 } finally { childHiveTasksLock.ExitWriteLock(); } 178 178 } 179 179 } … … 205 205 child.syncTasksWithOptimizers = true; 206 206 } 207 } 208 finally { childHiveTasksLock.ExitReadLock(); } 207 } finally { childHiveTasksLock.ExitReadLock(); } 209 208 syncTasksWithOptimizers = true; 210 209 } … … 268 267 child.SetIndexInParentOptimizerList(this); 269 268 } 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; 277 275 syncTasksWithOptimizers = false; 278 276 if (this.ItemTask != null && optimizerHiveJob.ItemTask != null) { … … 339 337 } 340 338 return null; 341 } 342 finally { childHiveTasksLock.ExitReadLock(); } 339 } finally { childHiveTasksLock.ExitReadLock(); } 343 340 } 344 341 … … 351 348 } 352 349 return null; 353 } 354 finally { childHiveTasksLock.ExitReadLock(); } 350 } finally { childHiveTasksLock.ExitReadLock(); } 355 351 } 356 352 … … 362 358 int idx = run.Name.IndexOf("Run ") + 4; 363 359 364 if (idx == -1|| runs.Count == 0)360 if (idx == 3 || runs.Count == 0) 365 361 return run.Name; 366 362 … … 379 375 private static int GetRunNumber(string runName) { 380 376 int idx = runName.IndexOf("Run ") + 4; 381 if (idx == -1) {377 if (idx == 3) { 382 378 return 0; 383 379 } else { -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/JobResultPoller.cs
r6976 r7215 27 27 namespace HeuristicLab.Clients.Hive { 28 28 public class JobResultPoller { 29 private bool stopRequested { get; set; }29 private bool stopRequested; 30 30 private AutoResetEvent waitHandle; 31 31 private Thread thread; … … 96 96 catch (Exception e) { 97 97 OnExceptionOccured(e); 98 } 99 finally { 98 } finally { 100 99 IsPolling = false; 101 100 } … … 106 105 107 106 public IEnumerable<LightweightTask> FetchJobResults() { 108 return ServiceLocator.Instance.CallHiveService(service => {107 return HiveServiceLocator.Instance.CallHiveService(service => { 109 108 var responses = new List<LightweightTask>(); 110 109 responses.AddRange(service.GetLightweightJobTasks(jobId)); -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/RefreshableJob.cs
r6976 r7215 51 51 OnJobChanged(); 52 52 OnToStringChanged(this, EventArgs.Empty); 53 job_ItemImageChanged(this, EventArgs.Empty); 53 54 } 54 55 } … … 194 195 this.Job = new Job(); 195 196 this.log = new ThreadSafeLog(); 196 this.jobDownloader = new ConcurrentTaskDownloader<ItemTask>( 2, 2);197 this.jobDownloader = new ConcurrentTaskDownloader<ItemTask>(Settings.Default.MaxParallelDownloads, Settings.Default.MaxParallelDownloads); 197 198 this.jobDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobDownloader_ExceptionOccured); 198 199 this.HiveTasks = new ItemCollection<HiveTask>(); … … 202 203 this.Job = hiveExperiment; 203 204 this.log = new ThreadSafeLog(); 204 this.jobDownloader = new ConcurrentTaskDownloader<ItemTask>( 2, 2);205 this.jobDownloader = new ConcurrentTaskDownloader<ItemTask>(Settings.Default.MaxParallelDownloads, Settings.Default.MaxParallelDownloads); 205 206 this.jobDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobDownloader_ExceptionOccured); 206 207 this.HiveTasks = new ItemCollection<HiveTask>(); … … 208 209 protected RefreshableJob(RefreshableJob original, Cloner cloner) { 209 210 cloner.RegisterClonedObject(original, this); 210 this.Job = original.Job;211 this.Job = cloner.Clone(original.Job); 211 212 this.IsControllable = original.IsControllable; 212 213 this.log = cloner.Clone(original.log); 213 214 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); 215 216 this.jobDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(jobDownloader_ExceptionOccured); 216 217 this.HiveTasks = cloner.Clone(original.HiveTasks); … … 230 231 public void StartResultPolling() { 231 232 if (jobResultPoller == null) { 232 jobResultPoller = new JobResultPoller(job.Id, /*ApplicationConstants.ResultPollingInterval*/new TimeSpan(0, 0, 5)); //TODO: find a better place for ApplicationConstants233 jobResultPoller = new JobResultPoller(job.Id, Settings.Default.ResultPollingInterval); 233 234 RegisterResultPollingEvents(); 234 235 jobResultPoller.AutoResumeOnException = true; … … 276 277 log.LogMessage(string.Format("Downloading task {0}", lightweightTask.Id)); 277 278 hiveTask.IsDownloading = true; 278 jobDownloader.DownloadTask (hiveTask.Task, (localJob, itemJob) => {279 jobDownloader.DownloadTaskData(hiveTask.Task, (localJob, itemJob) => { 279 280 log.LogMessage(string.Format("Finished downloading task {0}", localJob.Id)); 280 281 HiveTask localHiveTask = GetHiveJobById(localJob.Id); … … 533 534 public virtual void OnLoaded() { 534 535 this.UpdateTotalExecutionTime(); 536 this.OnStateLogListChanged(); 535 537 536 538 if (this.ExecutionState != ExecutionState.Stopped) { -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/ServiceClients/JobPermission.cs
r6976 r7215 37 37 } 38 38 39 public void UnmodifiedGrantedUserNameUpdate(string userName) { 40 grantedUserName = userName; 41 } 42 39 43 public JobPermission() { 40 44 this.Permission = Permission.Read; -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/ServiceClients/PluginData.cs
r6976 r7215 31 31 protected PluginData(PluginData original, Cloner cloner) 32 32 : base(original, cloner) { 33 if (original.Data != null) 33 if (original.Data != null) { 34 34 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 } 36 37 this.FileName = original.FileName; 37 38 this.PluginId = original.PluginId; -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/ServiceClients/StateLog.cs
r6976 r7215 38 38 } 39 39 40 public string TaskName { get; set; } 41 40 42 public override IDeepCloneable Clone(Cloner cloner) { 41 43 return new StateLog(this, cloner); -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/ServiceClients/Task.cs
r6976 r7215 34 34 this.CoresNeeded = original.CoresNeeded; 35 35 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 } 37 39 this.LastHeartbeat = original.LastHeartbeat; 38 40 this.IsParentTask = original.IsParentTask; -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/Settings.Designer.cs
r6976 r7215 2 2 // <auto-generated> 3 3 // This code was generated by a tool. 4 // Runtime Version:4.0.30319.23 54 // Runtime Version:4.0.30319.239 5 5 // 6 6 // Changes to this file may cause incorrect behavior and will be lost if … … 41 41 } 42 42 } 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 } 43 70 } 44 71 } -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/Settings.settings
r6976 r7215 9 9 <Value Profile="(Default)">HeuristicLab 3.3.exe</Value> 10 10 </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> 11 20 </Settings> 12 21 </SettingsFile> -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/TaskDownloader.cs
r6976 r7215 25 25 using HeuristicLab.Clients.Hive.Jobs; 26 26 using HeuristicLab.Common; 27 using System.Threading; 27 28 28 29 namespace HeuristicLab.Clients.Hive { … … 33 34 private bool exceptionOccured = false; 34 35 private Exception currentException; 36 private ReaderWriterLockSlim resultsLock = new ReaderWriterLockSlim(); 35 37 36 38 public bool IsFinished { 37 39 get { 38 return results.Count == taskIds.Count(); 40 try { 41 resultsLock.EnterReadLock(); 42 return results.Count == taskIds.Count(); 43 } finally { resultsLock.ExitReadLock(); } 39 44 } 40 45 } … … 51 56 } 52 57 } 53 58 54 59 public int FinishedCount { 55 60 get { 56 return results.Count; 61 try { 62 resultsLock.EnterReadLock(); 63 return results.Count; 64 } finally { resultsLock.ExitReadLock(); } 57 65 } 58 66 } … … 60 68 public IDictionary<Guid, HiveTask> Results { 61 69 get { 62 return results; 70 try { 71 resultsLock.EnterReadLock(); 72 return results; 73 } finally { resultsLock.ExitReadLock(); } 63 74 } 64 75 } … … 66 77 public TaskDownloader(IEnumerable<Guid> jobIds) { 67 78 this.taskIds = jobIds; 68 this.taskDownloader = new ConcurrentTaskDownloader<ItemTask>( 2, 2);79 this.taskDownloader = new ConcurrentTaskDownloader<ItemTask>(Settings.Default.MaxParallelDownloads, Settings.Default.MaxParallelDownloads); 69 80 this.taskDownloader.ExceptionOccured += new EventHandler<EventArgs<Exception>>(taskDownloader_ExceptionOccured); 70 81 this.results = new Dictionary<Guid, HiveTask>(); 71 82 } 72 83 73 84 public void StartAsync() { 74 85 foreach (Guid taskId in taskIds) { 75 Task task = ServiceLocator.Instance.CallHiveService(s => s.GetTask(taskId)); 76 77 taskDownloader.DownloadTask(task, 86 taskDownloader.DownloadTaskDataAndTask(taskId, 78 87 (localJob, itemJob) => { 79 88 if (localJob != null && itemJob != null) { … … 85 94 } 86 95 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(); } 88 100 } 89 101 }); 90 } 102 } 91 103 } 92 104 -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/Tasks/ItemTask.cs
r6976 r7215 150 150 151 151 #region INamedItem Members 152 public abstract bool CanChangeDescription { get; }152 public abstract new bool CanChangeDescription { get; } 153 153 154 public abstract bool CanChangeName { get; }154 public abstract new bool CanChangeName { get; } 155 155 156 public abstract string Description { get; set; }156 public abstract new string Description { get; set; } 157 157 158 public abstract string Name { get; set; }158 public abstract new string Name { get; set; } 159 159 #endregion 160 160 161 161 #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 }187 162 public event EventHandler ExecutionTimeChanged; 188 163 protected virtual void OnExecutionTimeChanged() { … … 198 173 199 174 #region IItem Members 200 public virtual string ItemDescription {175 public virtual new string ItemDescription { 201 176 get { return item.ItemDescription; } 202 177 } 203 178 204 public virtual Image ItemImage { 179 public virtual new Image ItemImage 180 { 205 181 get { return item.ItemImage; } 206 182 } 207 183 208 public virtual string ItemName { 184 public virtual new string ItemName 185 { 209 186 get { return item.ItemName; } 210 187 } 211 188 212 public virtual Version ItemVersion { 189 public virtual new Version ItemVersion 190 { 213 191 get { return item.ItemVersion; } 214 192 } -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/Tasks/OptimizerTask.cs
r6976 r7215 142 142 143 143 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)); 145 145 } 146 146 -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/Util/PersistenceUtil.cs
r6976 r7215 29 29 public static class PersistenceUtil { 30 30 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 } 36 36 } 37 37 38 38 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 } 44 44 } 45 45 46 46 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 } 51 51 } 52 52 } -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive/3.3/app.config
r6976 r7215 14 14 <value>HeuristicLab 3.3.exe</value> 15 15 </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> 16 25 </HeuristicLab.Clients.Hive.Settings> 17 26 </applicationSettings> 18 27 <system.serviceModel> 28 <behaviors> 29 <endpointBehaviors> 30 <behavior name="HiveBehaviorConfiguration"> 31 <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 32 </behavior> 33 </endpointBehaviors> 34 </behaviors> 19 35 <bindings> 20 36 <wsHttpBinding> … … 48 64 </bindings> 49 65 <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"> 51 67 <identity> 52 68 <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.