1 |
mojays |
2 |
package appl.parallel.server; |
2 |
|
|
|
3 |
|
|
import java.io.Serializable; |
4 |
|
|
import java.lang.management.ManagementFactory; |
5 |
|
|
import java.lang.management.MemoryPoolMXBean; |
6 |
|
|
import java.lang.management.MemoryUsage; |
7 |
|
|
import java.lang.management.ThreadMXBean; |
8 |
|
|
import java.util.List; |
9 |
|
|
import java.util.Timer; |
10 |
|
|
|
11 |
|
|
import org.apache.log4j.lf5.util.Resource; |
12 |
|
|
|
13 |
|
|
import appl.parallel.ComputingResourceProperties; |
14 |
|
|
import appl.parallel.SimpleResourceProperties; |
15 |
|
|
|
16 |
|
|
/** |
17 |
|
|
* Constructs information out of a XuluServer Object. Unfortunately there is no way |
18 |
|
|
* to measure CPU load (for this you would need to have access to the OS core). This could |
19 |
|
|
* be done with the use of the JNI, but that is low level programming and would be OS |
20 |
|
|
* dependent. |
21 |
|
|
* |
22 |
|
|
* Must be invoked on server side (which should be clear, anyway!).<br> |
23 |
|
|
* |
24 |
|
|
* Sets the following properties: |
25 |
|
|
* <br><br> |
26 |
|
|
* Name <br> |
27 |
|
|
* isAvailable<br> |
28 |
|
|
* Uptime<br><br> |
29 |
|
|
* |
30 |
|
|
* and of course the Properties the superclass sets<br> |
31 |
|
|
* @author Dominik Appl |
32 |
|
|
*/ |
33 |
|
|
public class XuluServerProperties extends SimpleResourceProperties implements |
34 |
|
|
Serializable { |
35 |
|
|
|
36 |
|
|
public XuluServerProperties(XuluServer server, String name) { |
37 |
|
|
super(); |
38 |
|
|
if (name != null) |
39 |
|
|
properties.setProperty("Name", name); |
40 |
|
|
properties.setProperty("isAvailable", (!(server.isClientConnected())) |
41 |
|
|
+ ""); |
42 |
|
|
|
43 |
|
|
//format uptime |
44 |
|
|
int uptimeInSeconds = server.getUptime() / 1000; |
45 |
|
|
int hours, minutes, seconds; |
46 |
|
|
hours = uptimeInSeconds / 3600; |
47 |
|
|
uptimeInSeconds = uptimeInSeconds - (hours * 3600); |
48 |
|
|
minutes = uptimeInSeconds / 60; |
49 |
|
|
uptimeInSeconds = uptimeInSeconds - (minutes * 60); |
50 |
|
|
seconds = uptimeInSeconds; |
51 |
|
|
String formatedTime = hours + "h " + minutes + "m " + seconds + "s"; |
52 |
|
|
properties.setProperty("Uptime", formatedTime); |
53 |
|
|
properties.setProperty("Rating", server.getRating() + ""); |
54 |
|
|
properties.setProperty("Port", server.getRegistryPort() + ""); |
55 |
|
|
} |
56 |
|
|
|
57 |
|
|
} |