| 814 |
mhunt |
1 |
package com.erggroup.buildtool.daemon;
|
|
|
2 |
|
|
|
3 |
import com.erggroup.buildtool.daemon.BuildThread;
|
|
|
4 |
import com.erggroup.buildtool.ripple.MutableInt;
|
|
|
5 |
import com.erggroup.buildtool.ripple.MutableString;
|
|
|
6 |
import com.erggroup.buildtool.ripple.Package;
|
|
|
7 |
import com.erggroup.buildtool.ripple.ReleaseManager;
|
|
|
8 |
import com.erggroup.buildtool.ripple.RippleEngine;
|
| 4280 |
dpurdie |
9 |
import com.erggroup.buildtool.smtp.Smtpsend;
|
| 814 |
mhunt |
10 |
|
|
|
11 |
import java.io.BufferedReader;
|
| 834 |
mhunt |
12 |
import java.io.DataInputStream;
|
| 814 |
mhunt |
13 |
import java.io.File;
|
| 834 |
mhunt |
14 |
import java.io.FileInputStream;
|
|
|
15 |
import java.io.InputStreamReader;
|
| 814 |
mhunt |
16 |
import java.sql.SQLException;
|
| 2541 |
dpurdie |
17 |
import java.lang.System;
|
| 814 |
mhunt |
18 |
|
|
|
19 |
import org.apache.log4j.Logger;
|
|
|
20 |
|
|
|
21 |
/**Master Thread sub component
|
|
|
22 |
*/
|
|
|
23 |
public class MasterThread
|
|
|
24 |
extends BuildThread
|
|
|
25 |
{
|
|
|
26 |
|
|
|
27 |
/**Logger
|
|
|
28 |
* @attribute
|
|
|
29 |
*/
|
|
|
30 |
private static final Logger mLogger = Logger.getLogger(MasterThread.class);
|
|
|
31 |
|
| 2541 |
dpurdie |
32 |
/**Nagios Monitoring
|
|
|
33 |
* @attribute
|
|
|
34 |
*/
|
|
|
35 |
protected long mPhaseStartTime = 0;
|
|
|
36 |
|
| 864 |
mhunt |
37 |
/**constructor
|
| 814 |
mhunt |
38 |
*/
|
| 896 |
mhunt |
39 |
public MasterThread(int rtag_id, int rcon_id, String unitTest)
|
| 814 |
mhunt |
40 |
{
|
| 818 |
mhunt |
41 |
mLogger.warn("MasterThread rtag_id " + rtag_id + " rcon_id " + rcon_id);
|
| 814 |
mhunt |
42 |
mRtagId = rtag_id;
|
|
|
43 |
mRconId = rcon_id;
|
| 896 |
mhunt |
44 |
if ( unitTest == null )
|
|
|
45 |
{
|
|
|
46 |
unitTest = new String();
|
|
|
47 |
}
|
|
|
48 |
mUnitTest = unitTest;
|
| 814 |
mhunt |
49 |
}
|
|
|
50 |
|
|
|
51 |
/**implements the sequence diagrams coordinate slave threads, generate build files, allowed to proceed, check environment
|
|
|
52 |
*/
|
|
|
53 |
public void run()
|
|
|
54 |
{
|
|
|
55 |
Integer id = new Integer(mRtagId);
|
|
|
56 |
setName(id.toString());
|
| 4123 |
dpurdie |
57 |
mLogger.warn("run");
|
| 814 |
mhunt |
58 |
boolean exit = false;
|
|
|
59 |
RippleEngine rippleEngine = new RippleEngine(mReleaseManager, mRtagId, true);
|
|
|
60 |
MutableInt rconId = new MutableInt();
|
|
|
61 |
MutableInt current_run_level = new MutableInt();
|
|
|
62 |
MutableString addendum = new MutableString();
|
|
|
63 |
|
|
|
64 |
while(!exit)
|
|
|
65 |
{
|
|
|
66 |
try
|
|
|
67 |
{
|
| 2541 |
dpurdie |
68 |
mPhaseStartTime = 0;
|
| 916 |
mhunt |
69 |
mLogger.fatal("run calling sleepCheck");
|
| 886 |
mhunt |
70 |
sleepCheck();
|
| 916 |
mhunt |
71 |
mLogger.fatal("run calling rippleEngine.collectMetaData");
|
| 2541 |
dpurdie |
72 |
mPhaseStartTime = System.currentTimeMillis();
|
| 868 |
mhunt |
73 |
rippleEngine.collectMetaData();
|
| 2541 |
dpurdie |
74 |
mPhaseStartTime = 0;
|
| 868 |
mhunt |
75 |
|
| 814 |
mhunt |
76 |
if ( Thread.currentThread().isInterrupted() )
|
|
|
77 |
{
|
|
|
78 |
mLogger.warn("run is interrupted");
|
|
|
79 |
// unit test technique
|
|
|
80 |
throw new ExitException();
|
|
|
81 |
}
|
|
|
82 |
|
| 896 |
mhunt |
83 |
if ( mUnitTest.compareTo("unit test spawn thread") == 0)
|
| 814 |
mhunt |
84 |
{
|
|
|
85 |
throw new Exception();
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
MutableString buildFileContent = new MutableString();
|
|
|
89 |
|
| 896 |
mhunt |
90 |
if ( mUnitTest.compareTo("unit test check environment") != 0)
|
| 814 |
mhunt |
91 |
{
|
| 896 |
mhunt |
92 |
if ( mUnitTest.compareTo("unit test generate build files") != 0)
|
| 814 |
mhunt |
93 |
{
|
| 896 |
mhunt |
94 |
if ((mUnitTest.compareTo("unit test allowed to proceed") != 0) &&
|
|
|
95 |
(mUnitTest.compareTo("unit test not allowed to proceed") != 0) &&
|
|
|
96 |
(mUnitTest.compareTo("unit test exit") != 0))
|
| 814 |
mhunt |
97 |
{
|
| 4280 |
dpurdie |
98 |
//---------------------------------------------------------------
|
|
|
99 |
// Wait for all Slaves to enter waiting or paused state
|
|
|
100 |
// They may be building
|
|
|
101 |
// They may be starting up
|
|
|
102 |
//
|
| 886 |
mhunt |
103 |
mLogger.warn("run coordinate slave threads");
|
|
|
104 |
|
|
|
105 |
mRunLevel = RunLevel.WAITING;
|
|
|
106 |
mLogger.warn("run changing run level to WAITING for rcon_id " + mRconId);
|
| 916 |
mhunt |
107 |
mLogger.fatal("run calling mRunLevel.persistNew to set WAITING");
|
| 890 |
mhunt |
108 |
mRunLevel.persistNew(mReleaseManager, mRconId);
|
| 886 |
mhunt |
109 |
|
|
|
110 |
boolean allSlaveThreadsWaiting = false;
|
|
|
111 |
boolean logWarning = true;
|
|
|
112 |
boolean logWarning2 = true;
|
|
|
113 |
|
|
|
114 |
while ( !allSlaveThreadsWaiting )
|
| 882 |
mhunt |
115 |
{
|
| 916 |
mhunt |
116 |
mLogger.fatal("run calling mReleaseManager.queryRunLevel");
|
| 886 |
mhunt |
117 |
mReleaseManager.queryRunLevel(mRtagId);
|
|
|
118 |
|
| 892 |
mhunt |
119 |
// anything but WAITING or PAUSED
|
| 886 |
mhunt |
120 |
current_run_level.value = ReleaseManager.DB_IDLE;
|
| 916 |
mhunt |
121 |
mLogger.fatal("run calling mReleaseManager.getFirstRunLevel");
|
| 886 |
mhunt |
122 |
boolean moreRunLevelsConfigured = mReleaseManager.getFirstRunLevel(rconId, current_run_level);
|
|
|
123 |
|
|
|
124 |
// attempt to exit loop
|
|
|
125 |
allSlaveThreadsWaiting = true;
|
| 814 |
mhunt |
126 |
|
| 886 |
mhunt |
127 |
do
|
| 814 |
mhunt |
128 |
{
|
| 886 |
mhunt |
129 |
if (moreRunLevelsConfigured)
|
| 814 |
mhunt |
130 |
{
|
| 892 |
mhunt |
131 |
// DEVI 53065 Slave indication that they are done with a package includes
|
|
|
132 |
// having a paused run level
|
|
|
133 |
if ((current_run_level.value != ReleaseManager.DB_WAITING) &&
|
|
|
134 |
(current_run_level.value != ReleaseManager.DB_PAUSED))
|
| 816 |
mhunt |
135 |
{
|
| 886 |
mhunt |
136 |
if ( logWarning )
|
|
|
137 |
{
|
|
|
138 |
mLogger.warn("run waiting for rcon id " + rconId.value);
|
|
|
139 |
logWarning = false;
|
|
|
140 |
}
|
|
|
141 |
else
|
|
|
142 |
{
|
|
|
143 |
mLogger.info("run waiting for rcon id " + rconId.value);
|
|
|
144 |
}
|
|
|
145 |
allSlaveThreadsWaiting = false;
|
| 816 |
mhunt |
146 |
}
|
|
|
147 |
else
|
|
|
148 |
{
|
| 916 |
mhunt |
149 |
mLogger.fatal("run calling mReleaseManager.getNextRunLevel");
|
| 886 |
mhunt |
150 |
moreRunLevelsConfigured = mReleaseManager.getNextRunLevel(rconId, current_run_level);
|
| 816 |
mhunt |
151 |
}
|
| 814 |
mhunt |
152 |
}
|
|
|
153 |
}
|
| 886 |
mhunt |
154 |
while (moreRunLevelsConfigured && allSlaveThreadsWaiting);
|
|
|
155 |
|
|
|
156 |
if ( !allSlaveThreadsWaiting )
|
| 814 |
mhunt |
157 |
{
|
| 886 |
mhunt |
158 |
// to do, sleep for periodicMs
|
| 896 |
mhunt |
159 |
if ( mUnitTest.compareTo("unit test coordinate slave threads") == 0 )
|
| 820 |
mhunt |
160 |
{
|
| 886 |
mhunt |
161 |
Thread.currentThread().interrupt();
|
| 820 |
mhunt |
162 |
}
|
|
|
163 |
else
|
|
|
164 |
{
|
| 886 |
mhunt |
165 |
if ( logWarning2 )
|
|
|
166 |
{
|
|
|
167 |
mLogger.warn("run sleeping 3 secs waiting for slave threads");
|
|
|
168 |
logWarning2 = false;
|
|
|
169 |
}
|
|
|
170 |
else
|
|
|
171 |
{
|
|
|
172 |
mLogger.info("run sleeping 3 secs waiting for slave threads");
|
|
|
173 |
}
|
| 916 |
mhunt |
174 |
mLogger.fatal("run calling Thread.sleep for 3 secs");
|
| 886 |
mhunt |
175 |
Thread.sleep(3000);
|
|
|
176 |
mLogger.info("run sleep returned");
|
| 820 |
mhunt |
177 |
}
|
| 814 |
mhunt |
178 |
}
|
|
|
179 |
}
|
| 886 |
mhunt |
180 |
|
| 896 |
mhunt |
181 |
if ( mUnitTest.compareTo("unit test coordinate slave threads") == 0 )
|
| 814 |
mhunt |
182 |
{
|
| 886 |
mhunt |
183 |
throw new ExitException();
|
|
|
184 |
}
|
|
|
185 |
|
| 4280 |
dpurdie |
186 |
//---------------------------------------------------------------
|
|
|
187 |
// Publish Package Build Results
|
|
|
188 |
// Indicate to RM that we are publishing
|
|
|
189 |
// Ensure that all build machines have placed placed marker in dpkg_archive
|
|
|
190 |
// Save updated build files into VCS
|
|
|
191 |
//
|
| 886 |
mhunt |
192 |
mRunLevel = RunLevel.PUBLISHING;
|
|
|
193 |
mLogger.warn("run changing run level to PUBLISHING for rcon_id " + mRconId);
|
| 916 |
mhunt |
194 |
mLogger.fatal("run calling mRunLevel.persist to set PUBLISHING");
|
| 886 |
mhunt |
195 |
mRunLevel.persist(mReleaseManager, mRconId);
|
|
|
196 |
|
| 916 |
mhunt |
197 |
mLogger.fatal("run calling deliverChange on AbtPublish");
|
| 4280 |
dpurdie |
198 |
deliverChange(null, "AbtPublish", true);
|
|
|
199 |
|
|
|
200 |
// preserve, as they are reset by deliverChange
|
| 886 |
mhunt |
201 |
String reportingFullyPublished = mReportingFullyPublished;
|
| 924 |
dpurdie |
202 |
String reportingNewVcsTag = mReportingNewVcsTag;
|
| 4280 |
dpurdie |
203 |
|
|
|
204 |
//---------------------------------------------------------------
|
|
|
205 |
// TearDown the build workspace
|
|
|
206 |
// Remove the build workspace
|
|
|
207 |
// Save build log files
|
|
|
208 |
//
|
| 916 |
mhunt |
209 |
mLogger.fatal("run calling deliverChange on AbtTearDown");
|
| 4280 |
dpurdie |
210 |
deliverChange(null, "AbtTearDown", true);
|
| 886 |
mhunt |
211 |
|
|
|
212 |
// DEVI 47395 delete the build file now
|
|
|
213 |
// this will prevent any chance of multiply publishing a package version
|
|
|
214 |
File buildFile = new File(mRtagId + "build.xml");
|
|
|
215 |
|
|
|
216 |
if ( buildFile.exists() )
|
|
|
217 |
{
|
|
|
218 |
buildFile.delete();
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
if ( mReportingPackageName != null )
|
|
|
222 |
{
|
|
|
223 |
// a dummy build file did not apply
|
|
|
224 |
// Publishing is done outside ant by design
|
|
|
225 |
// The preference is to do all release manager work outside ant
|
|
|
226 |
|
|
|
227 |
boolean buildErrorOccurred = true;
|
| 2541 |
dpurdie |
228 |
boolean publishError = false;
|
|
|
229 |
|
| 898 |
mhunt |
230 |
// max 50 characters
|
|
|
231 |
String rootCause = "Error publishing to Release Manager";
|
| 886 |
mhunt |
232 |
try
|
| 814 |
mhunt |
233 |
{
|
| 908 |
mhunt |
234 |
if ( mReportingTestBuild.compareTo("0") != 0 )
|
|
|
235 |
{
|
|
|
236 |
mLogger.info("run completing test build on " + mReportingPackageName + mReportingPackageExtension);
|
|
|
237 |
// build failure emails will have been sent
|
|
|
238 |
// just left to notify the user of the test build completion
|
|
|
239 |
Package p = rippleEngine.findPackage(mReportingPackageName + mReportingPackageExtension);
|
|
|
240 |
|
|
|
241 |
if (p != ReleaseManager.NULL_PACKAGE)
|
|
|
242 |
{
|
|
|
243 |
boolean success = false;
|
|
|
244 |
|
|
|
245 |
if ( reportingFullyPublished != null && reportingFullyPublished.compareTo("yes") == 0 )
|
|
|
246 |
{
|
|
|
247 |
success = true;
|
|
|
248 |
}
|
|
|
249 |
|
| 916 |
mhunt |
250 |
mLogger.fatal("run calling p.completeTestBuild");
|
| 908 |
mhunt |
251 |
p.completeTestBuild(rippleEngine.mMailServer, rippleEngine.mMailSender, mReleaseManager, rippleEngine.mBaselineName, success);
|
|
|
252 |
}
|
|
|
253 |
|
|
|
254 |
// ... and clean up the mess in the archive
|
|
|
255 |
throw new Exception();
|
|
|
256 |
}
|
|
|
257 |
|
| 886 |
mhunt |
258 |
if ( reportingFullyPublished != null && reportingFullyPublished.compareTo("yes") == 0 )
|
| 814 |
mhunt |
259 |
{
|
| 886 |
mhunt |
260 |
buildErrorOccurred = false;
|
| 868 |
mhunt |
261 |
|
| 924 |
dpurdie |
262 |
if ( reportingNewVcsTag.length() > 0 )
|
| 852 |
mhunt |
263 |
{
|
| 886 |
mhunt |
264 |
Integer rtagId = new Integer(mRtagId);
|
|
|
265 |
|
|
|
266 |
if ( mGbeGatherMetricsOnly == null )
|
| 868 |
mhunt |
267 |
{
|
| 906 |
mhunt |
268 |
// publish to release manager
|
| 2541 |
dpurdie |
269 |
// On error mAutoMakeReleaseCause will contain error string
|
|
|
270 |
mLogger.fatal("run calling mReleaseManager.autoMakeRelease");
|
|
|
271 |
publishError = mReleaseManager.autoMakeRelease(
|
|
|
272 |
rtagId.toString(),
|
|
|
273 |
mReportingPackageName,
|
|
|
274 |
mReportingPackageExtension,
|
|
|
275 |
mReportingPackageVersion,
|
|
|
276 |
reportingNewVcsTag,
|
|
|
277 |
mReportingPackageDepends,
|
|
|
278 |
mReportingIsRipple);
|
|
|
279 |
|
|
|
280 |
// publishErrors only affect one package
|
|
|
281 |
if ( publishError )
|
|
|
282 |
{
|
|
|
283 |
rootCause = mReleaseManager.mAutoMakeReleaseCause;
|
|
|
284 |
mLogger.fatal("autoMakeRelease publishError: " + rootCause);
|
|
|
285 |
throw new Exception();
|
|
|
286 |
}
|
| 868 |
mhunt |
287 |
}
|
| 2541 |
dpurdie |
288 |
|
| 886 |
mhunt |
289 |
FileInputStream abtmetrics = new FileInputStream( rtagId.toString() + "abtmetrics.txt" );
|
|
|
290 |
DataInputStream din = new DataInputStream( abtmetrics );
|
|
|
291 |
InputStreamReader isr = new InputStreamReader( din );
|
|
|
292 |
BufferedReader br = new BufferedReader( isr );
|
|
|
293 |
String metrics = br.readLine();
|
|
|
294 |
mLogger.warn( "execute read metrics string " + metrics );
|
|
|
295 |
br.close();
|
|
|
296 |
isr.close();
|
|
|
297 |
din.close();
|
|
|
298 |
|
| 916 |
mhunt |
299 |
mLogger.fatal("run calling mReleaseManager.insertPackageMetrics");
|
| 886 |
mhunt |
300 |
mReleaseManager.insertPackageMetrics(rtagId.toString(), mReportingPackageName, mReportingPackageExtension, metrics );
|
| 4280 |
dpurdie |
301 |
|
|
|
302 |
//
|
|
|
303 |
// Info reportinging
|
|
|
304 |
// Send an email to track build system usage - may be noise
|
|
|
305 |
//
|
|
|
306 |
mLogger.fatal("run calling emailBuildComplete");
|
|
|
307 |
emailBuildComplete(rippleEngine, reportingNewVcsTag);
|
|
|
308 |
|
|
|
309 |
// All done
|
|
|
310 |
// The package has been built and released
|
| 852 |
mhunt |
311 |
}
|
| 886 |
mhunt |
312 |
else
|
|
|
313 |
{
|
| 924 |
dpurdie |
314 |
mLogger.info("run package not labelled in Version Control on " + mReportingPackageName + mReportingPackageVersion);
|
| 898 |
mhunt |
315 |
// max 50 characters
|
| 924 |
dpurdie |
316 |
rootCause = "Error publishing to Version Control System";
|
| 886 |
mhunt |
317 |
throw new Exception();
|
|
|
318 |
}
|
| 814 |
mhunt |
319 |
}
|
|
|
320 |
else
|
|
|
321 |
{
|
| 886 |
mhunt |
322 |
mLogger.info("run build error occurred on " + mReportingPackageName + mReportingPackageVersion);
|
| 814 |
mhunt |
323 |
throw new Exception();
|
|
|
324 |
}
|
| 886 |
mhunt |
325 |
|
| 814 |
mhunt |
326 |
}
|
| 886 |
mhunt |
327 |
catch( Exception e)
|
| 814 |
mhunt |
328 |
{
|
| 898 |
mhunt |
329 |
// a build error occurred or
|
| 924 |
dpurdie |
330 |
// an error occurred publishing to Version Control or Release Manager
|
| 886 |
mhunt |
331 |
// take out the archive entry first
|
|
|
332 |
String fs = System.getProperty( "file.separator" );
|
|
|
333 |
String dpkgArchiveEntry = new String(Package.mGbeDpkg + fs + mReportingPackageName + fs + mReportingPackageVersion);
|
|
|
334 |
File dpkgArchiveEntryFile = new File(dpkgArchiveEntry);
|
|
|
335 |
mLogger.info("run checking existence of " + dpkgArchiveEntry);
|
|
|
336 |
|
|
|
337 |
if ( dpkgArchiveEntryFile.exists() )
|
| 814 |
mhunt |
338 |
{
|
| 886 |
mhunt |
339 |
if ( dpkgArchiveEntryFile.isDirectory() )
|
|
|
340 |
{
|
|
|
341 |
mLogger.warn("run deleting " + dpkgArchiveEntryFile.getName());
|
| 916 |
mhunt |
342 |
mLogger.fatal("run calling deleteDirectory on " + dpkgArchiveEntryFile);
|
| 886 |
mhunt |
343 |
deleteDirectory(dpkgArchiveEntryFile);
|
|
|
344 |
}
|
| 814 |
mhunt |
345 |
}
|
| 924 |
dpurdie |
346 |
|
| 886 |
mhunt |
347 |
Integer rtagId = new Integer(mRtagId);
|
|
|
348 |
|
| 4280 |
dpurdie |
349 |
if ( ! buildErrorOccurred )
|
| 886 |
mhunt |
350 |
{
|
| 924 |
dpurdie |
351 |
mLogger.fatal("an error occurred publishing to Version Control or Release Manager");
|
| 908 |
mhunt |
352 |
// force exclusion by default
|
|
|
353 |
int testBuildInstruction = 0;
|
|
|
354 |
try
|
|
|
355 |
{
|
|
|
356 |
testBuildInstruction = Integer.parseInt( mReportingTestBuild );
|
|
|
357 |
}
|
|
|
358 |
catch( NumberFormatException nfe )
|
|
|
359 |
{
|
|
|
360 |
}
|
| 916 |
mhunt |
361 |
mLogger.fatal("run calling excludeFromBuild");
|
| 908 |
mhunt |
362 |
mReleaseManager.excludeFromBuild(mReportingPackageVersionId, null, rtagId.toString(), null, rootCause, null, false, testBuildInstruction);
|
| 2541 |
dpurdie |
363 |
|
|
|
364 |
if ( ! publishError )
|
|
|
365 |
{
|
|
|
366 |
throw new Exception("an error occurred publishing to Version Control or Release Manager");
|
|
|
367 |
}
|
| 886 |
mhunt |
368 |
}
|
| 898 |
mhunt |
369 |
|
| 902 |
mhunt |
370 |
// DEVI 55364
|
|
|
371 |
// Package has not been built on all configured platforms
|
|
|
372 |
// Under normal circumstances, this root cause will be masked by a previously reported error
|
|
|
373 |
// Under abnormal circumstances amidst build activity such as:
|
|
|
374 |
// - slave build machine reboots
|
|
|
375 |
// - slave build machines with a read only file system
|
|
|
376 |
// this root cause is required to keep the end user informed
|
|
|
377 |
// max 50 chars
|
|
|
378 |
String cause = "Buildtool env error occurred. Attempt build again";
|
| 908 |
mhunt |
379 |
// force exclusion by default
|
|
|
380 |
int testBuildInstruction = 0;
|
|
|
381 |
try
|
|
|
382 |
{
|
|
|
383 |
testBuildInstruction = Integer.parseInt( mReportingTestBuild );
|
|
|
384 |
}
|
|
|
385 |
catch( NumberFormatException nfe )
|
|
|
386 |
{
|
|
|
387 |
}
|
| 916 |
mhunt |
388 |
mLogger.fatal("run calling excludeFromBuild");
|
| 908 |
mhunt |
389 |
mReleaseManager.excludeFromBuild(mReportingPackageVersionId, mReportingPackageVersion, rtagId.toString(), null, mReportingBuildFailureLogFile == null ? cause : null, mReportingBuildFailureLogFile, false, testBuildInstruction);
|
| 814 |
mhunt |
390 |
}
|
|
|
391 |
}
|
| 886 |
mhunt |
392 |
|
| 896 |
mhunt |
393 |
if ( mUnitTest.compareTo("unit test coordinate slave threads") == 0 )
|
| 886 |
mhunt |
394 |
{
|
|
|
395 |
throw new ExitException();
|
|
|
396 |
}
|
|
|
397 |
mLogger.info("run coordinate slave threads returned");
|
| 814 |
mhunt |
398 |
}
|
|
|
399 |
|
| 4280 |
dpurdie |
400 |
|
|
|
401 |
//---------------------------------------------------------------
|
|
|
402 |
// Start of a new build cycle
|
|
|
403 |
// Determine if the daemon has been paused.
|
|
|
404 |
//
|
| 886 |
mhunt |
405 |
mLogger.warn("run checking allowedToProceed");
|
| 916 |
mhunt |
406 |
mLogger.fatal("run calling allowedToProceed");
|
| 886 |
mhunt |
407 |
allowedToProceed(true);
|
|
|
408 |
mLogger.info("run allowedToProceed returned");
|
|
|
409 |
|
| 896 |
mhunt |
410 |
if ( mUnitTest.compareTo("unit test allowed to proceed") == 0 )
|
| 886 |
mhunt |
411 |
{
|
|
|
412 |
throw new ExitException();
|
|
|
413 |
}
|
| 814 |
mhunt |
414 |
|
| 4280 |
dpurdie |
415 |
// Set up Release Config in mReleaseConfigCollection
|
|
|
416 |
// This will be used when creating a build file
|
|
|
417 |
mLogger.fatal("run calling queryReleaseConfig");
|
|
|
418 |
mReleaseManager.queryReleaseConfig(mRtagId);
|
|
|
419 |
|
|
|
420 |
//---------------------------------------------------------------
|
|
|
421 |
// Plan the next build
|
|
|
422 |
// Determine what is to be built
|
|
|
423 |
// Generate build files
|
| 814 |
mhunt |
424 |
mLogger.warn("run generating build files");
|
| 924 |
dpurdie |
425 |
mLogger.fatal("run calling planRelease");
|
| 4123 |
dpurdie |
426 |
mPhaseStartTime = System.currentTimeMillis();
|
| 814 |
mhunt |
427 |
rippleEngine.planRelease();
|
| 4123 |
dpurdie |
428 |
mPhaseStartTime = 0;
|
|
|
429 |
|
| 2541 |
dpurdie |
430 |
mPhaseStartTime = System.currentTimeMillis();
|
| 916 |
mhunt |
431 |
mLogger.fatal("run calling reportChange");
|
| 908 |
mhunt |
432 |
rippleEngine.reportChange();
|
| 2541 |
dpurdie |
433 |
mPhaseStartTime = 0;
|
| 924 |
dpurdie |
434 |
|
| 814 |
mhunt |
435 |
// get the build file from the ripple engine
|
|
|
436 |
rippleEngine.getFirstBuildFileContent(buildFileContent, addendum);
|
|
|
437 |
|
|
|
438 |
if ( addendum.value.compareTo("non generic") == 0 )
|
|
|
439 |
{
|
|
|
440 |
// publish the build file
|
|
|
441 |
mLogger.warn("run publishing build file");
|
| 916 |
mhunt |
442 |
mLogger.fatal("run calling publishBuildFile");
|
| 814 |
mhunt |
443 |
mReleaseManager.publishBuildFile(mRtagId, buildFileContent.value);
|
|
|
444 |
}
|
|
|
445 |
else
|
|
|
446 |
{
|
|
|
447 |
// publish a dummy build file for either generic or dummy cases
|
|
|
448 |
// this results in the slave not running ant
|
|
|
449 |
mLogger.warn("run publishing dummy build file");
|
| 916 |
mhunt |
450 |
mLogger.fatal("run calling publishBuildFile on dummy");
|
| 814 |
mhunt |
451 |
mReleaseManager.publishBuildFile(mRtagId, mDummyBuildFileContent);
|
|
|
452 |
}
|
|
|
453 |
}
|
| 4280 |
dpurdie |
454 |
else
|
|
|
455 |
{
|
|
|
456 |
// UTF: Set up Release Config in mReleaseConfigCollection
|
|
|
457 |
mLogger.fatal("run calling queryReleaseConfig for UTF");
|
|
|
458 |
mReleaseManager.queryReleaseConfig(mRtagId);
|
|
|
459 |
}
|
| 814 |
mhunt |
460 |
mLogger.info("run generated build files");
|
| 924 |
dpurdie |
461 |
// Start of a build cycle. Set new log file to capture entire build log
|
|
|
462 |
flagStartBuildCycle();
|
|
|
463 |
|
| 4280 |
dpurdie |
464 |
//---------------------------------------------------------------
|
|
|
465 |
// SetUp BuildSpace
|
|
|
466 |
// Extract source from version control
|
|
|
467 |
//
|
| 868 |
mhunt |
468 |
if ( mGbeGatherMetricsOnly != null )
|
|
|
469 |
{
|
|
|
470 |
// set view up early for metrics gathering to ensure build file is fully written before letting the slave loose
|
| 916 |
mhunt |
471 |
mLogger.fatal("run calling setViewUp");
|
| 868 |
mhunt |
472 |
setViewUp(buildFileContent.value, true);
|
|
|
473 |
}
|
|
|
474 |
|
| 4280 |
dpurdie |
475 |
//---------------------------------------------------------------
|
|
|
476 |
// Notify all slaves that there is work to be done
|
|
|
477 |
// Change the run level for all threads in associated with the baseline
|
|
|
478 |
//
|
| 814 |
mhunt |
479 |
mLogger.warn("run change the run level for all threads in associated with the baseline");
|
|
|
480 |
rconId.value = -1;
|
|
|
481 |
boolean moreBuildThreadsConfigured = mReleaseManager.getFirstReleaseConfig(rconId);
|
|
|
482 |
mRunLevel = RunLevel.ACTIVE;
|
|
|
483 |
|
|
|
484 |
do
|
|
|
485 |
{
|
|
|
486 |
if (moreBuildThreadsConfigured)
|
|
|
487 |
{
|
| 816 |
mhunt |
488 |
mLogger.warn("run changing run level to ACTIVE for rcon_id " + rconId.value);
|
| 916 |
mhunt |
489 |
mLogger.fatal("run calling mRunLevel.persist to set ACTIVE");
|
| 814 |
mhunt |
490 |
mRunLevel.persist(mReleaseManager, rconId.value);
|
|
|
491 |
moreBuildThreadsConfigured = mReleaseManager.getNextReleaseConfig(rconId);
|
|
|
492 |
}
|
|
|
493 |
}
|
|
|
494 |
while (moreBuildThreadsConfigured);
|
|
|
495 |
|
| 896 |
mhunt |
496 |
if ( mUnitTest.compareTo("unit test generate build files") == 0 )
|
| 814 |
mhunt |
497 |
{
|
|
|
498 |
throw new ExitException();
|
|
|
499 |
}
|
|
|
500 |
}
|
|
|
501 |
mLogger.info("run changed run levels");
|
|
|
502 |
|
| 4280 |
dpurdie |
503 |
//---------------------------------------------------------------
|
|
|
504 |
// Check that we are good to proceed with the build
|
|
|
505 |
// Check environment
|
|
|
506 |
// Ensure we have enough disk space
|
|
|
507 |
//
|
| 814 |
mhunt |
508 |
mLogger.warn("run checkEnvironment");
|
| 916 |
mhunt |
509 |
mLogger.fatal("run calling checkEnvironment");
|
| 814 |
mhunt |
510 |
checkEnvironment();
|
|
|
511 |
mLogger.info("run checkEnvironment returned");
|
|
|
512 |
|
| 896 |
mhunt |
513 |
if ( mUnitTest.compareTo("unit test check environment") == 0 )
|
| 814 |
mhunt |
514 |
{
|
|
|
515 |
throw new ExitException();
|
|
|
516 |
}
|
|
|
517 |
|
| 4280 |
dpurdie |
518 |
//---------------------------------------------------------------
|
|
|
519 |
// Build the package
|
|
|
520 |
// Setup the workspace
|
|
|
521 |
// Build the package - deliver change to product baseline
|
|
|
522 |
//
|
| 814 |
mhunt |
523 |
mLogger.warn("run deliverChange");
|
| 868 |
mhunt |
524 |
|
|
|
525 |
if ( mGbeGatherMetricsOnly == null )
|
|
|
526 |
{
|
| 916 |
mhunt |
527 |
mLogger.fatal("run calling setViewUp metrics only");
|
| 868 |
mhunt |
528 |
setViewUp(buildFileContent.value, true);
|
|
|
529 |
}
|
|
|
530 |
|
| 922 |
dpurdie |
531 |
mLogger.fatal("run calling deliverChange - the actual build " + mReportingPackageName + "_" + mReportingPackageVersion);
|
| 4280 |
dpurdie |
532 |
deliverChange(null, null, true);
|
| 814 |
mhunt |
533 |
mLogger.info("run deliverChange returned");
|
| 886 |
mhunt |
534 |
|
|
|
535 |
mSleep = false;
|
|
|
536 |
if ( addendum.value.compareTo("dummy") == 0 )
|
|
|
537 |
{
|
|
|
538 |
// no build requirement, so let things settle
|
|
|
539 |
mLogger.warn("run no build requirement, so let things settle");
|
|
|
540 |
mSleep = true;
|
|
|
541 |
}
|
| 814 |
mhunt |
542 |
}
|
| 4280 |
dpurdie |
543 |
//---------------------------------------------------------------
|
|
|
544 |
// Build loop exception handling (only)
|
|
|
545 |
//
|
| 814 |
mhunt |
546 |
catch( SQLException e )
|
|
|
547 |
{
|
|
|
548 |
// oracle connection issues
|
|
|
549 |
mLogger.warn("run oracle connection issues");
|
| 886 |
mhunt |
550 |
mException = true;
|
| 814 |
mhunt |
551 |
}
|
|
|
552 |
catch( ExitException e )
|
|
|
553 |
{
|
| 858 |
mhunt |
554 |
mLogger.warn("run ExitException");
|
| 814 |
mhunt |
555 |
exit = true;
|
|
|
556 |
}
|
|
|
557 |
catch( InterruptedException e )
|
|
|
558 |
{
|
|
|
559 |
mLogger.warn("run InterruptedException");
|
|
|
560 |
}
|
|
|
561 |
catch( Exception e )
|
|
|
562 |
{
|
| 930 |
dpurdie |
563 |
mLogger.error("run indefinitePause " + e.toString());
|
| 868 |
mhunt |
564 |
String cause = e.getMessage();
|
| 930 |
dpurdie |
565 |
if ( cause == null )
|
| 814 |
mhunt |
566 |
{
|
| 930 |
dpurdie |
567 |
cause = e.toString();
|
|
|
568 |
}
|
|
|
569 |
|
|
|
570 |
try
|
|
|
571 |
{
|
|
|
572 |
// notify first
|
|
|
573 |
// many reasons for indefinite pause, including database related, so do database last
|
|
|
574 |
mRecoverable = false;
|
| 896 |
mhunt |
575 |
|
| 930 |
dpurdie |
576 |
if ( cause.compareTo(Package.mRecoverable) == 0 )
|
| 868 |
mhunt |
577 |
{
|
| 930 |
dpurdie |
578 |
mRecoverable = true;
|
| 868 |
mhunt |
579 |
}
|
| 930 |
dpurdie |
580 |
|
|
|
581 |
indefinitePause(rippleEngine, cause);
|
|
|
582 |
mReleaseManager.indefinitePause();
|
|
|
583 |
// DEVI 51366 force sleep at beginning of while loop
|
|
|
584 |
mException = true;
|
| 814 |
mhunt |
585 |
}
|
| 930 |
dpurdie |
586 |
catch( Exception f )
|
|
|
587 |
{
|
|
|
588 |
mLogger.error("run indefinitePause failed");
|
|
|
589 |
}
|
| 814 |
mhunt |
590 |
}
|
|
|
591 |
}
|
|
|
592 |
}
|
|
|
593 |
|
| 4280 |
dpurdie |
594 |
|
|
|
595 |
/** Sends email notification and mark the successful completion of a build
|
|
|
596 |
* Used simply to keep an email trail of build operations
|
|
|
597 |
* Send only the the buildadm group
|
|
|
598 |
*
|
|
|
599 |
* Uses globals for data
|
|
|
600 |
*/
|
|
|
601 |
public void emailBuildComplete( RippleEngine rippleEngine, String reportingNewVcsTag )
|
|
|
602 |
{
|
|
|
603 |
mLogger.debug("emailBuildComplete");
|
|
|
604 |
|
|
|
605 |
String subject = "BUILD SUCCESS on package " + mReportingPackageName + " " + mReportingPackageVersion;
|
|
|
606 |
String mailBody="Release : " + rippleEngine.mBaselineName + "<br>" +
|
|
|
607 |
"Package : " + mReportingPackageName + "<br>" +
|
|
|
608 |
"Version : " + mReportingPackageVersion + "<br>" +
|
|
|
609 |
"PVID : " + mReportingPackageVersionId + "<br>" +
|
|
|
610 |
"VcsTag : " + reportingNewVcsTag + "<br>" +
|
|
|
611 |
"Ripple : " + mReportingIsRipple + "<br>" +
|
|
|
612 |
"Dependencies : " + mReportingPackageDepends + "<br>";
|
|
|
613 |
|
|
|
614 |
mailBody += "<p><hr>";
|
|
|
615 |
try
|
|
|
616 |
{
|
|
|
617 |
Smtpsend.send( rippleEngine.mMailServer, // mailServer
|
|
|
618 |
rippleEngine.mMailSender, // source
|
|
|
619 |
rippleEngine.mMailSender, // target - send to myself
|
|
|
620 |
null, // cc
|
|
|
621 |
null, // bcc
|
|
|
622 |
subject, // subject
|
|
|
623 |
mailBody, // body
|
|
|
624 |
null // attachment
|
|
|
625 |
);
|
|
|
626 |
}
|
|
|
627 |
catch( Exception e )
|
|
|
628 |
{
|
|
|
629 |
mLogger.warn("Email Failure: emailBuildComplete:" + e.getMessage());
|
|
|
630 |
}
|
|
|
631 |
mLogger.debug("emailBuildComplete. Returning");
|
|
|
632 |
}
|
|
|
633 |
|
| 814 |
mhunt |
634 |
/**returns 'M'
|
|
|
635 |
*/
|
|
|
636 |
protected char getMode()
|
|
|
637 |
{
|
|
|
638 |
mLogger.debug("getMode");
|
|
|
639 |
return 'M';
|
|
|
640 |
}
|
| 2541 |
dpurdie |
641 |
|
|
|
642 |
/**
|
|
|
643 |
* Nagios interface extension
|
|
|
644 |
* This method should be overriden by classes that extend this class
|
|
|
645 |
* If not overriden then the test indicates OK
|
|
|
646 |
*
|
|
|
647 |
* Returns true if the thread looks OK
|
|
|
648 |
*/
|
|
|
649 |
boolean checkThreadExtended()
|
|
|
650 |
{
|
|
|
651 |
boolean retVal = true;
|
|
|
652 |
mLogger.info("Master checkThreadExtended");
|
|
|
653 |
if ( mPhaseStartTime > 0 )
|
|
|
654 |
{
|
|
|
655 |
/*
|
|
|
656 |
** Report if we appear to be stuck in the current phase
|
|
|
657 |
** At the moment the phases that we monitor should complete
|
|
|
658 |
** within 5 minutes and 10 minutes is real error.
|
|
|
659 |
** We do need to allow time for interlocking with other tasks.
|
|
|
660 |
*/
|
| 4123 |
dpurdie |
661 |
if ( ((System.currentTimeMillis() - mPhaseStartTime) / 1000) > (10 * 60) )
|
| 2541 |
dpurdie |
662 |
{
|
| 4123 |
dpurdie |
663 |
mLogger.info("Master checkThreadExtended: " + ((System.currentTimeMillis() - mPhaseStartTime) / 1000));
|
| 2541 |
dpurdie |
664 |
retVal = false;
|
|
|
665 |
}
|
|
|
666 |
}
|
|
|
667 |
return retVal;
|
|
|
668 |
}
|
|
|
669 |
|
| 814 |
mhunt |
670 |
}
|