public class VbsClient
extends java.lang.Object
implements java.lang.Runnable
VbsClient is the primary class of the VBS client application. It loads the settings from a XML file.
If a client id is not specified in the settings, the client is registered at the server.
The application stops when it is externally terminated. When this happens a VbsClientShutdown is run as a shutdown hook,
to shut down nicely. | Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
clientId
Identifier of the client.
|
private int |
DEFAULT_DATABASE_HANDLER_INTERVAL
Default interval between looking for closed SQLite database files which can be sent to the server.
|
private int |
DEFAULT_FLOW_TIMEOUT_INTERVAL
Default time after which an unmodified flow is considered as closed.
|
private java.lang.String |
DEFAULT_FOLDER
Default folder for storing VBS client data.
|
private int |
DEFAULT_PERFORMANCE_MONITOR_INTERVAL
Default interval between monitoring system performance.
|
private int |
DEFAULT_SOCKET_MONITOR_INTERVAL
Default interval between monitoring system sockets.
|
private int |
fdbServerPort
Default VBS server TCP port used to transfer SQLite database files.
|
private java.lang.String |
globalIP
Global IP address of the client.
|
private static org.apache.log4j.Logger |
log
Used to log different events.
|
private DatabaseHandler |
myDatabaseHandler
DatabaseHandler module of the VBS client. |
private DataTransmitter |
myDataTransmitter
DataTransmitter module of the VBS client. |
private FlowGenerator |
myFlowGenerator
FlowGenerator module of the VBS client. |
private PacketCapturer |
myPacketCapturer
PacketCapturer module of the VBS client. |
private PerformanceMonitor |
myPerformanceMonitor
PerformanceMonitor module of the VBS client. |
private VbsClientShutdown |
myShutDownHandler
VbsClientShutdown module of the VBS client. |
private SocketMonitor |
mySocketMonitor
SocketMonitor module of the VBS client. |
private java.lang.String |
networkName
Name of the network to which the client is connected.
|
private int |
registerServerPort
Default VBS server TCP port used to register the client or validate the client identifier.
|
private java.lang.String |
serverIP
IP address of the VBS server.
|
private java.lang.String |
SOFT_SETTINGS_FILE
File with settings which can be adjusted to our needs.
|
private int |
upgradeServerPort
Default VBS server TCP port used to upgrade the client.
|
static int |
VBS_CLIENT_VERSION
Version of the VBS client.
|
static int |
VBS_DATABASE_VERSION
Version of the structure of the SQLite database used by the VBS client.
|
| Constructor and Description |
|---|
VbsClient() |
| Modifier and Type | Method and Description |
|---|---|
private boolean |
areThreadsAlive()
Checks if at least one module of the VBS client is running.
|
private void |
checkForUpgrade()
Checks for the VBS client upgrade on the server.
|
private boolean |
getClientIdFromServer()
Obtains the client identifier from the VBS server and writes it to an external settings file.
|
private boolean |
loadHardSettings()
Loads the hard, fixed settings from the config file.
|
private void |
loadSoftSettings()
Loads the soft, modifiable settings from the configuration file.
|
static void |
main(java.lang.String[] args)
Starts the client application.
|
private java.lang.String |
obtainNetworkName()
Obtain name of the network to which the client is collected.
|
void |
run()
Runs the VBS client.
|
private void |
setupDatabaseHandler()
Prepares the
DatabaseHandler module of the VBS client. |
private void |
setupDataTransmitter()
Prepares the
DataTransmitter module of the VBS client. |
private void |
setupFlowGenerator()
Prepares the
FlowGenerator module of the VBS client. |
private boolean |
setupFolder(java.lang.String directoryName)
Prepares a folder on a disk.
|
private void |
setupPacketCapturer()
Prepares the
PacketCapturer module of the VBS client. |
private void |
setupPerformanceMonitor()
Prepares the
PerformanceMonitor module of the VBS client. |
private void |
setupShutdown()
Prepares the
VbsClientShutdown module of the VBS client. |
private void |
setupSocketMonitor()
Prepares the
SocketMonitor module of the VBS client. |
private boolean |
startSystem()
Sequentially starts all the modules of the VBS client.
|
private boolean |
validateClientId()
Validates the client identifier on the server.
|
private static org.apache.log4j.Logger log
public static final int VBS_CLIENT_VERSION
public static final int VBS_DATABASE_VERSION
private final java.lang.String DEFAULT_FOLDER
private final java.lang.String SOFT_SETTINGS_FILE
private final int DEFAULT_SOCKET_MONITOR_INTERVAL
private final int DEFAULT_PERFORMANCE_MONITOR_INTERVAL
private final int DEFAULT_DATABASE_HANDLER_INTERVAL
private final int DEFAULT_FLOW_TIMEOUT_INTERVAL
private java.lang.String clientId
private java.lang.String serverIP
private int fdbServerPort
private int registerServerPort
private int upgradeServerPort
private java.lang.String globalIP
private java.lang.String networkName
private PacketCapturer myPacketCapturer
PacketCapturer module of the VBS client.private SocketMonitor mySocketMonitor
SocketMonitor module of the VBS client.private PerformanceMonitor myPerformanceMonitor
PerformanceMonitor module of the VBS client.private FlowGenerator myFlowGenerator
FlowGenerator module of the VBS client.private DatabaseHandler myDatabaseHandler
DatabaseHandler module of the VBS client.private DataTransmitter myDataTransmitter
DataTransmitter module of the VBS client.private VbsClientShutdown myShutDownHandler
VbsClientShutdown module of the VBS client.public void run()
run in interface java.lang.Runnableprivate boolean startSystem()
true if the system is started successfully, false otherwiseprivate boolean areThreadsAlive()
true if the system is alive, false otherwiseprivate boolean setupFolder(java.lang.String directoryName)
directoryName - path to the folder which needs to be preparedtrue if the folder was prepared successfully, false otherwiseprivate void setupFlowGenerator()
FlowGenerator module of the VBS client.private void setupSocketMonitor()
SocketMonitor module of the VBS client.private void setupPerformanceMonitor()
PerformanceMonitor module of the VBS client.private void setupDatabaseHandler()
DatabaseHandler module of the VBS client.private void setupPacketCapturer()
PacketCapturer module of the VBS client.private void setupDataTransmitter()
DataTransmitter module of the VBS client.private void setupShutdown()
VbsClientShutdown module of the VBS client.private boolean loadHardSettings()
true if the settings were loaded, false otherwiseprivate void loadSoftSettings()
private boolean getClientIdFromServer()
true if the client identifier was obtained successfully, false otherwiseprivate boolean validateClientId()
true if the client identifier was validated on the server, false if the client identifier was rejected or if any problem occuredprivate void checkForUpgrade()
private java.lang.String obtainNetworkName()
public static void main(java.lang.String[] args)