public class DatabaseHandler
extends java.lang.Object
implements java.lang.Runnable
DatabaseHandler is responsible for: | Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
clientId
Identifier of the VBS client.
|
private java.lang.String |
databaseFolderPath
Path to the folder where the database is stored.
|
private java.lang.Thread |
databaseHandlerThread
Thread used by the class.
|
private java.lang.String |
databasePath
Path to the current database file.
|
(package private) SQLiteDB |
db
The database object.
|
private java.lang.String |
globalIP
Global IP of the VBS client.
|
private boolean |
isStarted
Used to dermine if the thread is already started.
|
private static org.apache.log4j.Logger |
log
Used to log different events.
|
private ClosedFlowsQueue |
myClosedFlowsQueue
Queue of closed flows.
|
private PerformanceMonitorQueue |
myPerformanceMonitorQueue
Queue of performance measurements.
|
private java.lang.String |
networkName
Name of the network in which the VBS client is located.
|
private boolean |
runFlag
The thread will stop when this flag is
false. |
private int |
samplingInterval
Tells how often the database maintenance tasks are done.
|
| Constructor and Description |
|---|
DatabaseHandler(ClosedFlowsQueue closedFlowsQueue,
PerformanceMonitorQueue performanceMonitorQueue,
java.lang.String databaseFolderPath)
Constructs the object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
emptyStorage()
Moves all the closed flows from the closed flows storage to the database.
|
private static java.lang.String |
getSystemInfo()
Gets system information.
|
boolean |
isAlive()
Checks if
DatabaseHandler is alive. |
private void |
maintenance()
Does the periodical maintenance.
|
void |
run()
Runs the thread.
|
void |
setClientId(java.lang.String clientId)
Sets the client identifier.
|
private void |
setDatabase()
Sets the database.
|
void |
setGlobalIP(java.lang.String globalIP)
Sets the global IP address of the client.
|
void |
setNetworkName(java.lang.String networkName)
Sets the network name.
|
void |
setSamplingInterval(int samplingInterval)
Sets the frequency of database maintenance.
|
void |
start()
Starts the thread.
|
void |
stop()
Stops the thread.
|
private static org.apache.log4j.Logger log
private java.lang.Thread databaseHandlerThread
private boolean runFlag
false.private boolean isStarted
private int samplingInterval
private java.lang.String clientId
private java.lang.String globalIP
private java.lang.String networkName
private java.lang.String databaseFolderPath
private java.lang.String databasePath
SQLiteDB db
private ClosedFlowsQueue myClosedFlowsQueue
private PerformanceMonitorQueue myPerformanceMonitorQueue
public DatabaseHandler(ClosedFlowsQueue closedFlowsQueue, PerformanceMonitorQueue performanceMonitorQueue, java.lang.String databaseFolderPath)
closedFlowsQueue - queue of closed flowsperformanceMonitorQueue - queue of performance measurementsdatabaseFolderPath - path to a folder containing the databasepublic void start()
public void stop()
public boolean isAlive()
DatabaseHandler is alive. It means that: isStarted equals true).
This condition is used to check if the thread is fully started or if it needs more time to start.true if the thread is fully started and operational, false otherwisepublic void run()
run in interface java.lang.Runnablepublic void setSamplingInterval(int samplingInterval)
samplingInterval - interval in miliseconds, how often the database maintenance will be performedpublic void setClientId(java.lang.String clientId)
clientId - the client identifierpublic void setGlobalIP(java.lang.String globalIP)
globalIP - the global IP addresspublic void setNetworkName(java.lang.String networkName)
networkName - the network nameprivate static java.lang.String getSystemInfo()
private void setDatabase()
fdb file,
which will be automatically picked up by another thread and sent to the server. Then, it creates
a new database and initializes its structure.public void emptyStorage()
setDatabase.private void maintenance()