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