Merge "Add the StorageService ownership support" from Amnon
"This series adds the effectiveOwnership and getOwnership support to StorageService. After applying the series the methods will be available from jconsole."
This commit is contained in:
commit
4a3af8ce03
@ -37,6 +37,8 @@ import javax.ws.rs.core.MediaType;
|
||||
|
||||
public class APIClient {
|
||||
JsonReaderFactory factory = Json.createReaderFactory(null);
|
||||
private static final java.util.logging.Logger logger = java.util.logging.Logger
|
||||
.getLogger(APIClient.class.getName());
|
||||
|
||||
public static String getBaseUrl() {
|
||||
return "http://" + System.getProperty("apiaddress", "localhost") + ":"
|
||||
@ -372,11 +374,29 @@ public class APIClient {
|
||||
return Long.parseLong(getStringValue(string));
|
||||
}
|
||||
|
||||
public Map<InetAddress, Float> getMapInetAddressFloatValue(String string) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public Map<InetAddress, Float> getMapInetAddressFloatValue(String string,
|
||||
MultivaluedMap<String, String> queryParams) {
|
||||
Map<InetAddress, Float> res = new HashMap<InetAddress, Float>();
|
||||
|
||||
JsonReader reader = getReader(string, queryParams);
|
||||
|
||||
JsonArray arr = reader.readArray();
|
||||
JsonObject obj = null;
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
try {
|
||||
obj = arr.getJsonObject(i);
|
||||
res.put(InetAddress.getByName(obj.getString("key")),
|
||||
Float.parseFloat(obj.getString("value")));
|
||||
} catch (UnknownHostException e) {
|
||||
logger.warning("Bad formatted address " + obj.getString("key"));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public Map<InetAddress, Float> getMapInetAddressFloatValue(String string) {
|
||||
return getMapInetAddressFloatValue(string, null);
|
||||
}
|
||||
public Map<String, Long> getMapStringLongValue(String string) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
@ -735,8 +735,7 @@ public class StorageService extends NotificationBroadcasterSupport
|
||||
*/
|
||||
public Map<InetAddress, Float> getOwnership() {
|
||||
log(" getOwnership()");
|
||||
// TBD
|
||||
return c.getMapInetAddressFloatValue("");
|
||||
return c.getMapInetAddressFloatValue("/storage_service/ownership/");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -749,8 +748,11 @@ public class StorageService extends NotificationBroadcasterSupport
|
||||
public Map<InetAddress, Float> effectiveOwnership(String keyspace)
|
||||
throws IllegalStateException {
|
||||
log(" effectiveOwnership(String keyspace) throws IllegalStateException");
|
||||
// TBD
|
||||
return c.getMapInetAddressFloatValue("");
|
||||
try {
|
||||
return c.getMapInetAddressFloatValue("/storage_service/ownership/" + keyspace);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Non-system keyspaces don't have the same replication settings, effective ownership information is meaningless");
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getKeyspaces() {
|
||||
|
Loading…
Reference in New Issue
Block a user