// create the nodes object if its missing nodesMap.putIfAbsent("nodes", new JsonArray(), res2 -> { if (res2.succeeded()) { logger.info((res2.result())); } else { logger.warn("unable to put new nodes"); } });
// add the address of this node to the nodes object nodesMap.putIfAbsent("nodes", new JsonArray(), res2 -> { if (res2.succeeded()) { res2.result().add(uniqueAddress); } else { logger.warn("unable add this node to nodes"); } });
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/bd9ef8a7-7748-4f85-b62e-dde68bf5a6e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/9bc274fd-1204-43a9-94ae-baabbd053962%40googlegroups.com.
sd.<String, JsonArray>getClusterWideMap("nodes", res -> { if (res.succeeded()) {
// get the map AsyncMap<String, JsonArray> nodesMap = res.result();
// JsonArray myObject = new JsonArray();
// create the nodes object if its missing nodesMap.putIfAbsent("nodesList", myObject, res2 -> { if (res.succeeded()) { JsonArray obj = res.result(); if (obj == null) { obj = myObject; } obj.add(uniqueAddress); // how do I update res2.result() since its null? } });
} else { logger.warn("No clusterwide map support"); }
});
sd.<String, JsonArray>getClusterWideMap("nodes", getMap -> { if (getMap.succeeded()) {
// get the map AsyncMap<String, JsonArray> nodesMap = getMap.result();
// create the nodes object if its missing nodesMap.putIfAbsent("nodesList", new JsonArray(), newList -> { if (newList.succeeded()) { // this will actually update the list nodesMap.get("nodesList", updateList -> { if (updateList.succeeded()) { updateList.result().add(uniqueAddress); } });
} });
} else { logger.warn("No clusterwide map support"); }
});To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/d3faf090-6afa-4279-870d-562f85cfbbce%40googlegroups.com.