Adding more JMX infos.

This commit is contained in:
Michael Nitschinger
2013-05-28 16:18:37 +02:00
parent dfb19ea7f7
commit 7f1dbfaa1d
2 changed files with 19 additions and 14 deletions

View File

@@ -1,10 +1,13 @@
package com.couchbase.spring.monitor;
import com.couchbase.client.CouchbaseClient;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import java.net.SocketAddress;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Exposes basic cluster information.
@@ -16,7 +19,7 @@ public class ClusterInfo extends AbstractMonitor {
super(client);
}
@ManagedOperation(description = "Cluster Hostnames")
@ManagedAttribute(description = "All hostnames of nodes in the cluster")
public String getHostNames() {
StringBuilder result = new StringBuilder();
for (SocketAddress node : getStats().keySet()) {
@@ -25,9 +28,22 @@ public class ClusterInfo extends AbstractMonitor {
return result.toString();
}
@ManagedOperation(description = "Number of Nodes")
@ManagedAttribute(description = "Number of nodes currently in the cluster")
public int getNumberOfNodes() {
return getStats().keySet().size();
}
@ManagedAttribute(description = "Couchbase Server versions of nodes in the cluster")
public String getNodeVersions() {
StringBuilder result = new StringBuilder();
for(Map.Entry<SocketAddress,Map<String,String>> entry : getStats().entrySet()) {
for(Map.Entry<String, String> stat : entry.getValue().entrySet()) {
if (stat.getKey().equals("ep_version")) {
result.append(stat.getValue()).append(",");
}
}
}
return result.toString();
}
}