36 |
|
SystemMonitor sysMon = new SystemMonitor(config); |
37 |
|
|
38 |
|
try { |
39 |
< |
udpcheckInterval = Long.parseLong(config.getProperty("UDPUpdateTime")) * 1000; |
40 |
< |
System.out.println("Configured UDPUpdateTime"); |
39 |
> |
udpcheckInterval = Long.parseLong(config.getProperty("UDPUpdateTime")) * 1000; |
40 |
> |
System.out.println("Configured UDPUpdateTime"); |
41 |
|
} |
42 |
|
catch ( NumberFormatException e ){ |
43 |
< |
System.out.println("The value for UDPUpdateTime is invalid, using a default"); |
44 |
< |
// 1 mins |
45 |
< |
udpcheckInterval = 1000 * 60; // 1 minute |
43 |
> |
System.out.println("The value for UDPUpdateTime is invalid, using a default"); |
44 |
> |
// 1 mins |
45 |
> |
udpcheckInterval = 1000 * 60; // 1 minute |
46 |
|
} |
47 |
|
|
48 |
|
try { |
49 |
< |
tcpcheckInterval = Long.parseLong(config.getProperty("TCPUpdateTime")) * 1000; |
50 |
< |
System.out.println("Configured TCPUpdateTime"); |
49 |
> |
tcpcheckInterval = Long.parseLong(config.getProperty("TCPUpdateTime")) * 1000; |
50 |
> |
System.out.println("Configured TCPUpdateTime"); |
51 |
|
} |
52 |
|
catch ( NumberFormatException e ){ |
53 |
< |
System.out.println("The value for UDPUpdateTime is invalid, using a default"); |
54 |
< |
// 10 mins |
55 |
< |
tcpcheckInterval = 10000 * 60; // 5 minutes |
53 |
> |
System.out.println("The value for UDPUpdateTime is invalid, using a default"); |
54 |
> |
// 10 mins |
55 |
> |
tcpcheckInterval = 10000 * 60; // 5 minutes |
56 |
|
} |
57 |
|
|
58 |
|
// the current time.. |
65 |
|
// keep going for ever and ever ;) |
66 |
|
|
67 |
|
if ( nextTCP < nextUDP ){ |
68 |
< |
try { |
69 |
< |
long sleeptime = nextTCP - currentTime; |
70 |
< |
if ( sleeptime > 0 ){ |
71 |
< |
Thread.sleep(sleeptime); |
72 |
< |
} |
73 |
< |
nextTCP += tcpcheckInterval; |
74 |
< |
// send a heartbeat |
75 |
< |
System.out.println("Sending Heartbeat"); |
76 |
< |
config.sendHeartBeat(); |
77 |
< |
if ( config.reloadConfig() ){ |
78 |
< |
System.out.println("Resarting System"); |
79 |
< |
break; |
80 |
< |
} |
81 |
< |
} |
82 |
< |
catch ( InterruptedException e ){ |
83 |
< |
// do nothing |
84 |
< |
} |
68 |
> |
try { |
69 |
> |
long sleeptime = nextTCP - currentTime; |
70 |
> |
if ( sleeptime > 0 ){ |
71 |
> |
Thread.sleep(sleeptime); |
72 |
> |
} |
73 |
> |
nextTCP += tcpcheckInterval; |
74 |
> |
// send a heartbeat |
75 |
> |
//System.out.println("Sending Heartbeat"); |
76 |
> |
System.out.print("+"); |
77 |
> |
config.sendHeartBeat(); |
78 |
> |
if ( config.reloadConfig() ){ |
79 |
> |
System.out.println("\nRestarting System"); |
80 |
> |
break; |
81 |
> |
} |
82 |
> |
} |
83 |
> |
catch ( InterruptedException e ){ |
84 |
> |
// do nothing |
85 |
> |
} |
86 |
|
} |
87 |
|
else { |
88 |
< |
try { |
89 |
< |
long sleeptime = nextUDP - currentTime; |
90 |
< |
if ( sleeptime > 0 ){ |
91 |
< |
Thread.sleep(sleeptime); |
92 |
< |
} |
93 |
< |
nextUDP += udpcheckInterval; |
94 |
< |
// send a heartbeat |
95 |
< |
System.out.println("Sending UDP Packet"); |
96 |
< |
LowLevelNet.sendUDPPacket(config, sysMon.getInfo()); |
88 |
> |
try { |
89 |
> |
long sleeptime = nextUDP - currentTime; |
90 |
> |
if ( sleeptime > 0 ){ |
91 |
> |
Thread.sleep(sleeptime); |
92 |
> |
} |
93 |
> |
nextUDP += udpcheckInterval; |
94 |
> |
// send a heartbeat |
95 |
> |
//System.out.println("Sending UDP Packet"); |
96 |
> |
System.out.print("."); |
97 |
> |
LowLevelNet.sendUDPPacket(config, sysMon.getInfo()); |
98 |
|
|
99 |
< |
} |
100 |
< |
catch ( InterruptedException e ){ |
101 |
< |
// do nothing |
102 |
< |
} |
99 |
> |
} |
100 |
> |
catch ( InterruptedException e ){ |
101 |
> |
// do nothing |
102 |
> |
} |
103 |
|
} |
104 |
|
|
105 |
|
|
125 |
|
|
126 |
|
//---STATIC ATTRIBUTES--- |
127 |
|
|
128 |
< |
} // class |
128 |
> |
} // class |