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