| 1 |
ab11 |
1.2 |
//---PACKAGE DECLARATION--- |
| 2 |
ab11 |
1.1 |
|
| 3 |
ab11 |
1.2 |
//---IMPORTS--- |
| 4 |
|
|
|
| 5 |
|
|
/** |
| 6 |
|
|
* A small efficient JavaHost |
| 7 |
|
|
* Designed to be used as a working design to build the C++ hosts on. |
| 8 |
|
|
* Hopefully fully functional and thus can be used as part of a test rig. |
| 9 |
|
|
* |
| 10 |
|
|
* @author $Author: ab11 $ |
| 11 |
ab11 |
1.3 |
* @version $Id: JavaHost.java,v 1.2 2000/11/27 20:36:20 ab11 Exp $ |
| 12 |
ab11 |
1.2 |
*/ |
| 13 |
ab11 |
1.1 |
class JavaHost { |
| 14 |
ab11 |
1.2 |
|
| 15 |
|
|
//---FINAL ATTRIBUTES--- |
| 16 |
|
|
|
| 17 |
|
|
//---STATIC METHODS--- |
| 18 |
|
|
|
| 19 |
|
|
//---CONSTRUCTORS--- |
| 20 |
|
|
|
| 21 |
|
|
/** |
| 22 |
|
|
* Constructor for the class. Takes in the hostname and port number |
| 23 |
|
|
* of the Configuration Manager. |
| 24 |
|
|
* |
| 25 |
|
|
*/ |
| 26 |
|
|
public JavaHost( String serverName, int port ){ |
| 27 |
|
|
// create a connection to the configurator |
| 28 |
ab11 |
1.3 |
System.out.println("Creating connection with Configurtator"); |
| 29 |
ab11 |
1.2 |
Config config = new Config(serverName, port); |
| 30 |
|
|
// the config class knows what values it wants to get from |
| 31 |
|
|
// the configurator |
| 32 |
|
|
|
| 33 |
|
|
// create a SystemMonitor object and pass the confifurator |
| 34 |
|
|
// as a param so it knows what to do! |
| 35 |
ab11 |
1.3 |
System.out.println("Creating System Monitor"); |
| 36 |
ab11 |
1.2 |
SystemMonitor sysMon = new SystemMonitor(config); |
| 37 |
|
|
|
| 38 |
|
|
while ( true ){ |
| 39 |
|
|
// keep going for ever and ever ;) |
| 40 |
|
|
// send a udp packet to the filter declared in config |
| 41 |
|
|
// send it the xml packet created by getInfo() |
| 42 |
ab11 |
1.3 |
System.out.println("Sending UDP Packet"); |
| 43 |
|
|
LowLevelNet.sendUDPPacket(config, sysMon.getInfo()); |
| 44 |
|
|
config.sendHeartBeat(); |
| 45 |
|
|
if ( config.reloadConfig() ){ |
| 46 |
|
|
System.out.println("Resarting System"); |
| 47 |
|
|
break; |
| 48 |
|
|
} |
| 49 |
|
|
} // while |
| 50 |
ab11 |
1.2 |
|
| 51 |
ab11 |
1.3 |
|
| 52 |
ab11 |
1.2 |
} // public javahost |
| 53 |
|
|
|
| 54 |
|
|
|
| 55 |
|
|
//---PUBLIC METHODS--- |
| 56 |
|
|
|
| 57 |
|
|
//---PRIVATE METHODS--- |
| 58 |
|
|
|
| 59 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
| 60 |
|
|
|
| 61 |
|
|
//---ATTRIBUTES--- |
| 62 |
|
|
|
| 63 |
|
|
//---STATIC ATTRIBUTES--- |
| 64 |
|
|
|
| 65 |
ab11 |
1.1 |
} // class |