Subversion Repositories DevTools

Rev

Rev 930 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 930 Rev 2541
Line 11... Line 11...
11
import java.io.DataInputStream;
11
import java.io.DataInputStream;
12
import java.io.File;
12
import java.io.File;
13
import java.io.FileInputStream;
13
import java.io.FileInputStream;
14
import java.io.InputStreamReader;
14
import java.io.InputStreamReader;
15
import java.sql.SQLException;
15
import java.sql.SQLException;
-
 
16
import java.lang.System;
16
 
17
 
17
import org.apache.log4j.Logger;
18
import org.apache.log4j.Logger;
18
 
19
 
19
/**Master Thread sub component
20
/**Master Thread sub component
20
 */
21
 */
Line 25... Line 26...
25
  /**Logger
26
  /**Logger
26
   * @attribute
27
   * @attribute
27
   */
28
   */
28
  private static final Logger mLogger = Logger.getLogger(MasterThread.class);
29
  private static final Logger mLogger = Logger.getLogger(MasterThread.class);
29
 
30
 
-
 
31
  /**Nagios Monitoring
-
 
32
   * @attribute
-
 
33
   */
-
 
34
  protected long mPhaseStartTime = 0;
-
 
35
 
30
   /**constructor
36
   /**constructor
31
   */
37
   */
32
  public MasterThread(int rtag_id, int rcon_id, String unitTest)
38
  public MasterThread(int rtag_id, int rcon_id, String unitTest)
