Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
814 mhunt 1
package com.erggroup.buildtool.daemon;
2
 
3
import com.erggroup.buildtool.daemon.ResumeTimerTask;
4
import com.erggroup.buildtool.ripple.ReleaseManager;
868 mhunt 5
import com.erggroup.buildtool.smtp.Smtpsend;
6
import com.erggroup.buildtool.ripple.RippleEngine;
814 mhunt 7
 
8
import java.io.BufferedReader;
9
import java.io.File;
10
import java.io.FileNotFoundException;
11
import java.io.FileOutputStream;
12
import java.io.FileWriter;
13
import java.io.FilenameFilter;
14
 
15
import java.io.IOException;
16
import java.io.PrintStream;
17
import java.io.StringReader;
18
 
19
import java.sql.SQLException;
20
 
21
import java.util.Date;
22
import java.util.Timer;
23
 
24
import org.apache.log4j.Logger;
25
import org.apache.tools.ant.BuildException;
26
import org.apache.tools.ant.DefaultLogger;
27
import org.apache.tools.ant.Project;
28
import org.apache.tools.ant.ProjectHelper;
29
 
30
/**Build Thread sub component
31
 */
32
public abstract class BuildThread
33
  extends Thread
34
{
35
  /**baseline identifier (which release manager release this BuildThread is dealing with)
36
   * @attribute
37
   */
38
  protected int mRtagId = 0;
39
 
40
  /**unique identifier of this BuildThread
41
   * @attribute
42
   */
43
  protected int mRconId = 0;
44
 
45
  /**
46
   * @aggregation composite
47
   */
48
  protected RunLevel mRunLevel;
49
 
50
  /**
51
   * @aggregation composite
52
   */
53
  protected ReleaseManager mReleaseManager;
54
 
55
  /**configured GBEBUILDFILTER for this BuildThread
56
   * @attribute
57
   */
58
  protected String mGbebuildfilter = "";
59
 
60
  /**
61
   * @aggregation composite
62
   */
63
  protected static ResumeTimerTask mResumeTimerTask;
64
 
65
  /**
66
   * @aggregation composite
67
   */
68
  private static Timer mTimer;
69
 
70
  /**Synchroniser object
71
   * Use to Synchronize on by multiple threads
72
   * @attribute
73
   */
74
  static final Object mSynchroniser = new Object();
75
 
76
  /**BuildThread group
77
   * @attribute
78
   */
79
  public static final ThreadGroup mThreadGroup = new ThreadGroup("BuildThread");
80
 
81
  /**the advertised build file content when either
82
   * a) no package in the baseline has a build requirement
83
   * b) the next package in the baseline with a build requirement is generic
84
   * @attribute
85
   */
86
  protected static final String mDummyBuildFileContent = new String("<dummy/>");
87
 
88
  /**Set true when last build cycle was benign.
89
   * @attribute
90
   */
91
  protected boolean mSleep;
92
 
886 mhunt 93
  /**Set true when last build cycle caught SQLException or Exception.
94
   * @attribute
95
   */
96
  protected boolean mException;
97
 
854 mhunt 98
  /**Set true when ant error reported on any target.
99
   * @attribute
100
   */
101
  private boolean mErrorReported;
102
 
866 mhunt 103
  /**Logger
854 mhunt 104
   * @attribute
105
   */
866 mhunt 106
  private static final Logger mLogger = Logger.getLogger(BuildThread.class);
854 mhunt 107
 
866 mhunt 108
  /**Package name for reporting purposes.
814 mhunt 109
   * @attribute
110
   */
866 mhunt 111
  protected String mReportingPackageName;
814 mhunt 112
 
866 mhunt 113
  /**Package version for reporting purposes.
114
   * @attribute
115
   */
116
  protected String mReportingPackageVersion;
117
 
118
  /**Package extension for reporting purposes.
119
   * @attribute
120
   */
121
  protected String mReportingPackageExtension;
122
 
123
  /**Package location for reporting purposes.
124
   * @attribute
125
   */
126
  protected String mReportingPackageLocation;
127
 
128
  /**Package dependencies for reporting purposes.
129
   * @attribute
130
   */
131
  protected String mReportingPackageDepends;
132
 
133
  /**Is ripple flag for reporting purposes.
134
   * @attribute
135
   */
136
  protected String mReportingIsRipple;
137
 
138
  /**Package version identifier for reporting purposes.
139
   * @attribute
140
   */
141
  protected String mReportingPackageVersionId;
142
 
143
  /**Fully published flag for reporting purposes.
144
   * @attribute
145
   */
146
  protected String mReportingFullyPublished;
147
 
148
  /**New label for reporting purposes.
149
   * @attribute
150
   */
151
  protected String mReportingNewLabel;
152
 
153
  /**Source control interaction for reporting purposes.
154
   * @attribute
155
   */
156
  protected String mReportingDoesNotRequireSourceControlInteraction;
157
 
158
  /**Log file location for reporting purposes.
159
   * @attribute
160
   */
161
  protected String mReportingBuildFailureLogFile;
162
 
868 mhunt 163
  /**Non null determines to only gather metrics
164
   * @attribute
165
   */
166
  protected static final String mGbeGatherMetricsOnly = System.getenv("GBE_GATHER_METRICS");
167
 
814 mhunt 168
  /**constructor
169
   */
170
  BuildThread()
171
  {
172
    super(mThreadGroup, "");
173
    mLogger.debug("BuildThread");
174
    mSleep = false;
886 mhunt 175
    mException = false;
854 mhunt 176
    mErrorReported = false;
814 mhunt 177
    mReleaseManager = new ReleaseManager();
178
 
179
    // no need to be synchronized - BuildThreads are instantiated in a single thread
180
    if ( mResumeTimerTask == null )
181
    {
182
      mResumeTimerTask = new ResumeTimerTask();
183
      mTimer = new Timer();
184
      mResumeTimerTask.setTimer(mTimer);
185
    }
186
  }
187
 
886 mhunt 188
  /**sleeps when mException is set
189
   */
190
  protected void sleepCheck()
191
  {
192
    if (mException)
193
    {
194
      try
195
      {
196
        Integer sleepTime = 300000;
197
        mLogger.warn("sleepCheck sleep " + sleepTime.toString() + " secs");
198
        Thread.sleep(sleepTime);
199
        mLogger.info("sleepCheck sleep returned");
200
      }
201
      catch(InterruptedException e)
202
      {
203
        mLogger.warn("sleepCheck sleep caught InterruptedException");
204
      }
205
 
206
    }
207
    mException = false;
208
  }
209
 
814 mhunt 210
  /**initially changes the run level to IDLE
211
   * determines if the BuildThread is still configured
212
   * a) determines if the BuildThread is running in scheduled downtime
213
   * b) determines if the BuildThread is directed to pause
214
   * changes the run level to PAUSED if a) or b) are true
215
   * throws ExitException when not configured
216
   * implements the sequence diagrams allowed to proceed, not allowed to proceed, exit
217
   */
868 mhunt 218
  protected void allowedToProceed(boolean master) throws ExitException, SQLException, Exception
814 mhunt 219
  {
220
    mLogger.debug("allowedToProceed");
886 mhunt 221
 
222
    try
223
    {
224
      mRunLevel = RunLevel.IDLE;
225
      mLogger.warn("allowedToProceed changing run level to IDLE for rcon_id " + mRconId);
226
      mRunLevel.persist(mReleaseManager, mRconId);
227
      mReleaseManager.clearCurrentPackageBeingBuilt(mRconId);      
228
    }
229
    catch(SQLException e)
230
    {
231
      mLogger.warn("allowedToProceed caught SQLException");
232
    }
814 mhunt 233
 
234
    if (mSleep)
235
    {
236
      try
237
      {
868 mhunt 238
        Integer sleepTime = 300000;
239
 
240
        if ( !master )
241
        {
242
          // sleep only 3 secs on slave
243
          sleepTime = 3000;
244
        }
245
        mLogger.warn("allowedToProceed sleep " + sleepTime.toString() + " secs no build requirement");
246
        Thread.sleep(sleepTime);
814 mhunt 247
        mLogger.info("allowedToProceed sleep returned");
248
      }
249
      catch(InterruptedException e)
250
      {
251
        mLogger.warn("allowedToProceed sleep caught InterruptedException");
252
      }
253
    }
254
 
255
    boolean proceed = false;
256
 
257
    while ( !proceed )
258
    {
259
      mReleaseManager.connect();
260
      if ( !mReleaseManager.queryReleaseConfig(mRtagId, mRconId, BuildDaemon.mHostname, getMode(), mGbebuildfilter) )
261
      {
262
        mReleaseManager.disconnect();
858 mhunt 263
        mLogger.warn("allowedToProceed queryReleaseConfig failed");
814 mhunt 264
        throw new ExitException();
265
      }
266
 
267
      Date resumeTime = new Date( 0 );
268
      if ( !mReleaseManager.queryRunLevelSchedule(resumeTime) )
269
      {
270
        mLogger.info("allowedToProceed scheduled downtime");
271
        mReleaseManager.disconnect();
272
        mRunLevel = RunLevel.PAUSED;
816 mhunt 273
        mLogger.warn("allowedToProceed changing run level to PAUSED for rcon_id " + mRconId);
814 mhunt 274
        mRunLevel.persist(mReleaseManager, mRconId);
275
 
276
        synchronized(mSynchroniser)
277
        {
278
          // contain the schedule and wait in the same synchronized block to prevent a deadlock
279
          // eg this thread calls schedule, timer thread calls notifyall, this thread calls wait (forever)
280
          try
281
          {
282
            if (mResumeTimerTask.isCancelled())
283
            {
284
              mResumeTimerTask = new ResumeTimerTask();
285
              mTimer = new Timer();
286
              mResumeTimerTask.setTimer(mTimer);
287
            }
288
            mLogger.warn("allowedToProceed schedule passed " + resumeTime.getTime());
289
            mTimer.schedule(mResumeTimerTask, resumeTime);
290
          }
291
          catch( IllegalStateException e )
292
          {
293
            // this may be thrown by schedule if already scheduled
294
            // it signifies another BuildThread has already scheduled the ResumeTimerTask
295
             mLogger.warn("allowedToProceed already scheduled");
296
          }
297
 
298
          try
299
          {
300
            mLogger.warn("allowedToProceed wait");
301
            mSynchroniser.wait();
302
            mLogger.warn("allowedToProceed wait returned");
303
 
304
            if ( mGbebuildfilter.compareTo("unit test not allowed to proceed") == 0 )
305
            {
306
              throw new ExitException();
307
            }
308
          }
309
          catch( InterruptedException e )
310
          {
311
            mLogger.warn("allowedToProceed caught InterruptedException");
312
          }
313
        }
314
 
315
      }
316
      else
317
      {
318
        if ( !mReleaseManager.queryDirectedRunLevel(mRconId) )
319
        {
320
          mLogger.info("allowedToProceed downtime");
321
          mReleaseManager.disconnect();
832 mhunt 322
          mRunLevel = RunLevel.PAUSED;
323
          mLogger.warn("allowedToProceed changing run level to PAUSED for rcon_id " + mRconId);
324
          mRunLevel.persist(mReleaseManager, mRconId);
814 mhunt 325
          try
326
          {
327
            // to do, sleep for periodicMs
328
            mLogger.warn("allowedToProceed sleep 5 mins directed downtime");
329
            Thread.sleep(300000);
330
            mLogger.info("allowedToProceed sleep returned");
331
          }
332
          catch (InterruptedException e)
333
          {
334
            mLogger.warn("allowedToProceed caught InterruptedException");
335
          }
336
        }
337
        else
338
        {
339
          mReleaseManager.disconnect();
340
          proceed = true;
341
        }
342
      }
343
    }
344
  }
345
 
346
  /**periodically 
347
   * a) performs disk housekeeping
348
   * b) determines if a minimum threshold of disk space is available
349
   * changes the run level to CANNOT_CONTINUE if insufficient disk space
350
   * otherwise changes the run level to ACTIVE and returns
351
   * implements the sequence diagram check environment
352
   */
353
  protected void checkEnvironment() throws Exception
354
  {
355
    mLogger.debug("checkEnvironment");
356
    boolean exit = false;
357
 
358
    while( !exit )
359
    {
360
      housekeep();
361
 
362
      // attempt to exit
363
      exit = true;
364
 
365
      if ( !hasSufficientDiskSpace() )
366
      {
367
        mLogger.warn("checkEnvironment below disk free threshold");
368
        exit = false;
369
        mRunLevel = RunLevel.CANNOT_CONTINUE;
816 mhunt 370
        mLogger.warn("checkEnvironment changing run level to CANNOT_CONTINUE for rcon_id " + mRconId);
814 mhunt 371
        mRunLevel.persist(mReleaseManager, mRconId);
372
        try
373
        {
374
          // to do, sleep for periodicMs
375
          if ( mGbebuildfilter.compareTo("unit test check environment") != 0 )
376
          {
377
            mLogger.warn("checkEnvironment sleep 5 mins below disk free threshold");
378
            Thread.sleep(300000);
379
            mLogger.info("checkEnvironment sleep returned");
380
          }
381
        }
382
        catch (InterruptedException e)
383
        {
384
          mLogger.warn("checkEnvironment caught InterruptedException");
385
        }
386
      }
387
    }
388
 
389
    mRunLevel = RunLevel.ACTIVE;    
816 mhunt 390
    mLogger.warn("checkEnvironment changing run level to ACTIVE for rcon_id " + mRconId);
814 mhunt 391
    mRunLevel.persist(mReleaseManager, mRconId);
392
  }
393
 
394
  /**performs disk housekeeping which involves deleting build directories > 5 days old
395
   * refer to the sequence diagram check environment
396
   */
397
  private void housekeep()
398
  {
399
    mLogger.debug("housekeep");
400
    FilenameFilter filter = new FilenameFilter()
401
    {
402
      public boolean accept(File file, String name)
403
      {
404
        mLogger.debug("accept " + name);
405
        boolean retVal = false;
406
 
407
        if ( file.isDirectory() && !name.startsWith( "." ) )
408
        {
409
          retVal = true;
410
        }
411
 
412
        mLogger.info("accept returned " + retVal);
413
        return retVal;
414
      }
415
    };
416
 
417
    try
418
    {
842 mhunt 419
      // DEVI 46729, 46730, solaris 10 core dumps implicate deleteDirectory
420
      // let each BuildThread look after its own housekeeping
854 mhunt 421
      File ocwd = new File( BuildDaemon.mGbeLog );
422
      File hcwd = new File( ocwd, BuildDaemon.mHostname );
423
      File cwd = new File( hcwd, String.valueOf( mRtagId ) );
842 mhunt 424
 
814 mhunt 425
      File[] children = cwd.listFiles( filter );
426
 
427
      if ( children != null )
428
      {
429
        for ( int child=0; child < children.length; child++ )
430
        {
854 mhunt 431
          // child is named uniquely to encapsulate a build
432
          // 5 days = 432,000,000 milliseconds
433
          if ( ( System.currentTimeMillis() - children[ child ].lastModified() ) > 432000000 )
814 mhunt 434
          {
854 mhunt 435
            // the directory is over 5 days old
436
            mLogger.warn("housekeep deleting directory " + children[ child ].getName());
437
            if ( mGbebuildfilter.compareTo("unit test check environment") != 0 )
814 mhunt 438
            {
854 mhunt 439
              deleteDirectory( children[ child ] );
814 mhunt 440
            }
441
          }
442
        }
443
      }
444
    }
445
    catch( SecurityException e )
446
    {
447
      // this can be thrown by lastModified
448
       mLogger.warn("housekeep caught SecurityException");
449
    }
450
 
451
  }
452
 
453
  /**returns true if free disk space > 10G
454
   * this may become configurable if the need arises
455
   * refer to the sequence diagram check environment
456
   */
457
  private boolean hasSufficientDiskSpace()
458
  {
459
    mLogger.debug("hasSufficientDiskSpace");
460
    boolean retVal = true;
461
    long freeSpace = 0;
462
 
463
    try
464
    {
465
      File cwd = new File( "." );
466
 
467
      // 5G = 5368709120 bytes
886 mhunt 468
      // 1G = 1073741824 bytes - useful for testing
814 mhunt 469
      if ( mGbebuildfilter.compareTo("unit test check environment") == 0 )
470
      {
864 mhunt 471
        if ( ReleaseManager.mPersistedRunLevelCollection.size() == 0 )
814 mhunt 472
        {
473
          retVal = false;
474
        }
475
        else
476
        {
477
          retVal = true;
478
        }
479
      }
480
      else
481
      {
816 mhunt 482
        freeSpace = cwd.getUsableSpace();
814 mhunt 483
 
484
        if ( freeSpace < 5368709120L )
485
        {
816 mhunt 486
          mLogger.warn("hasSufficientDiskSpace on " + cwd.getAbsolutePath() + " freeSpace " + freeSpace);
814 mhunt 487
          retVal = false;
488
        }
489
      }
490
    }
491
    catch( SecurityException e )
492
    {
493
      // this can be thrown by getFreeSpace
494
       mLogger.warn("hasSufficientDiskSpace caught SecurityException");
495
    }
496
 
497
    mLogger.info("hasSufficientDiskSpace returned " + retVal + " " + freeSpace);
498
    return retVal;
499
  }
500
 
501
  /**abstract method
502
   */
503
  public abstract void run();
504
 
505
  /**deletes directory and all its files
506
   */
507
  protected void deleteDirectory(File directory)
508
  {
509
    mLogger.debug("deleteDirectory " + directory.getName());
510
    try
511
    {
512
      if ( directory.exists() )
513
      {
514
        FilenameFilter filter = new FilenameFilter()
515
        {
516
          public boolean accept(File file, String name)
517
          {
518
            mLogger.debug("accept " + name);
519
            boolean retVal = false;
520
 
840 mhunt 521
            if ( name.compareTo(".") != 0 && ( name.compareTo("..") != 0 ) )
814 mhunt 522
            {
523
              retVal = true;
524
            }
525
 
526
            mLogger.info("accept returned " + retVal);
527
            return retVal;
528
          }
529
        };
530
 
531
        File[] children = directory.listFiles( filter );
532
 
533
        if ( children != null )
534
        {
535
          for ( int child=0; child < children.length; child++ )
536
          {
537
            if ( children[ child ].isDirectory() )
538
            {
539
              deleteDirectory( children[ child ] );
540
            }
541
            else
542
            {
543
              children[ child ].delete();
544
            }
545
          }
546
        }
547
        directory.delete();
548
      }
549
    }
550
    catch( SecurityException e )
551
    {
552
      // this can be thrown by exists and delete
553
       mLogger.warn("deleteDirectory caught SecurityException");
554
    }
555
  }
556
 
557
  /**abstract method
558
   */
559
  protected abstract char getMode();
560
 
561
  /**injects GBE_BUILDFILTER into the passed buildFileContent
562
   * builds a buildFile from the buildFileContent
563
   * triggers ant to operate on the buildFile
564
   */
854 mhunt 565
  protected void deliverChange(String buildFileContent, String target, boolean master)
814 mhunt 566
  {
567
    mLogger.debug("deliverChange");
854 mhunt 568
 
866 mhunt 569
    // always perform a AbtSetUp, AbtPublish (master only), and AbtTearDown
570
    if ( target == null && mErrorReported )
854 mhunt 571
    {
866 mhunt 572
      // AbtSetUp failed
573
      // the default target will inevitably fail and will generate further email if allowed to proceed
574
      // do not mask the root cause
854 mhunt 575
      return;
576
    }
577
 
814 mhunt 578
    File buildFile = new File(mRtagId + "build.xml");
862 mhunt 579
    boolean logError = true;
866 mhunt 580
    Project p = new Project();
814 mhunt 581
 
582
    try
583
    {
584
      // clear the file contents
585
      if ( buildFileContent != null && target != null && target.compareTo("AbtSetUp") == 0 )
586
      {
587
        FileOutputStream buildFileOutputStream = new FileOutputStream(buildFile, false);
588
        buildFileOutputStream.close();
589
 
590
        StringReader buildFileContentStringReader = new StringReader(buildFileContent);
591
        BufferedReader buildFileBufferedReader = new BufferedReader(buildFileContentStringReader);
592
 
593
        // sanitise the buildFileContent
594
        // it may contain line.separators of "\n", "\r", or "\r\n" variety, depending on the location of the ripple engine
595
        String sanitisedBFC = new String();
596
        String lf = new String( System.getProperty("line.separator") );
597
        int lineCount = 0;
598
        String line = new String();
599
 
600
        while( ( line = buildFileBufferedReader.readLine() ) != null)
601
        {
602
          sanitisedBFC += line + lf;
603
          lineCount++;
604
 
605
          if ( lineCount == 2 )
606
          {
607
            // have read the first two lines
862 mhunt 608
            String inject = "<property name=\"abt_MASTER\" value=\"";
814 mhunt 609
 
610
            if ( master )
611
            {
612
              inject += "yes\"/>" + lf;
613
            }
614
            else
615
            {
616
              inject += "no\"/>" + lf;
617
            }
618
 
619
            // insert a GBE_BUILDFILTER property if necessary
620
            if ( mGbebuildfilter.length() > 0 )
621
            {
862 mhunt 622
              inject += "<property name=\"abt_GBE_BUILDFILTER\" value=\"" + mGbebuildfilter + "\"/>" + lf;
814 mhunt 623
            }
624
 
625
            mLogger.info("deliverChange injecting " + inject);
626
            sanitisedBFC += inject;
627
          }
628
        }
629
        buildFileBufferedReader.close();
630
        FileWriter buildFileWriter = new FileWriter(buildFile);
631
        buildFileWriter.write(sanitisedBFC);
632
        buildFileWriter.close();
633
      }
634
 
866 mhunt 635
      mReportingPackageName = null;
636
      mReportingPackageVersion = null;
637
      mReportingPackageExtension = null;
638
      mReportingPackageLocation = null;
639
      mReportingPackageDepends = null;
640
      mReportingIsRipple = null;
641
      mReportingPackageVersionId = null;
642
      mReportingDoesNotRequireSourceControlInteraction = null;
643
      mReportingFullyPublished = null;
644
      mReportingNewLabel = null;
645
 
646
      if ( buildFile.exists() )
814 mhunt 647
      {
866 mhunt 648
        p.setProperty("ant.file", buildFile.getAbsolutePath());
649
        DefaultLogger dl = new DefaultLogger();
650
        PrintStream ps = new PrintStream(mRtagId + ".log");
651
        dl.setOutputPrintStream(ps);
652
        dl.setMessageOutputLevel(Project.MSG_INFO);
653
        p.addBuildListener(dl);
654
        p.init();
655
        ProjectHelper pH = ProjectHelper.getProjectHelper();
656
        p.addReference("ant.projectHelper", pH);
657
 
658
        // parse can throw BuildException, this is serious
659
        pH.parse(p, buildFile);
660
        mLogger.warn("deliverChange ant launched on " + buildFile.getAbsolutePath());
661
 
662
        if ( target == null )
663
        {
664
          target = p.getDefaultTarget();
665
        }
666
        mLogger.warn("deliverChange ant launched against target " + target);
667
 
668
        // executeTarget can throw BuildException, this is not serious
669
        logError = false;
670
        // set up project properties for reporting purposes
671
        // this first group are hard coded in the build file
672
        mReportingPackageName = p.getProperty("abt_package_name");
673
        mReportingPackageVersion = p.getProperty("abt_package_version");
674
        mReportingPackageExtension = p.getProperty("abt_package_extension");
675
        mReportingPackageLocation = p.getProperty("basedir") + p.getProperty("abt_package_location");
676
        mReportingPackageDepends = p.getProperty("abt_package_depends");
677
        mReportingIsRipple = p.getProperty("abt_is_ripple");
678
        mReportingPackageVersionId = p.getProperty("abt_package_version_id");
679
        mReportingDoesNotRequireSourceControlInteraction = p.getProperty("abt_does_not_require_source_control_interaction");
680
 
681
        p.executeTarget(target);
682
        mLogger.warn("deliverChange ant returned");
683
 
814 mhunt 684
      }
685
    }
686
    catch( BuildException e )
687
    {
862 mhunt 688
      if ( logError )
689
      {
690
        mLogger.error("deliverChange caught BuildException, the build failed " + e.getMessage());
691
      }
692
      else
693
      {
866 mhunt 694
        if ( mReportingBuildFailureLogFile == null )
695
        {
696
          mReportingBuildFailureLogFile = e.getMessage();
697
        }
698
        mLogger.debug("deliverChange caught BuildException, big deal, the build failed " + mReportingBuildFailureLogFile);
862 mhunt 699
      }
854 mhunt 700
 
701
      mErrorReported = true;
814 mhunt 702
    }
703
    catch( FileNotFoundException e )
704
    {
705
      mLogger.error("deliverChange caught FileNotFoundException");
706
    }
707
    catch( IOException e )
708
    {
709
      mLogger.error("deliverChange caught IOException");
710
    }
711
 
866 mhunt 712
    // this group are set at run time (by the AbtPublish target only)
713
    // they will be null for every other target,
714
    // and null if an error occurs in the AbtPublish target
715
    mReportingFullyPublished = p.getProperty("abt_fully_published");
716
    mReportingNewLabel = p.getProperty("abt_new_label");
717
 
814 mhunt 718
  }
719
 
720
  /**sets up a ClearCase static view
721
   */
854 mhunt 722
  protected void setViewUp(String content, boolean master)
814 mhunt 723
  {
724
    mLogger.debug("setViewUp");
866 mhunt 725
    mReportingBuildFailureLogFile = null;
854 mhunt 726
    mErrorReported = false;
868 mhunt 727
 
728
    if ( !master && mGbeGatherMetricsOnly != null )
729
    {
730
      // do not run AbtSetUp on slave in metrics gathering mode
731
      return;
732
    }
733
 
814 mhunt 734
    // run ant on the AbtSetUp target
735
    deliverChange(content, "AbtSetUp", master);
736
  }
737
 
738
  /**Checks the archive for the <packageName>/<packageVersion>/built.<machtype> existence
739
   */
740
  protected boolean published(String archive, String packageName, 
741
                            String packageVersion, String machtype,
742
                            String generic)
743
  {
744
    mLogger.debug("published");
745
    boolean retVal = false;
746
 
747
    String fs = System.getProperty( "file.separator" );
748
    String destination = archive + fs + packageName + fs + packageVersion;
749
 
750
    mLogger.debug("published " + destination);
751
    String filename = "built.";
752
 
753
    if ( generic.compareTo("generic") == 0 )
754
    {
755
      filename += "generic";
756
    }
757
    else
758
    {
759
      filename += machtype;
760
    }
761
 
762
    mLogger.debug("published " + filename);
763
    File flag = new File( destination, filename );
764
 
765
    if ( flag.exists() )
766
    {
767
      retVal = true;
768
    }
769
    mLogger.debug("published returned " + retVal);
770
    return retVal;
771
  }
868 mhunt 772
 
773
  /**
774
   * indefinite pause notification
775
  */
776
   protected void indefinitePause(RippleEngine rippleEngine, String cause)
777
   {
778
     mLogger.debug("indefinitePause");
779
 
780
     String body =
781
     "Hostname: " + BuildDaemon.mHostname + "<p>" +
782
     "Release: " + rippleEngine.mBaselineName + "<p>" +
783
     cause;
784
 
785
     try
786
     {
787
       Smtpsend.send(
788
       rippleEngine.mMailServer, // mailServer
789
       rippleEngine.mMailSender, // source
790
       rippleEngine.mGlobalTarget, // target
791
       null, // cc
792
       null, // bcc
793
       "BUILD DAEMON INDEFINITE PAUSE", // subject
794
       body, // body
795
       null // attachment
796
       );
797
     }
798
     catch( Exception e )
799
     {
800
     }
801
   }
802
 
814 mhunt 803
}