changeset 179 | d8ac696cc51f |
parent 1 | be27ed110b50 |
1:be27ed110b50 | 179:d8ac696cc51f |
---|---|
44 private boolean sendDatabase = true; |
44 private boolean sendDatabase = true; |
45 |
45 |
46 // Root node. |
46 // Root node. |
47 private BuildNode buildNode; |
47 private BuildNode buildNode; |
48 |
48 |
49 // Ant build Stack. Usefull to associate with current parent. |
49 // Ant build Stack. Useful to associate with current parent. |
50 private EndLessStack<DataNode> buildEventStack = new EndLessStack<DataNode>(); |
50 private EndLessStack<DataNode> buildEventStack = new EndLessStack<DataNode>(); |
51 |
51 |
52 // default list of properties to extract. |
52 // default list of properties to extract. |
53 private String[] propList = {"os.name", "user.name", "build.name", "build.number", "build.id", "build.system", "env.NUMBER_OF_PROCESSORS", "helium.version", "env.SYMSEE_VERSION", "diamonds.build.id"}; |
53 private String[] propList = {"os.name", "user.name", "build.name", "build.number", "build.id", "build.family", "build.system", "env.NUMBER_OF_PROCESSORS", "helium.version", "env.SYMSEE_VERSION", "diamonds.build.id"}; |
54 |
54 |
55 // Memory bean |
55 // Memory bean |
56 private MemoryMXBean mbean; |
56 private MemoryMXBean mbean; |
57 |
57 |
58 public Listener() { |
58 public Listener() { |
69 if (sendDatabase) { |
69 if (sendDatabase) { |
70 try { |
70 try { |
71 Database antDB = new Database((Project)buildNode.getReference(), null, null); |
71 Database antDB = new Database((Project)buildNode.getReference(), null, null); |
72 database = antDB.createDOM(); |
72 database = antDB.createDOM(); |
73 } catch (Exception e) { |
73 } catch (Exception e) { |
74 System.out.println("Warning: couldn't generate Ant DB."); |
74 // We are Ignoring the errors as no need to fail the build. |
75 log.debug("Error: couldn't generate Ant DB.", e); |
|
75 database = null; |
76 database = null; |
76 } |
77 } |
77 } |
78 } |
78 //TreeDumper dumper = new TreeDumper(buildNode); |
79 //TreeDumper dumper = new TreeDumper(buildNode); |
79 //dumper.dump(); |
80 //dumper.dump(); |
86 log.debug("Sending the data."); |
87 log.debug("Sending the data."); |
87 String xml = writer.toString(); |
88 String xml = writer.toString(); |
88 log.debug(xml); |
89 log.debug(xml); |
89 sender.sendData(xml); |
90 sender.sendData(xml); |
90 } catch (Exception e) { |
91 } catch (Exception e) { |
91 log.debug("Warning: error generating the XML."); |
92 // We are Ignoring the errors as no need to fail the build. |
92 e.printStackTrace(); |
93 log.debug("Error: error generating the InterData database XML.", e); |
93 } |
94 } |
94 } |
95 } |
95 } |
96 } |
96 |
97 |
97 |
98 |
102 */ |
103 */ |
103 private Hashtable<String, String> extractProperties() { |
104 private Hashtable<String, String> extractProperties() { |
104 Hashtable<String, String> properties = new Hashtable<String, String>(); |
105 Hashtable<String, String> properties = new Hashtable<String, String>(); |
105 if (buildNode != null) { |
106 if (buildNode != null) { |
106 Project project = (Project)buildNode.getReference(); |
107 Project project = (Project)buildNode.getReference(); |
107 Hashtable projProps = project.getProperties(); |
108 Hashtable<String, String> projProps = project.getProperties(); |
108 for (int i = 0; i < propList.length; i++) { |
109 for (int i = 0; i < propList.length; i++) { |
109 if (projProps.containsKey(propList[i])) { |
110 if (projProps.containsKey(propList[i])) { |
110 properties.put(propList[i], (String)projProps.get(propList[i])); |
111 properties.put(propList[i], projProps.get(propList[i])); |
111 } |
112 } |
112 } |
113 } |
113 } |
114 } |
114 return properties; |
115 return properties; |
115 } |
116 } |
131 String smtpServer = event.getProject().getProperty("email.smtp.server"); |
132 String smtpServer = event.getProject().getProperty("email.smtp.server"); |
132 this.sendData(smtpServer, event); |
133 this.sendData(smtpServer, event); |
133 } |
134 } |
134 |
135 |
135 public synchronized void buildStarted(BuildEvent event) { |
136 public synchronized void buildStarted(BuildEvent event) { |
136 log.debug("buildStarted"); |
|
137 if (buildNode == null) { |
137 if (buildNode == null) { |
138 // Create data node for a build |
138 // Create data node for a build |
139 buildNode = new BuildNode(null, event.getProject()); |
139 buildNode = new BuildNode(null, event.getProject()); |
140 // Garbage collector for execution. |
140 // Garbage collector for execution. |
141 buildEventStack.setDefaultElement(buildNode); |
141 buildEventStack.setDefaultElement(buildNode); |
142 } |
142 } |
143 } |
143 } |
144 |
144 |
145 public synchronized void subBuildFinished(BuildEvent event) { |
145 public synchronized void subBuildFinished(BuildEvent event) { |
146 log.debug("subBuildFinished"); |
|
147 if (buildNode != null) { |
146 if (buildNode != null) { |
148 BuildNode node = (BuildNode)buildNode.find(event.getProject()); |
147 BuildNode node = (BuildNode)buildNode.find(event.getProject()); |
149 if (node != null) { |
148 if (node != null) { |
150 node.setEndTime(new Date()); |
149 node.setEndTime(new Date()); |
151 node.setReference(null); |
150 node.setReference(null); |
156 buildEventStack.pop(); |
155 buildEventStack.pop(); |
157 } |
156 } |
158 } |
157 } |
159 |
158 |
160 public synchronized void subBuildStarted(BuildEvent event) { |
159 public synchronized void subBuildStarted(BuildEvent event) { |
161 log.debug("subBuildStarted"); |
|
162 DataNode parentNode = buildEventStack.peek(); |
160 DataNode parentNode = buildEventStack.peek(); |
163 if (parentNode != null) { |
161 if (parentNode != null) { |
164 BuildNode node = new BuildNode(parentNode, event.getProject()); |
162 BuildNode node = new BuildNode(parentNode, event.getProject()); |
165 buildEventStack.push(node); |
163 buildEventStack.push(node); |
166 } |
164 } |
169 public void messageLogged(BuildEvent event) { |
167 public void messageLogged(BuildEvent event) { |
170 // Ignoring message logging. |
168 // Ignoring message logging. |
171 } |
169 } |
172 |
170 |
173 public synchronized void targetFinished(BuildEvent event) { |
171 public synchronized void targetFinished(BuildEvent event) { |
174 //log.debug("targetFinished"); |
|
175 if (buildNode != null) { |
172 if (buildNode != null) { |
176 DataNode node = buildNode.find(event.getTarget()); |
173 DataNode node = buildNode.find(event.getTarget()); |
177 if (node != null) { |
174 if (node != null) { |
178 node.setEndTime(new Date()); |
175 node.setEndTime(new Date()); |
179 MemoryUsage mem = mbean.getHeapMemoryUsage(); |
176 MemoryUsage mem = mbean.getHeapMemoryUsage(); |
187 buildEventStack.pop(); |
184 buildEventStack.pop(); |
188 } |
185 } |
189 } |
186 } |
190 |
187 |
191 public synchronized void targetStarted(BuildEvent event) { |
188 public synchronized void targetStarted(BuildEvent event) { |
192 //log.debug("targetStarted"); |
|
193 DataNode parentNode = buildEventStack.peek(); |
189 DataNode parentNode = buildEventStack.peek(); |
194 if (parentNode != null) { |
190 if (parentNode != null) { |
195 TargetNode node = new TargetNode(parentNode, event.getTarget()); |
191 TargetNode node = new TargetNode(parentNode, event.getTarget()); |
196 MemoryUsage mem = mbean.getHeapMemoryUsage(); |
192 MemoryUsage mem = mbean.getHeapMemoryUsage(); |
197 node.setStartUsedHeap(mem.getUsed()); |
193 node.setStartUsedHeap(mem.getUsed()); |
201 log.debug("targetStarted - could not find parent."); |
197 log.debug("targetStarted - could not find parent."); |
202 } |
198 } |
203 } |
199 } |
204 |
200 |
205 public synchronized void taskFinished(BuildEvent event) { |
201 public synchronized void taskFinished(BuildEvent event) { |
206 //log.debug("taskFinished"); |
202 // Ignoring task information |
207 if (buildNode != null) { |
|
208 DataNode node = buildNode.find(event.getTask()); |
|
209 if (node != null) { |
|
210 node.setEndTime(new Date()); |
|
211 node.setReference(null); |
|
212 } else { |
|
213 log.debug("taskFinished - could not find task."); |
|
214 } |
|
215 } |
|
216 } |
203 } |
217 |
204 |
218 public synchronized void taskStarted(BuildEvent event) { |
205 public synchronized void taskStarted(BuildEvent event) { |
219 //log.debug("taskStarted"); |
206 // Ignoring task information |
220 if (buildNode != null) { |
|
221 DataNode parentNode = buildNode.find(event.getTask().getOwningTarget()); |
|
222 if (parentNode != null) { |
|
223 //log.debug("taskStarted - pushing using owning parent"); |
|
224 new TaskNode(parentNode, event.getTask()); |
|
225 } else { |
|
226 //log.debug("taskStarted - pushing using stack"); |
|
227 new TaskNode(buildEventStack.peek(), event.getTask()); |
|
228 } |
|
229 } |
|
230 } |
207 } |
231 |
208 |
232 public void addAssertTask(HlmAssertMessage assertTask) { |
209 public void addAssertTask(HlmAssertMessage assertTask) { |
233 if (buildNode != null) { |
210 if (buildNode != null) { |
234 DataNode parentNode = buildNode.find(assertTask.getOwningTarget()); |
211 DataNode parentNode = buildNode.find(assertTask.getOwningTarget()); |
238 new AssertNode(buildEventStack.peek(), assertTask); |
215 new AssertNode(buildEventStack.peek(), assertTask); |
239 } |
216 } |
240 } |
217 } |
241 |
218 |
242 } |
219 } |
243 |
|
244 } |
220 } |