Subversion Repositories DevTools

Rev

Rev 7033 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7033 Rev 7176
Line 1... Line 1...
1
package com.erggroup.buildtool.daemon;
1
package com.erggroup.buildtool.daemon;
2
 
2
 
3
import com.erggroup.buildtool.abt.BuildToolException;
3
import com.erggroup.buildtool.abt.BuildToolException;
4
import com.erggroup.buildtool.daemon.BuildThread;
-
 
5
import com.erggroup.buildtool.ripple.Package;
4
import com.erggroup.buildtool.ripple.Package;
6
import com.erggroup.buildtool.ripple.ReleaseManager;
5
import com.erggroup.buildtool.ripple.ReleaseManager;
7
import com.erggroup.buildtool.ripple.RippleEngine;
6
import com.erggroup.buildtool.ripple.RippleEngine;
8
import com.erggroup.buildtool.ripple.RunLevel.BuildState;
7
import com.erggroup.buildtool.ripple.RunLevel.BuildState;
9
import com.erggroup.buildtool.utilities.MutableDate;
8
import com.erggroup.buildtool.utilities.MutableDate;
Line 38... Line 37...
38
     * @param unitTest        - Unit Test data 
37
     * @param unitTest        - Unit Test data 
39
     */
38
     */
40
    public SlaveThread(int rtagId, int rconId, ReleaseManager releaseManager, String unitTest)
39
    public SlaveThread(int rtagId, int rconId, ReleaseManager releaseManager, String unitTest)
41
    {
40
    {
42
        super(rtagId, rconId, releaseManager, unitTest);
41
        super(rtagId, rconId, releaseManager, unitTest);
43
        mLogger.warn("SlaveThread rtag_id " + rtagId + " rcon_id " + rconId);
42
        mLogger.warn("SlaveThread rcon_id {}", rconId);
44
    }
43
    }
45
 
44
 
