Subversion Repositories DevTools

Rev

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

Rev 866 Rev 868
Line 1... Line 1...
1
package com.erggroup.buildtool.daemon;
1
package com.erggroup.buildtool.daemon;
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;
-
 
6
import com.erggroup.buildtool.ripple.RippleEngine;
5
 
7
 
6
import java.io.BufferedReader;
8
import java.io.BufferedReader;
7
import java.io.File;
9
import java.io.File;
8
import java.io.FileNotFoundException;
10
import java.io.FileNotFoundException;
9
import java.io.FileOutputStream;
11
import java.io.FileOutputStream;
Line 151... Line 153...
151
  /**Log file location for reporting purposes.
153
  /**Log file location for reporting purposes.
152
   * @attribute
154
   * @attribute
153
   */
155
   */
154
  protected String mReportingBuildFailureLogFile;
156
  protected String mReportingBuildFailureLogFile;
155
 
157
 
-
 
158
  /**Non null determines to only gather metrics
-
 
159
   * @attribute
-
 
160
   */
-
 
161
  protected static final String mGbeGatherMetricsOnly = System.getenv("GBE_GATHER_METRICS");
-
 
162
 
156
  /**constructor
163
  /**constructor
157
   */
164
   */
158
  BuildThread()
165
  BuildThread()
159
  {
166
  {
160
    super(mThreadGroup, "");
167
    super(mThreadGroup, "");
Line 179... Line 186...
179
   * changes the run level to PAUSED if a) or b) are true
186
   * changes the run level to PAUSED if a) or b) are true
180
   * throws ExitException when not configured
187
   * throws ExitException when not configured
181
   * otherwise changes the run level to WAITING and returns when allowed to proceed
188
   * otherwise changes the run level to WAITING and returns when allowed to proceed
182
   * implements the sequence diagrams allowed to proceed, not allowed to proceed, exit
189
   * implements the sequence diagrams allowed to proceed, not allowed to proceed, exit
183
   */
190
   */
184
  protected void allowedToProceed() throws ExitException, SQLException, Exception
191
  protected void allowedToProceed(boolean master) throws ExitException, SQLException, Exception
185
  {
192
  {
186
    mLogger.debug("allowedToProceed");
193
    mLogger.debug("allowedToProceed");
187
  
194
  
188
    if (mSleep)
195
    if (mSleep)
189
    {
196
    {
Line 192... Line 199...
192
        mRunLevel = RunLevel.IDLE;
199
        mRunLevel = RunLevel.IDLE;
193
        mLogger.warn("allowedToProceed changing run level to IDLE for rcon_id " + mRconId);
200
        mLogger.warn("allowedToProceed changing run level to IDLE for rcon_id " + mRconId);
194
        mRunLevel.persist(mReleaseManager, mRconId);
201
        mRunLevel.persist(mReleaseManager, mRconId);
195
        mReleaseManager.clearCurrentPackageBeingBuilt(mRconId);
202
        mReleaseManager.clearCurrentPackageBeingBuilt(mRconId);
196
 
203
 
-
 
204
        Integer sleepTime = 300000;
-
 
205
        
-
 
206
        if ( !master )
-
 
207
        {
-
 
208
          // sleep only 3 secs on slave
-
 
209
          sleepTime = 3000;
-
 
210
        }
197
        mLogger.warn("allowedToProceed sleep 5 mins no build requirement");
211
        mLogger.warn("allowedToProceed sleep " + sleepTime.toString() + " secs no build requirement");
198
        Thread.sleep(300000);
212
        Thread.sleep(sleepTime);
199
        mLogger.info("allowedToProceed sleep returned");
213
        mLogger.info("allowedToProceed sleep returned");
200
      }
214
      }
201
      catch(SQLException e)
215
      catch(SQLException e)
202
      {
216
      {
203
        mLogger.warn("allowedToProceed caught SQLException");
217
        mLogger.warn("allowedToProceed caught SQLException");
Line 688... Line 702...
688
  protected void setViewUp(String content, boolean master)
702
  protected void setViewUp(String content, boolean master)
689
  {
703
  {
690
    mLogger.debug("setViewUp");
704
    mLogger.debug("setViewUp");
691
    mReportingBuildFailureLogFile = null;
705
    mReportingBuildFailureLogFile = null;
692
    mErrorReported = false;
706
    mErrorReported = false;
-
 
707
    
-
 
708
    if ( !master && mGbeGatherMetricsOnly != null )
-
 
709
    {
-
 
710
      // do not run AbtSetUp on slave in metrics gathering mode
-
 
711
      return;
-
 
712
    }
-
 
713
    
693
    // run ant on the AbtSetUp target
714
    // run ant on the AbtSetUp target
694
    deliverChange(content, "AbtSetUp", master);
715
    deliverChange(content, "AbtSetUp", master);
695
  }
716
  }
696
  
717
  
697
  /**Checks the archive for the <packageName>/<packageVersion>/built.<machtype> existence
718
  /**Checks the archive for the <packageName>/<packageVersion>/built.<machtype> existence
Line 726... Line 747...
726
      retVal = true;
747
      retVal = true;
727
    }
748
    }
728
    mLogger.debug("published returned " + retVal);
749
    mLogger.debug("published returned " + retVal);
729
    return retVal;
750
    return retVal;
730
  }
751
  }
-
 
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
   
731
}
783
}