Changeset 1726
- Timestamp:
- 04/30/09 15:18:28 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Hive.Engine/3.2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Engine/3.2/HiveEngine.cs
r1651 r1726 31 31 using HeuristicLab.Hive.Contracts.BusinessObjects; 32 32 using System.IO; 33 using System.Xml; 33 34 34 35 namespace HeuristicLab.Hive.Engine { … … 46 47 } 47 48 48 49 49 #region IEngine Members 50 50 … … 75 75 public void Execute() { 76 76 IExecutionEngineFacade executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(HiveServerUrl); 77 77 78 78 DiscoveryService dService = new DiscoveryService(); 79 79 PluginInfo depInfo = dService.GetDeclaringPlugin(typeof(HiveEngine)); … … 89 89 90 90 foreach (PluginInfo info in dependentPlugins) { 91 HivePluginInfo pluginInfo = 91 HivePluginInfo pluginInfo = 92 92 new HivePluginInfo(); 93 93 pluginInfo.Name = info.Name; … … 102 102 } 103 103 104 public void ExecuteStep() { 105 throw new NotSupportedException(); 106 } 107 108 public void ExecuteSteps(int steps) { 109 throw new NotSupportedException(); 110 } 111 112 public void Abort() { 104 public void RequestSnapshot() { 113 105 IExecutionEngineFacade executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(HiveServerUrl); 114 115 116 //This are just Stubs on the server right now. There won't be any effect right now... 117 executionEngineFacade.AbortJob(jobId); 118 executionEngineFacade.RequestSnapshot(Guid); 119 106 120 107 //Requests the last result. 121 108 //false: There will always be a result that is been sent back … … 123 110 // the snapshot hasn't been submitted to the server (because the client needs 124 111 // more time). 125 executionEngineFacade.GetLastResult(jobId, false); 126 127 throw new NotImplementedException(); 112 var result = executionEngineFacade.GetLastResult(jobId, false); 113 if (result.Success) { 114 JobResult jobResult = result.Obj; 115 if (jobResult != null) { 116 job = (Job)PersistenceManager.RestoreFromGZip(jobResult.Result); 117 PluginManager.ControlManager.ShowControl(job.Engine.CreateView()); 118 } 119 } else { 120 Exception ex = new Exception(result.Obj.Exception.Message); 121 ThreadPool.QueueUserWorkItem(delegate(object state) { OnExceptionOccurred(ex); }); 122 } 123 } 124 125 126 public void ExecuteStep() { 127 throw new NotSupportedException(); 128 } 129 130 public void ExecuteSteps(int steps) { 131 throw new NotSupportedException(); 132 } 133 134 public void Abort() { 135 IExecutionEngineFacade executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(HiveServerUrl); 136 137 //This are just Stubs on the server right now. There won't be any effect right now... 138 executionEngineFacade.AbortJob(jobId); 139 OnFinished(); 128 140 } 129 141 130 142 public void Reset() { 131 throw new NotImplementedException(); 143 job.Engine.Reset(); 144 jobId = Guid.NewGuid(); 145 OnInitialized(); 132 146 } 133 147 134 148 public event EventHandler Initialized; 149 /// <summary> 150 /// Fires a new <c>Initialized</c> event. 151 /// </summary> 152 protected virtual void OnInitialized() { 153 if (Initialized != null) 154 Initialized(this, new EventArgs()); 155 } 135 156 136 157 public event EventHandler<OperationEventArgs> OperationExecuted; 158 /// <summary> 159 /// Fires a new <c>OperationExecuted</c> event. 160 /// </summary> 161 /// <param name="operation">The operation that has been executed.</param> 162 protected virtual void OnOperationExecuted(IOperation operation) { 163 if (OperationExecuted != null) 164 OperationExecuted(this, new OperationEventArgs(operation)); 165 } 137 166 138 167 public event EventHandler<ExceptionEventArgs> ExceptionOccurred; 168 /// <summary> 169 /// Aborts the execution and fires a new <c>ExceptionOccurred</c> event. 170 /// </summary> 171 /// <param name="exception">The exception that was thrown.</param> 172 protected virtual void OnExceptionOccurred(Exception exception) { 173 Abort(); 174 if (ExceptionOccurred != null) 175 ExceptionOccurred(this, new ExceptionEventArgs(exception)); 176 } 139 177 140 178 public event EventHandler ExecutionTimeChanged; 179 /// <summary> 180 /// Fires a new <c>ExecutionTimeChanged</c> event. 181 /// </summary> 182 protected virtual void OnExecutionTimeChanged() { 183 if (ExecutionTimeChanged != null) 184 ExecutionTimeChanged(this, new EventArgs()); 185 } 141 186 142 187 public event EventHandler Finished; 188 /// <summary> 189 /// Fires a new <c>Finished</c> event. 190 /// </summary> 191 protected virtual void OnFinished() { 192 if (Finished != null) 193 Finished(this, new EventArgs()); 194 } 143 195 144 196 #endregion 145 146 public void RequestSnapshot() {147 throw new NotImplementedException();148 }149 197 150 198 public override IView CreateView() { … … 158 206 } 159 207 #endregion 208 209 public override System.Xml.XmlNode GetXmlNode(string name, System.Xml.XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) { 210 XmlNode node = base.GetXmlNode(name, document, persistedObjects); 211 XmlAttribute attr = document.CreateAttribute("HiveServerUrl"); 212 attr.Value = HiveServerUrl; 213 node.Attributes.Append(attr); 214 node.AppendChild(PersistenceManager.Persist("Job", job, document, persistedObjects)); 215 return node; 216 } 217 218 public override void Populate(System.Xml.XmlNode node, IDictionary<Guid, IStorable> restoredObjects) { 219 base.Populate(node, restoredObjects); 220 HiveServerUrl = node.Attributes["HiveServerUrl"].Value; 221 job = (Job)PersistenceManager.Restore(node.SelectSingleNode("Job"), restoredObjects); 222 } 160 223 } 161 224 } -
trunk/sources/HeuristicLab.Hive.Engine/3.2/HiveEngineEditor.Designer.cs
r1530 r1726 87 87 // 88 88 this.snapshotButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 89 this.snapshotButton.Enabled = false; 89 90 this.snapshotButton.Location = new System.Drawing.Point(294, 457); 90 91 this.snapshotButton.Name = "snapshotButton"; … … 93 94 this.snapshotButton.Text = "Snapshot"; 94 95 this.snapshotButton.UseVisualStyleBackColor = true; 96 this.snapshotButton.Click += new System.EventHandler(this.snapshotButton_Click); 95 97 // 96 98 // urlTextBox -
trunk/sources/HeuristicLab.Hive.Engine/3.2/HiveEngineEditor.cs
r1530 r1726 42 42 get { return (HiveEngine)Engine; } 43 43 set { 44 if (base.Engine != null) RemoveItemEvents(); 44 45 base.Engine = value; 46 AddItemEvents(); 45 47 SetDataBinding(); 46 48 } … … 61 63 : this() { 62 64 HiveEngine = hiveEngine; 65 base.executeButton.Click += new EventHandler(executeButton_Click); 66 } 67 68 void executeButton_Click(object sender, EventArgs e) { 69 snapshotButton.Enabled = true; 63 70 } 64 71 … … 66 73 urlTextBox.DataBindings.Add("Text", HiveEngine, "HiveServerUrl"); 67 74 } 75 76 protected override void RemoveItemEvents() { 77 Engine.Initialized -= new EventHandler(Engine_Initialized); 78 Engine.Finished -= new EventHandler(Engine_Finished); 79 base.RemoveItemEvents(); 80 } 81 82 protected override void AddItemEvents() { 83 base.AddItemEvents(); 84 Engine.Finished += new EventHandler(Engine_Finished); 85 Engine.Initialized += new EventHandler(Engine_Initialized); 86 } 87 88 void Engine_Initialized(object sender, EventArgs e) { 89 snapshotButton.Enabled = false; 90 } 91 92 void Engine_Finished(object sender, EventArgs e) { 93 snapshotButton.Enabled = false; 94 } 95 96 private void snapshotButton_Click(object sender, EventArgs e) { 97 HiveEngine.RequestSnapshot(); 98 } 68 99 } 69 100 }
Note: See TracChangeset
for help on using the changeset viewer.