Subversion Repositories DevTools

Rev

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

Rev 886 Rev 894
Line 344... Line 344...
344
  }
344
  }
345
 
345
 
346
  /**periodically 
346
  /**periodically 
347
   * a) performs disk housekeeping
347
   * a) performs disk housekeeping
348
   * b) determines if a minimum threshold of disk space is available
348
   * b) determines if a minimum threshold of disk space is available
-
 
349
   * c) determines if a file can be touched
349
   * changes the run level to CANNOT_CONTINUE if insufficient disk space
350
   * changes the run level to CANNOT_CONTINUE if insufficient disk space
350
   * otherwise changes the run level to ACTIVE and returns
351
   * otherwise changes the run level to ACTIVE and returns
351
   * implements the sequence diagram check environment
352
   * implements the sequence diagram check environment
352
   */
353
   */
353
  protected void checkEnvironment() throws Exception
354
  protected void checkEnvironment() throws Exception
Line 360... Line 361...
360
      housekeep();
361
      housekeep();
361
      
362
      
362
      // attempt to exit
363
      // attempt to exit
363
      exit = true;
364
      exit = true;
364
    
365
    
365
      if ( !hasSufficientDiskSpace() )
366
      if ( !hasSufficientDiskSpace() || !touch() )
366
      {
367
      {
367
        mLogger.warn("checkEnvironment below disk free threshold");
368
        mLogger.warn("checkEnvironment below disk free threshold or read only file system detected");
368
        exit = false;
369
        exit = false;
369
        mRunLevel = RunLevel.CANNOT_CONTINUE;
370
        mRunLevel = RunLevel.CANNOT_CONTINUE;
370
        mLogger.warn("checkEnvironment changing run level to CANNOT_CONTINUE for rcon_id " + mRconId);
371
        mLogger.warn("checkEnvironment changing run level to CANNOT_CONTINUE for rcon_id " + mRconId);
371
        mRunLevel.persist(mReleaseManager, mRconId);
372
        mRunLevel.persist(mReleaseManager, mRconId);
372
        try
373
        try
Line 443... Line 444...
443
      }
444
      }
444
    }
445
    }
445
    catch( SecurityException e )
446
    catch( SecurityException e )
446
    {
447
    {
447
      // this can be thrown by lastModified
448
      // this can be thrown by lastModified
448
       mLogger.warn("housekeep caught SecurityException");
449
      mLogger.warn("housekeep caught SecurityException");
449
    }
450
    }
450
     
451
     
451
  }
452
  }
452
 
453
 
-
 
454
  /**returns true if a file exists and can be deleted,
-
 
455
   * created and exists in the file system
-
 
456
   * this is to guard against read-only file systems
-
 
457
   */
-
 
458
  private boolean touch()
-
 
459
  {
-
 
460
    mLogger.debug("touch");
-
 
461
    boolean retVal = true;
-
 
462
    
-
 
463
    try
-
 
464
    {
-
 
465
      File touch = new File( String.valueOf( mRtagId ) + "touch" );
-
 
466
      
-
 
467
      if ( touch.exists() )
-
 
468
      {
-
 
469
        // delete it
-
 
470
        retVal = touch.delete();
-
 
471
      }
-
 
472
      
-
 
473
      if ( retVal )
-
 
474
      {
-
 
475
        // file does not exist
-
 
476
        retVal = touch.createNewFile();
-
 
477
      }
-
 
478
    }
-
 
479
    catch( SecurityException e )
-
 
480
    {
-
 
481
      // this can be thrown by exists, delete, createNewFile
-
 
482
      retVal = false;
-
 
483
      mLogger.warn("touch caught SecurityException");
-
 
484
    }
-
 
485
    catch( IOException e )
-
 
486
    {
-
 
487
      // this can be thrown by createNewFile
-
 
488
      retVal = false;
-
 
489
      mLogger.warn("touch caught IOException");
-
 
490
    }
-
 
491
    
-
 
492
    mLogger.info("touch returned " + retVal);
-
 
493
    return retVal;
-
 
494
  }
-
 
495
  
453
  /**returns true if free disk space > 10G
496
  /**returns true if free disk space > 10G
454
   * this may become configurable if the need arises
497
   * this may become configurable if the need arises
455
   * refer to the sequence diagram check environment
498
   * refer to the sequence diagram check environment
456
   */
499
   */
457
  private boolean hasSufficientDiskSpace()
500
  private boolean hasSufficientDiskSpace()