use of com.hazelcast.internal.json.JsonValue in project hazelcast by hazelcast.
the class JsonUtil method getDouble.
/**
* Returns a field in a Json object as a double.
* Throws IllegalArgumentException if the field value is null.
*
* @param object the Json Object
* @param field the field in the Json object to return
* @return the Json field value as a double
*/
public static double getDouble(JsonObject object, String field) {
final JsonValue value = object.get(field);
throwExceptionIfNull(value, field);
return value.asDouble();
}
use of com.hazelcast.internal.json.JsonValue in project hazelcast by hazelcast.
the class JsonUtil method getString.
/**
* Returns a field in a Json object as a string.
* Throws IllegalArgumentException if the field value is null.
*
* @param object the Json Object
* @param field the field in the Json object to return
* @return the Json field value as a string
*/
public static String getString(JsonObject object, String field) {
final JsonValue value = object.get(field);
throwExceptionIfNull(value, field);
return value.asString();
}
use of com.hazelcast.internal.json.JsonValue in project hazelcast by hazelcast.
the class JsonUtil method getLong.
/**
* Returns a field in a Json object as a long.
* Throws IllegalArgumentException if the field value is null.
*
* @param object the Json Object
* @param field the field in the Json object to return
* @return the Json field value as a long
*/
public static long getLong(JsonObject object, String field) {
final JsonValue value = object.get(field);
throwExceptionIfNull(value, field);
return value.asLong();
}
use of com.hazelcast.internal.json.JsonValue in project hazelcast by hazelcast.
the class ElasticCatClient method nodes.
/**
* Returns list of nodes currently in ES cluster
*/
public List<Node> nodes() {
try {
Request r = new Request("GET", "/_cat/nodes");
r.addParameter("format", "json");
r.addParameter("full_id", "true");
r.addParameter("h", "id,ip,name,http_address,master");
Response res = withRetry(() -> client.performRequest(r), retries);
try (InputStreamReader reader = new InputStreamReader(res.getEntity().getContent(), UTF_8)) {
JsonArray array = Json.parse(reader).asArray();
List<Node> nodes = new ArrayList<>(array.size());
for (JsonValue value : array) {
Optional<Node> shard = convertToNode(value);
shard.ifPresent(nodes::add);
}
LOG.fine("Nodes: " + nodes);
return nodes;
}
} catch (IOException e) {
throw new JetException("Could not get ES cluster nodes", e);
}
}
use of com.hazelcast.internal.json.JsonValue in project hazelcast by hazelcast.
the class AzureComputeApi method parsePrivateIpResponse.
private Map<String, AzureNetworkInterface> parsePrivateIpResponse(String response) {
Map<String, AzureNetworkInterface> interfaces = new HashMap<>();
for (JsonValue item : toJsonArray(Json.parse(response).asObject().get("value"))) {
Set<Tag> tagList = new HashSet<>();
JsonObject tags = toJsonObject(item.asObject().get("tags"));
for (String key : tags.asObject().names()) {
tagList.add(new Tag(key, tags.asObject().getString(key, null)));
}
JsonObject properties = item.asObject().get("properties").asObject();
if (properties.get("virtualMachine") != null) {
for (JsonValue ipConfiguration : toJsonArray(properties.get("ipConfigurations"))) {
JsonObject ipProps = ipConfiguration.asObject().get("properties").asObject();
String privateIp = ipProps.getString("privateIPAddress", null);
String publicIpId = toJsonObject(ipProps.get("publicIPAddress")).getString("id", null);
if (!isNullOrEmptyAfterTrim(privateIp)) {
interfaces.put(privateIp, new AzureNetworkInterface(privateIp, publicIpId, tagList));
}
}
}
}
return interfaces;
}
Aggregations