Subversion Repositories DevTools

Rev

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

Rev 868 Rev 886
Line 88... Line 88...
88
  /**Set true when last build cycle was benign.
88
  /**Set true when last build cycle was benign.
89
   * @attribute
89
   * @attribute
90
   */
90
   */
91
  protected boolean mSleep;
91
  protected boolean mSleep;
92
 
92
 
-
 
93
  /**Set true when last build cycle caught SQLException or Exception.
-
 
94
   * @attribute
-
 
95
   */
-
 
96
  protected boolean mException;
-
 
97
 
93
  /**Set true when ant error reported on any target.
98
  /**Set true when ant error reported on any target.
94
   * @attribute
99
   * @attribute
95
   */
100
   */
96
  private boolean mErrorReported;
101
  private boolean mErrorReported;
97
 
102
 
Line 165... Line 170...
165
  BuildThread()
170
  BuildThread()
166
  {
171
  {
167
    super(mThreadGroup, "");
172
    super(mThreadGroup, "");
168
    mLogger.debug("BuildThread");
173
    mLogger.debug("BuildThread");
169
    mSleep = false;
174
    mSleep = false;
-
 
175
    mException = false;
170
    mErrorReported = false;
176
    mErrorReported = false;
171
    mReleaseManager = new ReleaseManager();
177
    mReleaseManager = new ReleaseManager();
172
    
178
    
173
    // no need to be synchronized - BuildThreads are instantiated in a single thread
179
    // no need to be synchronized - BuildThreads are instantiated in a single thread
174
    if ( mResumeTimerTask == null )
180
    if ( mResumeTimerTask == null )
Line 177... Line 183...
177
      mTimer = new Timer();
183
      mTimer = new Timer();
178
      mResumeTimerTask.setTimer(mTimer);
184
      mResumeTimerTask.setTimer(mTimer);
179
    }
185
    }
180
  }
186
  }
181
 
187
 
-
 
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
  
182
  /**initially changes the run level to IDLE
210
  /**initially changes the run level to IDLE
183
   * determines if the BuildThread is still configured
211
   * determines if the BuildThread is still configured
184
   * a) determines if the BuildThread is running in scheduled downtime
212
   * a) determines if the BuildThread is running in scheduled downtime
185
   * b) determines if the BuildThread is directed to pause
213
   * b) determines if the BuildThread is directed to pause
186
   * changes the run level to PAUSED if a) or b) are true
214
   * changes the run level to PAUSED if a) or b) are true
187
   * throws ExitException when not configured
215
   * 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
216
   * implements the sequence diagrams allowed to proceed, not allowed to proceed, exit
190
   */
217
   */
191
  protected void allowedToProceed(boolean master) throws ExitException, SQLException, Exception
218
  protected void allowedToProceed(boolean master) throws ExitException, SQLException, Exception
192
  {
219
  {
193
    mLogger.debug("allowedToProceed");
220
    mLogger.debug("allowedToProceed");
-
 
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
    }
194
  
233
  
195
    if (mSleep)
234
    if (mSleep)
196
    {
235
    {
197
      try
236
      try
198
      {
237
      {
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
 
-
 
204
        Integer sleepTime = 300000;
238
        Integer sleepTime = 300000;
205
        
239
        
206
        if ( !master )
240
        if ( !master )
207
        {
241
        {
208
          // sleep only 3 secs on slave
242
          // sleep only 3 secs on slave
Line 210... Line 244...
210
        }
244
        }
211
        mLogger.warn("allowedToProceed sleep " + sleepTime.toString() + " secs no build requirement");
245
        mLogger.warn("allowedToProceed sleep " + sleepTime.toString() + " secs no build requirement");
212
        Thread.sleep(sleepTime);
246
        Thread.sleep(sleepTime);
213
        mLogger.info("allowedToProceed sleep returned");
247
        mLogger.info("allowedToProceed sleep returned");
214
      }
248
      }
215
      catch(SQLException e)
-
 
216
      {
-
 
217
        mLogger.warn("allowedToProceed caught SQLException");
-
 
218
      }
-
 
219
      catch(InterruptedException e)
249
      catch(InterruptedException e)
220
      {
250
      {
221
        mLogger.warn("allowedToProceed sleep caught InterruptedException");
251
        mLogger.warn("allowedToProceed sleep caught InterruptedException");
222
      }
252
      }
223
    }
253
    }
224
    
254
    
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;
-
 
229
    mLogger.warn("allowedToProceed changing run level to IDLE for rcon_id " + mRconId);
-
 
230
    mRunLevel.persist(mReleaseManager, mRconId);
-
 
231
    boolean proceed = false;
255
    boolean proceed = false;
232
    
256
    
233
    while ( !proceed )
257
    while ( !proceed )
234
    {
258
    {
235
      mReleaseManager.connect();
259
      mReleaseManager.connect();
Line 315... Line 339...
315
          mReleaseManager.disconnect();
339
          mReleaseManager.disconnect();
316
          proceed = true;
340
          proceed = true;
317
        }
341
        }
318
      }
342
      }
319
    }
343
    }
320
 
-
 
321
    mRunLevel = RunLevel.WAITING;
-
 
322
    mLogger.warn("allowedToProceed changing run level to WAITING for rcon_id " + mRconId);
-
 
323
    mRunLevel.persist(mReleaseManager, mRconId);
-
 
324
 
-
 
325
  }
344
  }
326
 
345
 
327
  /**periodically 
346
  /**periodically 
328
   * a) performs disk housekeeping
347
   * a) performs disk housekeeping
329
   * b) determines if a minimum threshold of disk space is available
348
   * b) determines if a minimum threshold of disk space is available
Line 444... Line 463...
444
    try
463
    try
445
    {
464
    {
446
      File cwd = new File( "." );
465
      File cwd = new File( "." );
447
 
466
 
448
      // 5G = 5368709120 bytes
467
      // 5G = 5368709120 bytes
-
 
468
      // 1G = 1073741824 bytes - useful for testing
449
      if ( mGbebuildfilter.compareTo("unit test check environment") == 0 )
469
      if ( mGbebuildfilter.compareTo("unit test check environment") == 0 )
450
      {
470
      {
451
        if ( ReleaseManager.mPersistedRunLevelCollection.size() == 0 )
471
        if ( ReleaseManager.mPersistedRunLevelCollection.size() == 0 )
452
        {
472
        {
453
          retVal = false;
473
          retVal = false;