46
    /**
45
    /**
47
     * implements the sequence diagrams consume build files, allowed to proceed,
46
     * implements the sequence diagrams consume build files, allowed to proceed,
48
     * check environment
47
     * check environment
Line 57... Line 56...
57
 
56
 
58
        while (!exit)
57
        while (!exit)
59
        {
58
        {
60
            try
59
            try
61
            {
60
            {
62
                mLogger.error("run calling sleepCheck");
61
                mLogger.warn("run calling sleepCheck");
63
                mPhase.setPhase("sleepCheck");
62
                mPhase.setPhase("sleepCheck");
64
                sleepCheck();
63
                sleepCheck();
65
                
64
                
66
                mLogger.error("run calling rippleEngine.collectMetaData");
65
                mLogger.warn("run calling rippleEngine.collectMetaData");
67
                mPhase.setPhase("collectMetaData");
66
                mPhase.setPhase("collectMetaData");
68
                mRippleEngine.collectMetaData();
67
                mRippleEngine.collectMetaData();
69
 
68
 
70
                if (Thread.currentThread().isInterrupted())
69
                if (Thread.currentThread().isInterrupted())
71
                {
70
                {
Line 80... Line 79...
80
                }
79
                }
81
 
80
 
82
                // allowed to proceed
81
                // allowed to proceed
83
                if (mUnitTest.compareTo("unit test consume build files") != 0)
82
                if (mUnitTest.compareTo("unit test consume build files") != 0)
84
                {
83
                {
85
                    mLogger.error("run calling allowedToProceed");
84
                    mLogger.warn("run calling allowedToProceed");
86
                    mPhase.setPhase("allowedToProceed");
85
                    mPhase.setPhase("allowedToProceed");
87
                    allowedToProceed(false);
86
                    allowedToProceed(false);
88
                    mLogger.info("run allowedToProceed returned");
87
                    mLogger.info("run allowedToProceed returned");
89
                }
88
                }
90
 
89
 
91
                // Indicate that the Slave is WAITING - for a job
90
                // Indicate that the Slave is WAITING - for a job
92
                mPhase.setPhase("Waiting for work");
91
                mPhase.setPhase("Waiting for work");
93
                mLogger.error("run changing run level to WAITING for rcon_id " + mRconId);
92
                mLogger.warn("run changing run level to WAITING for rcon_id {}", mRconId);
94
 
93
 
95
 
94
 
96
                // Wait for Slave to be set as Active
95
                // Wait for Slave to be set as Active
97
                while (!BuildDaemon.mShutDown)
96
                while (!BuildDaemon.mShutDown)
98
                {
97
                {
Line 178... Line 177...
178
                    // entire build log
177
                    // entire build log
179
                    mPhase.setPhase("flagStartBuildCycle");
178
                    mPhase.setPhase("flagStartBuildCycle");
180
                    flagStartBuildCycle();
179
                    flagStartBuildCycle();
181
                    mReporting.resetData();
180
                    mReporting.resetData();
182
                    
181
                    
183
                    mLogger.error("Collect fresh MetaData");
182
                    mLogger.warn("Collect fresh MetaData");
184
                    mPhase.setPhase("collectMetaData");
183
                    mPhase.setPhase("collectMetaData");
185
                    mRippleEngine.collectMetaData();
184
                    mRippleEngine.collectMetaData();
186
                    
185
                    
187
                    // Save the build file
186
                    // Save the build file
188
                    mLogger.error("Save buildfile");
187
                    mLogger.warn("Save buildfile");
189
                    mPhase.setPhase("Save buildfile");
188
                    mPhase.setPhase("Save buildfile");
190
                    saveBuildFile(mBuildFileContent);
189
                    saveBuildFile(mBuildFileContent);
191
 
190
 
192
                    // deliver change to product baseline
191
                    // deliver change to product baseline
193
                    mLogger.error("run calling setViewUp");
192
                    mLogger.warn("run calling setViewUp");
194
                    mPhase.setPhase("Setup View for build");
193
                    mPhase.setPhase("Setup View for build");
195
                    deliverChange("AbtSetUp", true, true);
194
                    deliverChange("AbtSetUp", true, true);
196
 
195
 
197
                    mLogger.error("run calling deliverChange - the actual build");
196
                    mLogger.warn("run calling deliverChange - the actual build");
198
                    mPhase.setPhase("deliverChange for Build");
197
                    mPhase.setPhase("deliverChange for Build");
199
                    deliverChange(null, true, false);
198
                    deliverChange(null, true, false);
200
                    
199
                    
201
                    mLogger.error("run calling deliverChange on AbtTearDown");
200
                    mLogger.warn("run calling deliverChange on AbtTearDown");
202
                    mPhase.setPhase("AbtTearDown");
201
                    mPhase.setPhase("AbtTearDown");
203
                    deliverChange("AbtTearDown", false, true);
202
                    deliverChange("AbtTearDown", false, true);
204
 
203
 
205
                    if (mReporting.buildFailureLogFile != null)
204
                    if (mReporting.buildFailureLogFile != null)
206
                    {
205
                    {
207
                        mLogger.error("run calling excludeFromBuild");
206
                        mLogger.warn("run calling excludeFromBuild");
208
                        mPhase.setPhase("excludeFromBuild");
207
                        mPhase.setPhase("excludeFromBuild");
209
                        mReleaseManager.excludeFromBuild(false, 
208
                        mReleaseManager.excludeFromBuild(false, 
210
                                                         mReporting.packageVersionId,
209
                                                         mReporting.packageVersionId,
211
                                                         mReporting.packageVersion, 
210
                                                         mReporting.packageVersion, 
212
                                                         mRtagId, 
211
                                                         mRtagId, 
Line 224... Line 223...
224
            //---------------------------------------------------------------
223
            //---------------------------------------------------------------
225
            //    Build loop exception handling (only)
224
            //    Build loop exception handling (only)
226
            //
225
            //
227
            catch (ShouldNotContinueExpection e)
226
            catch (ShouldNotContinueExpection e)
228
            {
227
            {
229
                mLogger.error("ShouldNotContinueExpection:" + e.getMessage());
228
                mLogger.error("ShouldNotContinueExpection:{}", e.getMessage());
230
            }
229
            }
231
            catch (SQLException e)
230
            catch (SQLException e)
232
            {
231
            {
233
                // oracle connection issues
232
                // oracle connection issues
234
                //  Request a prolonged sleep at the start of the build loop
233
                //  Request a prolonged sleep at the start of the build loop
Line 276... Line 275...
276
	        //  Uncaptured exception
275
	        //  Uncaptured exception
277
	        //  These are not good. Current mechanism to handle this condition is:
276
	        //  These are not good. Current mechanism to handle this condition is:
278
	        //      1) Email build system administrator
277
	        //      1) Email build system administrator
279
	        //      2) Pause the build system
278
	        //      2) Pause the build system
280
	        //  
279
	        //  
281
                mLogger.error("run indefinitePause " + e.toString());
280
                mLogger.error("run indefinitePause {}", e);
282
                
281
                
283
                // DEVI 51366 force sleep at beginning of while loop
282
                // DEVI 51366 force sleep at beginning of while loop
284
                mException = true;
283
                mException = true;
285
                
284
                
286
                String cause = e.getMessage();
285
                String cause = e.getMessage();
Line 311... Line 310...
311
            }
310
            }
312
        }
311
        }
313
        try {
312
        try {
314
            mReleaseManager.clearCurrentPackageBeingBuilt(mRconId);
313
            mReleaseManager.clearCurrentPackageBeingBuilt(mRconId);
315
        } catch (Exception e) {
314
        } catch (Exception e) {
316
            mLogger.error("Exception in clearCurrentPackageBeingBuilt:" + e.getMessage());
315
            mLogger.error("Exception in clearCurrentPackageBeingBuilt:{}", e.getMessage());
317
        }
316
        }
318
        mPhase.setPhase("Exit Thread");
317
        mPhase.setPhase("Exit Thread");
319
    }
318
    }
320
 
319
 
321
    /** Determine if we are allowed to continue in this build cycle
320
    /** Determine if we are allowed to continue in this build cycle
Line 339... Line 338...
339
            throw new ExitException();
338
            throw new ExitException();
340
        }
339
        }
341
        
340
        
342
        try
341
        try
343
        {
342
        {
344
            mLogger.error("allowedToContinue calling mReleaseManager.connect");                      
343
            mLogger.warn("allowedToContinue calling mReleaseManager.connect");                      
345
            mReleaseManager.connect();
344
            mReleaseManager.connect();
346
            
345
            
347
            //  Ensure that the machine is a part of the current build set
346
            //  Ensure that the machine is a part of the current build set
348
            mLogger.error("allowedToContinue calling mReleaseManager.queryReleaseConfig");                      
347
            mLogger.warn("allowedToContinue calling mReleaseManager.queryReleaseConfig");                      
349
            if ( !mReleaseManager.queryReleaseConfig(mRtagId, mRconId, BuildDaemon.mHostname, getMode(), mStartTime) )
348
            if ( !mReleaseManager.queryReleaseConfig(mRtagId, mRconId, BuildDaemon.mHostname, getMode(), mStartTime) )
350
            {
349
            {
351
                mLogger.warn("allowedToContinue queryReleaseConfig failed");
350
                mLogger.warn("allowedToContinue queryReleaseConfig failed");
352
                mReleaseManager.disconnect();
351
                mReleaseManager.disconnect();
353
                throw new ExitException();
352
                throw new ExitException();
354
            }
353
            }
355
            
354
            
356
            
355
            
357
            //  Check for scheduled downtime or indefinite pause
356
            //  Check for scheduled downtime or indefinite pause
358
            MutableDate resumeTime = new MutableDate();
357
            MutableDate resumeTime = new MutableDate();
359
            mLogger.error("allowedToContinue calling mReleaseManager.queryRunLevelSchedule");                      
358
            mLogger.warn("allowedToContinue calling mReleaseManager.queryRunLevelSchedule");                      
360
            if ( !mReleaseManager.queryRunLevelSchedule(resumeTime) )
359
            if ( !mReleaseManager.queryRunLevelSchedule(resumeTime) )
361
            {
360
            {
362
              mLogger.info("allowedToContinue scheduled downtime");
361
              mLogger.info("allowedToContinue scheduled downtime");
363
              mReleaseManager.disconnect();
362
              mReleaseManager.disconnect();
364
              throw new ShouldNotContinueExpection("Scheduled downtime");
363
              throw new ShouldNotContinueExpection("Scheduled downtime");
365
            }
364
            }
366
            
365
            
367
            //
366
            //
368
            //  If commanded to pause, then wait around until the command has been removed.
367
            //  If commanded to pause, then wait around until the command has been removed.
369
            //
368
            //
370
            mLogger.error("allowedToContinue calling mReleaseManager.queryDirectedRunLevel");                      
369
            mLogger.warn("allowedToContinue calling mReleaseManager.queryDirectedRunLevel");                      
371
            if ( !mReleaseManager.queryDirectedRunLevel(mRconId) )
370
            if ( !mReleaseManager.queryDirectedRunLevel(mRconId) )
372
            {
371
            {
373
                mLogger.error("allowedToContinue Pause Detected");
372
                mLogger.warn("allowedToContinue Pause Detected");
374
                throw new ShouldNotContinueExpection("Pause Detected");
373
                throw new ShouldNotContinueExpection("Pause Detected");
375
            }
374
            }
376
          
375
          
377
        }
376
        }
378
        finally
377
        finally
379
        {
378
        {
380
          // this block is executed regardless of what happens in the try block
379
          // this block is executed regardless of what happens in the try block
381
          // even if an exception is thrown
380
          // even if an exception is thrown
382
          // ensure disconnect
381
          // ensure disconnect
383
          mLogger.error("allowedToContinue calling mReleaseManager.disconnect");                      
382
          mLogger.warn("allowedToContinue calling mReleaseManager.disconnect");                      
384
          mReleaseManager.disconnect();
383
          mReleaseManager.disconnect();
385
        }
384
        }
386
 
385
 
387
        // One last test for a shut down request
386
        // One last test for a shut down request
388
        if (BuildDaemon.mShutDown)
387
        if (BuildDaemon.mShutDown)