com.faa.flyfaa
Class DatabaseUpdater

java.lang.Object
  |
  +--java.util.TimerTask
        |
        +--com.faa.flyfaa.DatabaseUpdater
All Implemented Interfaces:
java.lang.Runnable

class DatabaseUpdater
extends java.util.TimerTask

Describes a DatabaseUpdater class, which will be kicked off when the FlyfaaProjectBean is instantiated. Its purpose is to read new Ground Delay Program, Ground Stop, Delay, and Closure information from the database if any new data exists in these OIS tables. This thread runs every 90 seconds. When this Thread starts, it first determines if there are any recently updated or recently deleted records in any of the OIS tables. If there is new data, it copies the data from the main ArrayLists, GDPA, GStopA, DelayA, and ClosureA, to similarly-named arrays with "old" at the beginning of their name. Then, the FlyLock is obtained to signal jsp users to read from the "old" arraylists. jsp users who get control while the FlyLock is not set will still read from the new arraylists.


Field Summary
private  FlyfaaDbBean d
          Provides access to the database
private  java.lang.String Logf
          Pointer to the log file, which will be named FLYlogyyyy_Monddhhmm.txt (for example, FLYlog2003_Jan291940.txt) and is currently set up to reside in the /web/trace/atcscc/java_logs directory.
private  FlyFAAProjectBean p
          Provides access to the FlyFAAProjectBean
(package private)  boolean stopRunning
          Flag intended to signal the DatabaseUpdater to stop running.
(package private)  boolean UpdateInProgress
          Flag to indicate whether a Database Update is in progress
 
Fields inherited from class java.util.TimerTask
CANCELLED, EXECUTED, lock, nextExecutionTime, period, SCHEDULED, state, VIRGIN
 
Constructor Summary
DatabaseUpdater(FlyFAAProjectBean pb, boolean calledbyBeanStalk)
          Instantiation method for the DatabaseUpdater Thread.
 
Method Summary
 void checkFAAData()
          Rereads the Delay/GDP/GSTOP/Closure info from the database.
 void clearUpdateInProgress()
          Method to unset the UpdateInProgress flag.
 boolean isUpdateInProgress()
          Method to return the value of the UpdateInProgress flag.
 void run()
          Run method for the DatabaseUpdater Thread.
 void setUpdateInProgress()
          Method to set the UpdateInProgress flag to true.
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

Logf

private java.lang.String Logf
Pointer to the log file, which will be named FLYlogyyyy_Monddhhmm.txt (for example, FLYlog2003_Jan291940.txt) and is currently set up to reside in the /web/trace/atcscc/java_logs directory.

p

private FlyFAAProjectBean p
Provides access to the FlyFAAProjectBean

d

private FlyfaaDbBean d
Provides access to the database

UpdateInProgress

boolean UpdateInProgress
Flag to indicate whether a Database Update is in progress

stopRunning

boolean stopRunning
Flag intended to signal the DatabaseUpdater to stop running. Not implemented.
Constructor Detail

DatabaseUpdater

public DatabaseUpdater(FlyFAAProjectBean pb,
                       boolean calledbyBeanStalk)
Instantiation method for the DatabaseUpdater Thread.

Parameters:
pb - FlyFAAProjectBean reference to the flyFAA 'Project' object
calledbyBeanStalk - true if called by the FlyFAAProjectBeanStalk, false otherwise.
Method Detail

isUpdateInProgress

public boolean isUpdateInProgress()
Method to return the value of the UpdateInProgress flag.

Returns:
true if reading of data is in progress, false if the reading of data from the database has finished.

setUpdateInProgress

public void setUpdateInProgress()
Method to set the UpdateInProgress flag to true.

clearUpdateInProgress

public void clearUpdateInProgress()
Method to unset the UpdateInProgress flag.

run

public void run()
Run method for the DatabaseUpdater Thread. Clears the OLD arrays for GDPs, GStops, etc. (oldGDPA, oldGStopA, etc.) and fills them with the latest info from the NEW arrays (GDPA, GStopA, etc.). Gets a FlyLock to signal jsp users to stop using the NEW arrays. Does not wait until count of clients reading NEW arrays reaches zero, but instead forges ahead and reads new information from the database. Lastly, releases the FlyLock to signal jsp users that it is once again OK to read from the NEW arrays.
Overrides:
run in class java.util.TimerTask

checkFAAData

public void checkFAAData()
                  throws java.sql.SQLException,
                         java.io.IOException
Rereads the Delay/GDP/GSTOP/Closure info from the database. The strDD property is set to a string of HTML produced by FillDelayData containing Tooltips for delayed airports.

Throws:
java.sql.SQLException - if a database access error occurs
java.io.IOException - if a database Connection cannot be obtained within 5 seconds