33
  {
39
  {
34
    mLogger.warn("MasterThread rtag_id " + rtag_id + " rcon_id " + rcon_id);
40
    mLogger.warn("MasterThread rtag_id " + rtag_id + " rcon_id " + rcon_id);
Line 56... Line 62...
56
 
62
 
57
    while(!exit)
63
    while(!exit)
58
    {
64
    {
59
      try
65
      try
60
      {
66
      {
-
 
67
        mPhaseStartTime = 0;
61
        mLogger.fatal("run calling sleepCheck");
68
        mLogger.fatal("run calling sleepCheck");
62
        sleepCheck();
69
        sleepCheck();
63
        mLogger.fatal("run calling rippleEngine.collectMetaData");
70
        mLogger.fatal("run calling rippleEngine.collectMetaData");
-
 
71
        mPhaseStartTime = System.currentTimeMillis();
64
        rippleEngine.collectMetaData();
72
        rippleEngine.collectMetaData();
-
 
73
        mPhaseStartTime = 0;
65
        
74
        
66
        if ( Thread.currentThread().isInterrupted() )
75
        if ( Thread.currentThread().isInterrupted() )
67
        {
76
        {
68
          mLogger.warn("run is interrupted");
77
          mLogger.warn("run is interrupted");
69
          // unit test technique
78
          // unit test technique
Line 197... Line 206...
197
                // a dummy build file did not apply
206
                // a dummy build file did not apply
198
                // Publishing is done outside ant by design
207
                // Publishing is done outside ant by design
199
                // The preference is to do all release manager work outside ant
208
                // The preference is to do all release manager work outside ant
200
  
209
  
201
                boolean buildErrorOccurred = true;
210
                boolean buildErrorOccurred = true;
-
 
211
                boolean publishError = false;
-
 
212
 
202
                // max 50 characters
213
                // max 50 characters
203
                String rootCause = "Error publishing to Release Manager";
214
                String rootCause = "Error publishing to Release Manager";
204
                try
215
                try
205
                {
216
                {
206
                  if ( mReportingTestBuild.compareTo("0") != 0 )
217
                  if ( mReportingTestBuild.compareTo("0") != 0 )
Line 236... Line 247...
236
                      Integer rtagId = new Integer(mRtagId);
247
                      Integer rtagId = new Integer(mRtagId);
237
                      
248
                      
238
                      if ( mGbeGatherMetricsOnly == null )
249
                      if ( mGbeGatherMetricsOnly == null )
239
                      {
250
                      {
240
                        // publish to release manager
251
                        // publish to release manager
-
 
252
                        // On error mAutoMakeReleaseCause will contain error string
241
                        mLogger.fatal("run calling mReleaseManager.autoMakeRelease");                      
253
                        mLogger.fatal("run calling mReleaseManager.autoMakeRelease");
-
 
254
                        publishError =  mReleaseManager.autoMakeRelease(
242
                        mReleaseManager.autoMakeRelease(rtagId.toString(),
255
                                                    rtagId.toString(),
243
                                                        mReportingPackageName,
256
                                                    mReportingPackageName,
244
                                                        mReportingPackageExtension,
257
                                                    mReportingPackageExtension,
245
                                                        mReportingPackageVersion,
258
                                                    mReportingPackageVersion,
246
                                                        reportingNewVcsTag,
259
                                                    reportingNewVcsTag,
247
                                                        mReportingPackageDepends,
260
                                                    mReportingPackageDepends,
248
                                                        mReportingIsRipple);
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
                        }
249
                      }
270
                      }
250
                      
-
 
-
 
271
 
251
                      FileInputStream abtmetrics = new FileInputStream( rtagId.toString() + "abtmetrics.txt" );
272
                      FileInputStream abtmetrics = new FileInputStream( rtagId.toString() + "abtmetrics.txt" );
252
                      DataInputStream din = new DataInputStream( abtmetrics );
273
                      DataInputStream din = new DataInputStream( abtmetrics );
253
                      InputStreamReader isr = new InputStreamReader( din );
274
                      InputStreamReader isr = new InputStreamReader( din );
254
                      BufferedReader br = new BufferedReader( isr );
275
                      BufferedReader br = new BufferedReader( isr );
255
                      String metrics = br.readLine();
276
                      String metrics = br.readLine();
Line 310... Line 331...
310
                    catch( NumberFormatException nfe )
331
                    catch( NumberFormatException nfe )
311
                    {
332
                    {
312
                    }
333
                    }
313
                    mLogger.fatal("run calling excludeFromBuild");                      
334
                    mLogger.fatal("run calling excludeFromBuild");                      
314
                    mReleaseManager.excludeFromBuild(mReportingPackageVersionId, null, rtagId.toString(), null, rootCause, null, false, testBuildInstruction);
335
                    mReleaseManager.excludeFromBuild(mReportingPackageVersionId, null, rtagId.toString(), null, rootCause, null, false, testBuildInstruction);
-
 
336
 
-
 
337
                    if ( ! publishError )
-
 
338
                    {
315
                    throw new Exception("an error occurred publishing to Version Control or Release Manager");
339
                        throw new Exception("an error occurred publishing to Version Control or Release Manager");
-
 
340
                    }
316
                  }
341
                  }
317
                  
342
                  
318
                  // DEVI 55364
343
                  // DEVI 55364
319
                  // Package has not been built on all configured platforms
344
                  // Package has not been built on all configured platforms
320
                  // Under normal circumstances, this root cause will be masked by a previously reported error
345
                  // Under normal circumstances, this root cause will be masked by a previously reported error
Line 358... Line 383...
358
            
383
            
359
            // generate build files
384
            // generate build files
360
            mLogger.warn("run generating build files");
385
            mLogger.warn("run generating build files");
361
            mLogger.fatal("run calling planRelease");
386
            mLogger.fatal("run calling planRelease");
362
            rippleEngine.planRelease();
387
            rippleEngine.planRelease();
-
 
388
            mPhaseStartTime = System.currentTimeMillis();
363
            mLogger.fatal("run calling reportChange");                      
389
            mLogger.fatal("run calling reportChange");                      
364
            rippleEngine.reportChange();
390
            rippleEngine.reportChange();
-
 
391
            mPhaseStartTime = 0;
365
 
392
 
366
            // get the build file from the ripple engine
393
            // get the build file from the ripple engine
367
            rippleEngine.getFirstBuildFileContent(buildFileContent, addendum);
394
            rippleEngine.getFirstBuildFileContent(buildFileContent, addendum);
368
            
395
            
369
            if ( addendum.value.compareTo("non generic") == 0 )
396
            if ( addendum.value.compareTo("non generic") == 0 )
Line 508... Line 535...
508
  protected char getMode()
535
  protected char getMode()
509
  {
536
  {
510
    mLogger.debug("getMode");
537
    mLogger.debug("getMode");
511
    return 'M';
538
    return 'M';
512
  }
539
  }
-
 
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
  
513
}
568
}
514
569