Urchin-JMX: Adding the EndpointSnitchInfo implementation

This adds the call to the API for the EndpointSnitch, the url are based
on the endpoint_snitch_info.json swagger definition file.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudus-systems.com>
This commit is contained in:
Amnon Heiman 2015-07-02 18:22:27 +03:00 committed by Pekka Enberg
parent aa546f3ccb
commit fe3b786053

View File

@ -22,8 +22,10 @@ import java.net.UnknownHostException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.ws.rs.core.MultivaluedMap;
import com.cloudius.urchin.api.APIClient;
import com.sun.jersey.core.util.MultivaluedMapImpl;
public class EndpointSnitchInfo implements EndpointSnitchInfoMBean {
private static final java.util.logging.Logger logger = java.util.logging.Logger
@ -32,7 +34,6 @@ public class EndpointSnitchInfo implements EndpointSnitchInfoMBean {
private APIClient c = new APIClient();
public void log(String str) {
System.out.println(str);
logger.info(str);
}
@ -61,7 +62,9 @@ public class EndpointSnitchInfo implements EndpointSnitchInfoMBean {
*/
public String getRack(String host) throws UnknownHostException {
log("getRack(String host) throws UnknownHostException");
return c.getStringValue("");
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("host", host);
return c.getStringValue("/snitch/rack", queryParams);
}
/**
@ -73,7 +76,9 @@ public class EndpointSnitchInfo implements EndpointSnitchInfoMBean {
*/
public String getDatacenter(String host) throws UnknownHostException {
log(" getDatacenter(String host) throws UnknownHostException");
return c.getStringValue("");
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("host", host);
return c.getStringValue("/snitch/datacenter", queryParams);
}
/**
@ -83,7 +88,7 @@ public class EndpointSnitchInfo implements EndpointSnitchInfoMBean {
*/
public String getSnitchName() {
log(" getSnitchName()");
return c.getStringValue("");
return c.getStringValue("/snitch/name");
}
}