// Peer Clusters
final JLabel clusters = getUIElement("general.stats.peerclusters");
clusters.setText("0");
// Peer Clusters Update Hook
ServiceEventsSupport.addServiceHook(new ServiceHookCallback() {
public void onServiceEvent(ServiceMessage message) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
int peers = ClusterManager.getInstance().getPeerService().getPeerCount();
clusters.setText(String.valueOf(peers));
} catch (Exception e) {
log.warn("[UI] Exception while accessing peer information",e);
}
}
});
}
}, ServiceMessageType.PEER_CONNECTION, ServiceMessageType.PEER_DISCONNECTION);
// Local Nodes
final JLabel nodes = getUIElement("general.stats.nodes");
nodes.setText(String.valueOf(ClusterManager.getInstance().getClusterRegistrationService().getNodeCount()));
// Local Nodes Update Hook
ServiceEventsSupport.addServiceHook(new ServiceHookCallback() {
public void onServiceEvent(ServiceMessage message) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
int count = ClusterManager.getInstance().getClusterRegistrationService().getNodeCount();
nodes.setText(String.valueOf(count));
}
});
}
}, ServiceMessageType.NODE_REGISTERED, ServiceMessageType.NODE_UNREGISTERED);
// Completed Jobs
final JLabel jobsdone = getUIElement("general.stats.jobsdone");
jobsdone.setText("0");
// Completed Jobs Update Hook
ServiceEventsSupport.addServiceHook(new ServiceHookCallback() {
public void onServiceEvent(ServiceMessage message) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
int count = ClusterManager.getInstance().getJobService().getFinishedJobCount();
jobsdone.setText(String.valueOf(count));
}
});
}
}, ServiceMessageType.JOB_END, ServiceMessageType.JOB_CANCEL);
// Active Jobs
final JLabel activejobs = getUIElement("general.stats.activejobs");
activejobs.setText(String.valueOf(ClusterManager.getInstance().getJobService().getActiveJobCount()));
// Active Jobs Update Hook
ServiceEventsSupport.addServiceHook(new ServiceHookCallback() {
public void onServiceEvent(ServiceMessage message) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
int count = ClusterManager.getInstance().getJobService().getActiveJobCount();
activejobs.setText(String.valueOf(count));