use of com.hazelcast.internal.json.JsonArray 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.JsonArray in project hazelcast by hazelcast.
the class AwsEcsApi method createBodyDescribeTasks.
private String createBodyDescribeTasks(String cluster, List<String> taskArns) {
JsonArray jsonArray = new JsonArray();
taskArns.stream().map(Json::value).forEach(jsonArray::add);
return new JsonObject().add("tasks", jsonArray).add("cluster", cluster).toString();
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testSkipsScalarValuesInCaseOfAnyAndAttributeName.
@Test
public void testSkipsScalarValuesInCaseOfAnyAndAttributeName() {
JsonArray array1 = Json.array(new int[] { 1, 2, 3, 5000 });
JsonArray array2 = Json.array(new int[] { 1, 5000, 3, 5 });
JsonArray array3 = Json.array(new int[] { 1, 5000, 30, 40 });
array1.add(Json.object().add("innerAttribute", 5000));
JsonValue value1 = Json.object().add("arr", array1);
JsonValue value2 = Json.object().add("arr", array2);
JsonValue value3 = Json.object().add("arr", array3);
IMap<String, HazelcastJsonValue> map = instance.getMap(randomMapName());
HazelcastJsonValue p1 = putJsonString(map, "one", value1);
putJsonString(map, "two", value2);
putJsonString(map, "three", value3);
Collection<HazelcastJsonValue> vals = map.values(Predicates.equal("arr[any].innerAttribute", 5000));
assertEquals(1, vals.size());
assertTrue(vals.contains(p1));
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testArrayInNestedQuery.
@Test
public void testArrayInNestedQuery() {
JsonObject object1 = Json.object();
JsonObject nested1 = Json.object();
JsonObject object2 = Json.object();
JsonObject nested2 = Json.object();
JsonArray array1 = Json.array(new int[] { 1, 2, 3, 4, 5, 6 });
JsonArray array2 = Json.array(new int[] { 10, 20, 30, 40, 50, 60 });
nested1.add("arr", array1);
nested2.add("arr", array2);
object1.add("inner", nested1);
object2.add("inner", nested2);
IMap<String, JsonValue> map = instance.getMap(randomMapName());
HazelcastJsonValue p1 = putJsonString(map, "one", object1);
HazelcastJsonValue p2 = putJsonString(map, "two", object2);
Collection<JsonValue> vals = map.values(Predicates.greaterEqual("inner.arr[2]", 20));
assertEquals(1, vals.size());
assertTrue(vals.contains(p2));
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class MapPredicateJsonTest method testQueryOnArrayIndex.
@Test
public void testQueryOnArrayIndex() {
JsonObject value1 = Json.object();
JsonObject value2 = Json.object();
JsonObject value3 = Json.object();
JsonArray array1 = Json.array(new int[] { 1, 2, 3, 4, 5 });
JsonArray array2 = Json.array(new int[] { 10, 20, 30, 40, 50 });
JsonArray array3 = Json.array(new int[] { 100, 200, 300, 400, 500 });
value1.add("numbers", array1);
value2.add("numbers", array2);
value3.add("numbers", array3);
IMap<String, JsonValue> map = instance.getMap(randomMapName());
HazelcastJsonValue p1 = putJsonString(map, "one", value1);
HazelcastJsonValue p2 = putJsonString(map, "two", value2);
HazelcastJsonValue p3 = putJsonString(map, "three", value3);
Collection<String> vals = map.keySet(Predicates.greaterEqual("numbers[1]", 20));
assertEquals(2, vals.size());
assertTrue(vals.contains("two"));
assertTrue(vals.contains("three"));
}
Aggregations