Subversion Repositories DevTools

Rev

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

Rev 894 Rev 896
Line 2... Line 2...
2
 
2
 
3
import com.erggroup.buildtool.daemon.ResumeTimerTask;
3
import com.erggroup.buildtool.daemon.ResumeTimerTask;
4
import com.erggroup.buildtool.ripple.ReleaseManager;
4
import com.erggroup.buildtool.ripple.ReleaseManager;
5
import com.erggroup.buildtool.smtp.Smtpsend;
5
import com.erggroup.buildtool.smtp.Smtpsend;
6
import com.erggroup.buildtool.ripple.RippleEngine;
6
import com.erggroup.buildtool.ripple.RippleEngine;
-
 
7
import com.erggroup.buildtool.ripple.MutableString;
7
 
8
 
8
import java.io.BufferedReader;
9
import java.io.BufferedReader;
9
import java.io.File;
10
import java.io.File;
10
import java.io.FileNotFoundException;
11
import java.io.FileNotFoundException;
11
import java.io.FileOutputStream;
12
import java.io.FileOutputStream;
Line 53... Line 54...
53
  protected ReleaseManager mReleaseManager;
54
  protected ReleaseManager mReleaseManager;
54
 
55
 
55
  /**configured GBEBUILDFILTER for this BuildThread
56
  /**configured GBEBUILDFILTER for this BuildThread
56
   * @attribute
57
   * @attribute
57
   */
58
   */
58
  protected String mGbebuildfilter = "";
59
  protected String mGbebuildfilter = null;
-
 
60
 
-
 
61
  /**unit test support
-
 
62
   * @attribute
-
 
63
   */
-
 
64
  protected String mUnitTest = "";
59
 
65
 
60
  /**
66
  /**
61
   * @aggregation composite
67
   * @aggregation composite
62
   */
68
   */
63
  protected static ResumeTimerTask mResumeTimerTask;
69
  protected static ResumeTimerTask mResumeTimerTask;
Line 163... Line 169...
163
  /**Non null determines to only gather metrics
169
  /**Non null determines to only gather metrics
164
   * @attribute
170
   * @attribute
165
   */
171
   */
166
  protected static final String mGbeGatherMetricsOnly = System.getenv("GBE_GATHER_METRICS");
172
  protected static final String mGbeGatherMetricsOnly = System.getenv("GBE_GATHER_METRICS");
167
 
173
 
-
 
174
  /**Non null determines to only gather metrics
-
 
175
   * @attribute
-
 
176
   */
-
 
177
  protected boolean mRecoverable;
-
 
178
 
168
  /**constructor
179
  /**constructor
169
   */
180
   */
170
  BuildThread()
181
  BuildThread()
