Compare commits

...

5 Commits

Author SHA1 Message Date
Pekka Enberg
f928519591 release: prepare for 0.14.1 2016-01-05 15:31:12 +02:00
Amnon Heiman
1fa270985a StorageService: Support the update getLoadMap API
The API was modify to return the load map as a map of string to double
instead of formatted string.

This patch change the code to support the udpated API.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
2015-12-30 11:35:45 +02:00
Amnon Heiman
cff990a787 APIClient: Add a mapStringDouble method
This patch adds a method to the APIClient that return a map of String
and Double.

It support both simple and with query parameters.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
2015-12-30 11:35:41 +02:00
Amnon Heiman
2d320a2323 APIClient: Fixing parsing long as int
The APIClient use getInt to return a long value wich can cause number
trancation.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
2015-12-30 11:35:35 +02:00
Pekka Enberg
e14773daad release: prepare for 0.14 2015-12-30 10:29:20 +02:00
3 changed files with 43 additions and 5 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
VERSION=1.0
VERSION=0.14.1
if test -f version
then

View File

@ -576,7 +576,7 @@ public class APIClient {
if (obj.get(k) instanceof JsonString) {
key = obj.getString(k);
} else {
val = obj.getInt(k);
val = obj.getJsonNumber(k).longValue();
}
}
if (val > 0 && !key.equals("")) {
@ -692,4 +692,37 @@ public class APIClient {
public long[] getEstimatedHistogramAsLongArrValue(String string) {
return getEstimatedHistogramAsLongArrValue(string, null);
}
public Map<String, Double> getMapStringDouble(String string,
MultivaluedMap<String, String> queryParams) {
if (string.equals("")) {
return null;
}
JsonReader reader = getReader(string, queryParams);
JsonArray arr = reader.readArray();
Map<String, Double> map = new HashMap<String, Double>();
for (int i = 0; i < arr.size(); i++) {
JsonObject obj = arr.getJsonObject(i);
Iterator<String> it = obj.keySet().iterator();
String key = "";
double val = -1;
while (it.hasNext()) {
String k = it.next();
if (obj.get(k) instanceof JsonString) {
key = obj.getString(k);
} else {
val = obj.getJsonNumber(k).doubleValue();
}
}
if (!key.equals("")) {
map.put(key, val);
}
}
reader.close();
return map;
}
public Map<String, Double> getMapStringDouble(String string) {
return getMapStringDouble(string, null);
}
}

View File

@ -366,15 +366,20 @@ public class StorageService extends NotificationBroadcasterSupport
/** Human-readable load value. Keys are IP addresses. */
public Map<String, String> getLoadMap() {
log(" getLoadMap()");
Map<String, String> load = c.getMapStrValue("/storage_service/load_map");
Map<String, Double> load = getLoadMapAsDouble();
Map<String, String> map = new HashMap<>();
for (Map.Entry<String, String> entry : load.entrySet())
for (Map.Entry<String, Double> entry : load.entrySet())
{
map.put(entry.getKey(), FileUtils.stringifyFileSize(Double.parseDouble(entry.getValue())));
map.put(entry.getKey(), FileUtils.stringifyFileSize(entry.getValue()));
}
return map;
}
public Map<String, Double> getLoadMapAsDouble() {
log(" getLoadMapAsDouble()");
return c.getMapStringDouble("/storage_service/load_map");
}
/**
* Return the generation value for this node.
*