Subversion Repositories DevTools

Rev

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

Rev 842 Rev 854
Line 87... Line 87...
87
  /**Set true when last build cycle was benign.
87
  /**Set true when last build cycle was benign.
88
   * @attribute
88
   * @attribute
89
   */
89
   */
90
  protected boolean mSleep;
90
  protected boolean mSleep;
91
 
91
 
-
 
92
  /**Set true when ant error reported on any target.
-
 
93
   * @attribute
-
 
94
   */
-
 
95
  private boolean mErrorReported;
-
 
96
 
-
 
97
  /**Set true when ant error reported on AbtSetUp target.
-
 
98
   * @attribute
-
 
99
   */
-
 
100
  private boolean mSetUpErrorReported;
-
 
101
 
92
  /**Logger
102
  /**Logger
93
   * @attribute
103
   * @attribute
94
   */
104
   */
95
  private static final Logger mLogger = Logger.getLogger(BuildThread.class);
105
  private static final Logger mLogger = Logger.getLogger(BuildThread.class);
96
 
106
 
Line 99... Line 109...
99
  BuildThread()
109
  BuildThread()
100
  {
110
  {
101
    super(mThreadGroup, "");
111
    super(mThreadGroup, "");
102
    mLogger.debug("BuildThread");
112
    mLogger.debug("BuildThread");
103
    mSleep = false;
113
    mSleep = false;
-
 
114
    mErrorReported = false;
-
 
115
    mSetUpErrorReported = false;
104
    mReleaseManager = new ReleaseManager();
116
    mReleaseManager = new ReleaseManager();
105
    
117
    
106
    // no need to be synchronized - BuildThreads are instantiated in a single thread
118
    // no need to be synchronized - BuildThreads are instantiated in a single thread
107
    if ( mResumeTimerTask == null )
119
    if ( mResumeTimerTask == null )
108
    {
120
    {
Line 323... Line 335...
323
    
335
    
324
    try
336
    try
325
    {
337
    {
326
      // DEVI 46729, 46730, solaris 10 core dumps implicate deleteDirectory
338
      // DEVI 46729, 46730, solaris 10 core dumps implicate deleteDirectory
327
      // let each BuildThread look after its own housekeeping
339
      // let each BuildThread look after its own housekeeping
328
      File ocwd = new File( "." );
340
      File ocwd = new File( BuildDaemon.mGbeLog );
-
 
341
      File hcwd = new File( ocwd, BuildDaemon.mHostname );
329
      File cwd = new File( ocwd.getAbsolutePath() + System.getProperty( "file.separator" ) + mRtagId );
342
      File cwd = new File( hcwd, String.valueOf( mRtagId ) );
330
 
343
 
331
      File[] children = cwd.listFiles( filter );
344
      File[] children = cwd.listFiles( filter );
332
      
345
      
333
      if ( children != null )
346
      if ( children != null )
334
      {
347
      {
335
        for ( int child=0; child < children.length; child++ )
348
        for ( int child=0; child < children.length; child++ )
336
        {
349
        {
337
          // child is named uniquely after an rtag_id
350
          // child is named uniquely to encapsulate a build
-
 
351
          // 5 days = 432,000,000 milliseconds
338
          File[] grandchildren = children[ child ].listFiles( filter );
352
          if ( ( System.currentTimeMillis() - children[ child ].lastModified() ) > 432000000 )
339
          
353
          {
340
          if ( grandchildren != null )
354
            // the directory is over 5 days old
341
          {
355
            mLogger.warn("housekeep deleting directory " + children[ child ].getName());
342
            for ( int grandchild=0; grandchild < grandchildren.length; grandchild++ )
356
            if ( mGbebuildfilter.compareTo("unit test check environment") != 0 )
343
            {
357
            {
344
              // child is named uniquely to encapsulate a build
-
 
345
              // 5 days = 432,000,000 milliseconds
-
 
346
              if ( ( System.currentTimeMillis() - grandchildren[ grandchild ].lastModified() ) > 432000000 )
-
 
347
              {
-
 
348
                // the directory is over 5 days old
-
 
349
                mLogger.warn("housekeep deleting directory " + grandchildren[ grandchild ].getName());
-
 
350
                if ( mGbebuildfilter.compareTo("unit test check environment") != 0 )
-
 
351
                {
-
 
352
                  deleteDirectory( grandchildren[ grandchild ] );
358
              deleteDirectory( children[ child ] );
353
                }
-
 
354
              }
-
 
355
            }
359
            }
356
          }
360
          }
357
        }
361
        }
358
      }
362
      }
359
    }
363
    }
Line 474... Line 478...
474
 
478
 
475
  /**injects GBE_BUILDFILTER into the passed buildFileContent
479
  /**injects GBE_BUILDFILTER into the passed buildFileContent
476
   * builds a buildFile from the buildFileContent
480
   * builds a buildFile from the buildFileContent
477
   * triggers ant to operate on the buildFile
481
   * triggers ant to operate on the buildFile
478
   */
482
   */
479
  protected void deliverChange(String buildFileContent, String target, boolean master) throws Exception
483
  protected void deliverChange(String buildFileContent, String target, boolean master)
480
  {
484
  {
481
    mLogger.debug("deliverChange");
485
    mLogger.debug("deliverChange");
-
 
486
    
-
 
487
    if ( ( target == null || target.compareTo( "AbtPublish" ) == 0 ) && ( mErrorReported ) )
-
 
488
    {
-
 
489
      // previous error occurred processing the build file content
-
 
490
      return;
-
 
491
    }
-
 
492
    
482
    File buildFile = new File(mRtagId + "build.xml");
493
    File buildFile = new File(mRtagId + "build.xml");
483
    
494
    
484
    try
495
    try
485
    {
496
    {
486
      // clear the file contents
497
      // clear the file contents
Line 532... Line 543...
532
        FileWriter buildFileWriter = new FileWriter(buildFile);
543
        FileWriter buildFileWriter = new FileWriter(buildFile);
533
        buildFileWriter.write(sanitisedBFC);
544
        buildFileWriter.write(sanitisedBFC);
534
        buildFileWriter.close();
545
        buildFileWriter.close();
535
      }
546
      }
536
      
547
      
537
      String antHome = System.getenv("ANT_HOME");
-
 
538
      
-
 
539
      if ( antHome == null )
-
 
540
      {
-
 
541
      	mLogger.fatal("deliverChange ANT_HOME not set");
-
 
542
        throw new Exception();
-
 
543
      }
-
 
544
 
-
 
545
      Project p = new Project();
548
      Project p = new Project();
546
      p.setProperty("ant.file", buildFile.getAbsolutePath());
549
      p.setProperty("ant.file", buildFile.getAbsolutePath());
547
      DefaultLogger dl = new DefaultLogger();
550
      DefaultLogger dl = new DefaultLogger();
548
      PrintStream ps = new PrintStream(mRtagId + ".log");
551
      PrintStream ps = new PrintStream(mRtagId + ".log");
549
      dl.setOutputPrintStream(ps);
552
      dl.setOutputPrintStream(ps);
Line 564... Line 567...
564
      mLogger.warn("deliverChange ant returned");
567
      mLogger.warn("deliverChange ant returned");
565
    }
568
    }
566
    catch( BuildException e )
569
    catch( BuildException e )
567
    {
570
    {
568
      mLogger.debug("deliverChange caught BuildException, big deal, the build failed " + e.getMessage());
571
      mLogger.debug("deliverChange caught BuildException, big deal, the build failed " + e.getMessage());
-
 
572
      
-
 
573
      if ( target.compareTo( "AbtSetUp ") == 0 )
-
 
574
      {
-
 
575
        mSetUpErrorReported = true;
-
 
576
      }
-
 
577
 
-
 
578
      mErrorReported = true;
569
    }
579
    }
570
    catch( FileNotFoundException e )
580
    catch( FileNotFoundException e )
571
    {
581
    {
572
      mLogger.error("deliverChange caught FileNotFoundException");
582
      mLogger.error("deliverChange caught FileNotFoundException");
573
    }
583
    }
Line 578... Line 588...
578
    
588
    
579
  }
589
  }
580
  
590
  
581
  /**sets up a ClearCase static view
591
  /**sets up a ClearCase static view
582
   */
592
   */
583
  protected void setViewUp(String content, boolean master) throws Exception
593
  protected void setViewUp(String content, boolean master)
584
  {
594
  {
585
    mLogger.debug("setViewUp");
595
    mLogger.debug("setViewUp");
-
 
596
    mErrorReported = false;
-
 
597
    mSetUpErrorReported = false;
586
    // run ant on the AbtSetUp target
598
    // run ant on the AbtSetUp target
587
    deliverChange(content, "AbtSetUp", master);
599
    deliverChange(content, "AbtSetUp", master);
588
  }
600
  }
589
  
601
  
590
  /**tears down a ClearCase static view
602
  /**tears down a ClearCase static view
591
  */
603
  */
592
  protected void tearViewDown() throws Exception
604
  protected void tearViewDown()
593
  {
605
  {
594
    mLogger.debug("tearViewDown");
606
    mLogger.debug("tearViewDown");
-
 
607
    
-
 
608
    if ( !mSetUpErrorReported )
-
 
609
    {
-
 
610
      // no error setting the view up, so...
595
    // to do run ant on the AbtTearDown target
611
      // run ant on the AbtTearDown target
596
    deliverChange(null, "AbtTearDown", false);
612
      deliverChange(null, "AbtTearDown", false);
-
 
613
    }
597
  }
614
  }
598
  
615
  
599
  /**Checks the archive for the <packageName>/<packageVersion>/built.<machtype> existence
616
  /**Checks the archive for the <packageName>/<packageVersion>/built.<machtype> existence
600
   */
617
   */
601
  protected boolean published(String archive, String packageName, 
618
  protected boolean published(String archive, String packageName,