171
  {
182
  {
172
    super(mThreadGroup, "");
183
    super(mThreadGroup, "");
173
    mLogger.debug("BuildThread");
184
    mLogger.debug("BuildThread");
174
    mSleep = false;
185
    mSleep = false;
175
    mException = false;
186
    mException = false;
176
    mErrorReported = false;
187
    mErrorReported = false;
177
    mReleaseManager = new ReleaseManager();
188
    mReleaseManager = new ReleaseManager();
-
 
189
    mRecoverable = false;
178
    
190
    
179
    // no need to be synchronized - BuildThreads are instantiated in a single thread
191
    // no need to be synchronized - BuildThreads are instantiated in a single thread
180
    if ( mResumeTimerTask == null )
192
    if ( mResumeTimerTask == null )
181
    {
193
    {
182
      mResumeTimerTask = new ResumeTimerTask();
194
      mResumeTimerTask = new ResumeTimerTask();
Line 222... Line 234...
222
    try
234
    try
223
    {
235
    {
224
      mRunLevel = RunLevel.IDLE;
236
      mRunLevel = RunLevel.IDLE;
225
      mLogger.warn("allowedToProceed changing run level to IDLE for rcon_id " + mRconId);
237
      mLogger.warn("allowedToProceed changing run level to IDLE for rcon_id " + mRconId);
226
      mRunLevel.persist(mReleaseManager, mRconId);
238
      mRunLevel.persist(mReleaseManager, mRconId);
-
 
239
      if ( master )
-
 
240
      {
-
 
241
        mReleaseManager.discardVersion();
-
 
242
      }
227
      mReleaseManager.clearCurrentPackageBeingBuilt(mRconId);      
243
      mReleaseManager.clearCurrentPackageBeingBuilt(mRconId);      
228
    }
244
    }
229
    catch(SQLException e)
245
    catch(SQLException e)
230
    {
246
    {
231
      mLogger.warn("allowedToProceed caught SQLException");
247
      mLogger.warn("allowedToProceed caught SQLException");
Line 255... Line 271...
255
    boolean proceed = false;
271
    boolean proceed = false;
256
    
272
    
257
    while ( !proceed )
273
    while ( !proceed )
258
    {
274
    {
259
      mReleaseManager.connect();
275
      mReleaseManager.connect();
260
      if ( !mReleaseManager.queryReleaseConfig(mRtagId, mRconId, BuildDaemon.mHostname, getMode(), mGbebuildfilter) )
276
      if ( !mReleaseManager.queryReleaseConfig(mRtagId, mRconId, BuildDaemon.mHostname, getMode()) )
261
      {
277
      {
262
        mReleaseManager.disconnect();
278
        mReleaseManager.disconnect();
263
        mLogger.warn("allowedToProceed queryReleaseConfig failed");
279
        mLogger.warn("allowedToProceed queryReleaseConfig failed");
264
        throw new ExitException();
280
        throw new ExitException();
265
      }
281
      }
266
      
282
      
267
      Date resumeTime = new Date( 0 );
283
      Date resumeTime = new Date( 0 );
268
      if ( !mReleaseManager.queryRunLevelSchedule(resumeTime) )
284
      if ( !mReleaseManager.queryRunLevelSchedule(resumeTime, mRecoverable) )
269
      {
285
      {
270
        mLogger.info("allowedToProceed scheduled downtime");
286
        mLogger.info("allowedToProceed scheduled downtime");
271
        mReleaseManager.disconnect();
287
        mReleaseManager.disconnect();
272
        mRunLevel = RunLevel.PAUSED;
288
        mRunLevel = RunLevel.PAUSED;
273
        mLogger.warn("allowedToProceed changing run level to PAUSED for rcon_id " + mRconId);
289
        mLogger.warn("allowedToProceed changing run level to PAUSED for rcon_id " + mRconId);
Line 299... Line 315...
299
          {
315
          {
300
            mLogger.warn("allowedToProceed wait");
316
            mLogger.warn("allowedToProceed wait");
301
            mSynchroniser.wait();
317
            mSynchroniser.wait();
302
            mLogger.warn("allowedToProceed wait returned");
318
            mLogger.warn("allowedToProceed wait returned");
303
             
319
             
304
            if ( mGbebuildfilter.compareTo("unit test not allowed to proceed") == 0 )
320
            if ( mUnitTest.compareTo("unit test not allowed to proceed") == 0 )
305
            {
321
            {
306
              throw new ExitException();
322
              throw new ExitException();
307
            }
323
            }
308
          }
324
          }
309
          catch( InterruptedException e )
325
          catch( InterruptedException e )
Line 339... Line 355...
339
          mReleaseManager.disconnect();
355
          mReleaseManager.disconnect();
340
          proceed = true;
356
          proceed = true;
341
        }
357
        }
342
      }
358
      }
343
    }
359
    }
-
 
360
    
-
 
361
    mRecoverable = false;
344
  }
362
  }
345
 
363
 
346
  /**periodically 
364
  /**periodically 
347
   * a) performs disk housekeeping
365
   * a) performs disk housekeeping
348
   * b) determines if a minimum threshold of disk space is available
366
   * b) determines if a minimum threshold of disk space is available
Line 371... Line 389...
371
        mLogger.warn("checkEnvironment changing run level to CANNOT_CONTINUE for rcon_id " + mRconId);
389
        mLogger.warn("checkEnvironment changing run level to CANNOT_CONTINUE for rcon_id " + mRconId);
372
        mRunLevel.persist(mReleaseManager, mRconId);
390
        mRunLevel.persist(mReleaseManager, mRconId);
373
        try
391
        try
374
        {
392
        {
375
          // to do, sleep for periodicMs
393
          // to do, sleep for periodicMs
376
          if ( mGbebuildfilter.compareTo("unit test check environment") != 0 )
394
          if ( mUnitTest.compareTo("unit test check environment") != 0 )
377
          {
395
          {
378
            mLogger.warn("checkEnvironment sleep 5 mins below disk free threshold");
396
            mLogger.warn("checkEnvironment sleep 5 mins below disk free threshold");
379
            Thread.sleep(300000);
397
            Thread.sleep(300000);
380
            mLogger.info("checkEnvironment sleep returned");
398
            mLogger.info("checkEnvironment sleep returned");
381
          }
399
          }
Line 433... Line 451...
433
          // 5 days = 432,000,000 milliseconds
451
          // 5 days = 432,000,000 milliseconds
434
          if ( ( System.currentTimeMillis() - children[ child ].lastModified() ) > 432000000 )
452
          if ( ( System.currentTimeMillis() - children[ child ].lastModified() ) > 432000000 )
435
          {
453
          {
436
            // the directory is over 5 days old
454
            // the directory is over 5 days old
437
            mLogger.warn("housekeep deleting directory " + children[ child ].getName());
455
            mLogger.warn("housekeep deleting directory " + children[ child ].getName());
438
            if ( mGbebuildfilter.compareTo("unit test check environment") != 0 )
456
            if ( mUnitTest.compareTo("unit test check environment") != 0 )
439
            {
457
            {
440
              deleteDirectory( children[ child ] );
458
              deleteDirectory( children[ child ] );
441
            }
459
            }
442
          }
460
          }
443
        }
461
        }
Line 507... Line 525...
507
    {
525
    {
508
      File cwd = new File( "." );
526
      File cwd = new File( "." );
509
 
527
 
510
      // 5G = 5368709120 bytes
528
      // 5G = 5368709120 bytes
511
      // 1G = 1073741824 bytes - useful for testing
529
      // 1G = 1073741824 bytes - useful for testing
512
      if ( mGbebuildfilter.compareTo("unit test check environment") == 0 )
530
      if ( mUnitTest.compareTo("unit test check environment") == 0 )
513
      {
531
      {
514
        if ( ReleaseManager.mPersistedRunLevelCollection.size() == 0 )
532
        if ( ReleaseManager.mPersistedRunLevelCollection.size() == 0 )
515
        {
533
        {
516
          retVal = false;
534
          retVal = false;
517
        }
535
        }
Line 656... Line 674...
656
            }
674
            }
657
            else
675
            else
658
            {
676
            {
659
              inject += "no\"/>" + lf;
677
              inject += "no\"/>" + lf;
660
            }
678
            }
661
            
679
                        
662
            // insert a GBE_BUILDFILTER property if necessary
680
            // insert a GBE_BUILDFILTER property if necessary
663
            if ( mGbebuildfilter.length() > 0 )
681
            if ( mGbebuildfilter != null && mGbebuildfilter.length() > 0 )
664
            {
682
            {
665
              inject += "<property name=\"abt_GBE_BUILDFILTER\" value=\"" + mGbebuildfilter + "\"/>" + lf;
683
              inject += "<property name=\"abt_GBE_BUILDFILTER\" value=\"" + mGbebuildfilter + "\"/>" + lf;
666
            }
684
            }
667
            
685
            
668
            mLogger.info("deliverChange injecting " + inject);
686
            mLogger.info("deliverChange injecting " + inject);
Line 760... Line 778...
760
    
778
    
761
  }
779
  }
762
  
780
  
763
  /**sets up a ClearCase static view
781
  /**sets up a ClearCase static view
764
   */
782
   */
765
  protected void setViewUp(String content, boolean master)
783
  protected void setViewUp(String content, boolean master) throws SQLException, Exception
766
  {
784
  {
767
    mLogger.debug("setViewUp");
785
    mLogger.debug("setViewUp");
768
    mReportingBuildFailureLogFile = null;
786
    mReportingBuildFailureLogFile = null;
769
    mErrorReported = false;
787
    mErrorReported = false;
770
    
788
    
Line 772... Line 790...
772
    {
790
    {
773
      // do not run AbtSetUp on slave in metrics gathering mode
791
      // do not run AbtSetUp on slave in metrics gathering mode
774
      return;
792
      return;
775
    }
793
    }
776
    
794
    
-
 
795
    MutableString buildFilter = new MutableString();
-
 
796
    mReleaseManager.connect();
-
 
797
    mReleaseManager.queryBuildFilter(mRconId, buildFilter);
-
 
798
    mReleaseManager.disconnect();
-
 
799
    mGbebuildfilter = buildFilter.value;
-
 
800
 
777
    // run ant on the AbtSetUp target
801
    // run ant on the AbtSetUp target
778
    deliverChange(content, "AbtSetUp", master);
802
    deliverChange(content, "AbtSetUp", master);
779
  }
803
  }
780
  
804
  
781
  /**Checks the archive for the <packageName>/<packageVersion>/built.<machtype> existence
805
  /**Checks the archive for the <packageName>/<packageVersion>/built.<machtype> existence