Changeset 6230 for branches/HeuristicLab.Hive-3.4/sources
- Timestamp:
- 05/17/11 18:56:06 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.4/AboutView.cs
r6225 r6230 28 28 namespace HeuristicLab.Clients.Hive.SlaveCore.Views { 29 29 [View("AboutView: Show some information about HeursticLab Hive")] 30 [Content(typeof(Item), IsDefaultView = true)]30 [Content(typeof(Item), IsDefaultView = false)] 31 31 public partial class AboutView : ItemView { 32 32 public new Item Content { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.4/LogView.cs
r6225 r6230 29 29 namespace HeuristicLab.Clients.Hive.SlaveCore.Views { 30 30 [View("LogView: Displays logged messages from the slave core.")] 31 [Content(typeof(SlaveItem), IsDefaultView = true)]31 [Content(typeof(SlaveItem), IsDefaultView = false)] 32 32 public partial class LogView : ItemView { 33 33 public new SlaveItem Content { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/PluginCache.cs
r6178 r6230 25 25 using System.Linq; 26 26 using System.Reflection; 27 using System.Runtime.CompilerServices;28 27 using System.Runtime.Serialization; 29 28 using System.Runtime.Serialization.Formatters.Binary; … … 74 73 private void DoUpdateRun() { 75 74 SafelyCreateDirectory(PluginCacheDir); 76 foreach (string dir in Directory.EnumerateDirectories(PluginCacheDir)) { 77 cachedPluginsGuids.Add(Guid.Parse(GetFilenameFromPath(dir))); 78 } 79 } 80 81 [MethodImpl(MethodImplOptions.Synchronized)] 75 lock (cachedPluginsGuids) { 76 cachedPluginsGuids.Clear(); 77 foreach (string dir in Directory.EnumerateDirectories(PluginCacheDir)) { 78 cachedPluginsGuids.Add(Guid.Parse(GetFilenameFromPath(dir))); 79 } 80 } 81 } 82 82 83 public void CopyPluginsForJob(List<Plugin> requests, Guid jobId, out string configFileName) { 83 lock (locker) { 84 configFileName = string.Empty; 85 String targetDir = Path.Combine(PluginTempBaseDir, jobId.ToString()); 86 87 RecreateDirectory(targetDir); 88 89 foreach (Plugin requestedPlugin in requests) { 90 var filePaths = GetPluginFilePaths(requestedPlugin.Id); 91 foreach (string filePath in filePaths) { 92 File.Copy(filePath, Path.Combine(targetDir, Path.GetFileName(filePath))); 93 } 94 95 if (requestedPlugin.Name == "Configuration") { 96 configFileName = Path.Combine(targetDir, Path.GetFileName(filePaths.SingleOrDefault())); // configuration plugin consists only of 1 file (usually the "HeuristicLab X.X.exe.config") 97 } 98 } 99 100 // copy files from PluginInfrastructure (which are not declared in any plugins) 101 string baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 102 CopyFile(baseDir, targetDir, "HeuristicLab.PluginInfrastructure-3.3.dll"); 103 CopyFile(baseDir, targetDir, "ICSharpCode.SharpZipLib.dll"); 104 CopyFile(baseDir, targetDir, "ICSharpCode.SharpZipLib License.txt"); 105 106 // copy slave plugins, otherwise its not possible to register the UnhandledException handler to the appdomain 107 CopyFile(baseDir, targetDir, "HeuristicLab.Clients.Hive.SlaveCore-3.4.dll"); 108 CopyFile(baseDir, targetDir, "HeuristicLab.Clients.Hive-3.4.dll"); 109 //CopyFile(baseDir, targetDir, "HeuristicLab.Services.Hive.Common-3.4.dll"); 110 CopyFile(baseDir, targetDir, "HeuristicLab.Hive-3.4.dll"); 111 CopyFile(baseDir, targetDir, "HeuristicLab.Clients.Common-3.3.dll"); 112 } 84 configFileName = string.Empty; 85 String targetDir = Path.Combine(PluginTempBaseDir, jobId.ToString()); 86 87 RecreateDirectory(targetDir); 88 89 foreach (Plugin requestedPlugin in requests) { 90 var filePaths = GetPluginFilePaths(requestedPlugin.Id); 91 foreach (string filePath in filePaths) { 92 File.Copy(filePath, Path.Combine(targetDir, Path.GetFileName(filePath))); 93 } 94 95 if (requestedPlugin.Name == "Configuration") { 96 configFileName = Path.Combine(targetDir, Path.GetFileName(filePaths.SingleOrDefault())); // configuration plugin consists only of 1 file (usually the "HeuristicLab X.X.exe.config") 97 } 98 } 99 100 // copy files from PluginInfrastructure (which are not declared in any plugins) 101 string baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 102 CopyFile(baseDir, targetDir, "HeuristicLab.PluginInfrastructure-3.3.dll"); 103 CopyFile(baseDir, targetDir, "ICSharpCode.SharpZipLib.dll"); 104 CopyFile(baseDir, targetDir, "ICSharpCode.SharpZipLib License.txt"); 105 106 // copy slave plugins, otherwise its not possible to register the UnhandledException handler to the appdomain 107 CopyFile(baseDir, targetDir, "HeuristicLab.Clients.Hive.SlaveCore-3.4.dll"); 108 CopyFile(baseDir, targetDir, "HeuristicLab.Clients.Hive-3.4.dll"); 109 //CopyFile(baseDir, targetDir, "HeuristicLab.Services.Hive.Common-3.4.dll"); 110 CopyFile(baseDir, targetDir, "HeuristicLab.Hive-3.4.dll"); 111 CopyFile(baseDir, targetDir, "HeuristicLab.Clients.Common-3.3.dll"); 112 113 113 } 114 114 … … 150 150 List<Guid> missingGuids = new List<Guid>(); 151 151 List<Plugin> neededPlugins = new List<Plugin>(); 152 foreach (Guid pluginId in myJob.PluginsNeededIds) { 153 Plugin plugin = WcfService.Instance.GetPlugin(pluginId); 154 if (plugin != null) { 155 neededPlugins.Add(plugin); 156 } 157 158 if (!cachedPluginsGuids.Contains(pluginId)) { 159 missingGuids.Add(pluginId); 152 lock (cachedPluginsGuids) { 153 foreach (Guid pluginId in myJob.PluginsNeededIds) { 154 Plugin plugin = WcfService.Instance.GetPlugin(pluginId); 155 if (plugin != null) { 156 neededPlugins.Add(plugin); 157 } 158 159 if (!cachedPluginsGuids.Contains(pluginId)) { 160 missingGuids.Add(pluginId); 161 } 160 162 } 161 163 } … … 172 174 } 173 175 174 DoUpdateRun(); 176 if (missingGuids.Count > 0) { 177 DoUpdateRun(); 178 } 175 179 CopyPluginsForJob(neededPlugins, myJob.Id, out configFileName); 176 180 } else { 177 181 configFileName = ""; 178 182 } 179 180 183 SlaveClientCom.Instance.ClientCom.LogMessage("Fetched " + missingGuids.Count + " plugins for job " + myJob.Id); 181 184 } … … 203 206 /// </summary> 204 207 private void WriteDateLastUsed(string path) { 205 FileStream fs = new FileStream(Path.Combine(path, lastUsedFileName), FileMode.Create); 206 BinaryFormatter formatter = new BinaryFormatter(); 207 208 FileStream fs = null; 208 209 try { 210 fs = new FileStream(Path.Combine(path, lastUsedFileName), FileMode.Create); 211 BinaryFormatter formatter = new BinaryFormatter(); 209 212 formatter.Serialize(fs, DateTime.Now); 213 } 214 catch (IOException) { 215 SlaveClientCom.Instance.ClientCom.LogMessage(string.Format("No used date written in path {0}.", path)); 210 216 } 211 217 catch (SerializationException) { … … 214 220 } 215 221 finally { 216 fs.Close(); 222 if (fs != null) { 223 fs.Close(); 224 } 217 225 } 218 226 } … … 245 253 246 254 if (Directory.Exists(PluginCacheDir)) { 247 foreach (string dir in Directory.EnumerateDirectories(PluginCacheDir)) { 248 try { 249 fs = new FileStream(Path.Combine(dir, lastUsedFileName), FileMode.Open); 250 BinaryFormatter formatter = new BinaryFormatter(); 251 luDate = (DateTime)formatter.Deserialize(fs); 252 fs.Close(); 253 254 if (luDate.AddDays(maxAge) < DateTime.Now) { 255 lock (locker) { 256 foreach (string dir in Directory.EnumerateDirectories(PluginCacheDir)) { 257 try { 258 fs = new FileStream(Path.Combine(dir, lastUsedFileName), FileMode.Open); 259 BinaryFormatter formatter = new BinaryFormatter(); 260 luDate = (DateTime)formatter.Deserialize(fs); 261 fs.Close(); 262 263 if (luDate.AddDays(maxAge) < DateTime.Now) { 264 Directory.Delete(dir, true); 265 changed = true; 266 } 267 } 268 catch (FileNotFoundException) { 269 //nerver used 255 270 Directory.Delete(dir, true); 256 271 changed = true; 257 272 } 258 } 259 catch (SerializationException) { 260 fs.Close(); 261 throw; 262 } 263 catch (System.IO.FileNotFoundException) { 264 //nerver used 265 Directory.Delete(dir, true); 266 changed = true; 267 } 268 catch (Exception) { 269 throw; 270 } 271 } 272 } 273 if (changed) 274 DoUpdateRun(); 275 } 276 273 catch (Exception ex) { 274 if (fs != null) { 275 fs.Close(); 276 } 277 SlaveClientCom.Instance.ClientCom.LogMessage(string.Format("CleanPluginCache threw exception: {0}", ex.ToString())); 278 } 279 } 280 281 if (changed) 282 DoUpdateRun(); 283 } 284 } 285 } 277 286 278 287 internal void DeletePluginsForJob(Guid id) { … … 288 297 Thread.Sleep(1000); 289 298 tries--; 290 if (tries == 0) throw;// TODO: don't know what do do299 if (tries == 0) throw;// TODO: don't know what to do 291 300 } 292 301 }
Note: See TracChangeset
for help on using the changeset viewer.