use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project java by wavefrontHQ.
the class JsonMetricsParser method processValueNode.
public static void processValueNode(JsonNode value, String table, String metric, String host, long timestamp, List<ReportPoint> points, Map<String, String> tags) {
if (value.isNumber()) {
if (value.isLong()) {
points.add(makePoint(table, metric, host, value.longValue(), timestamp, tags));
} else {
points.add(makePoint(table, metric, host, value.doubleValue(), timestamp, tags));
}
} else if (value.isTextual()) {
points.add(makePoint(table, metric, host, value.textValue(), timestamp, tags));
} else if (value.isObject()) {
if (/*wavefront histogram*/
value.has("bins")) {
Iterator<JsonNode> binIt = ((ArrayNode) value.get("bins")).elements();
while (binIt.hasNext()) {
JsonNode bin = binIt.next();
List<Integer> counts = newArrayList();
bin.get("counts").elements().forEachRemaining(v -> counts.add(v.intValue()));
List<Double> means = newArrayList();
bin.get("means").elements().forEachRemaining(v -> means.add(v.doubleValue()));
points.add(makeHistogramPoint(table, metric, host, tags, bin.get("startMillis").longValue(), bin.get("durationMillis").intValue(), means, counts));
}
} else {
report(table, metric, value, points, host, timestamp, tags);
}
} else if (value.isBoolean()) {
points.add(makePoint(table, metric, host, value.booleanValue() ? 1.0 : 0.0, timestamp, tags));
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project iobserve-analysis by research-iobserve.
the class TBehaviorModelVisualization method createEdges.
/**
* create new edges at visualization backend.
*
* @param entryCallEdges
* entryCallEdges
* @param modelId
* modelId
*/
private void createEdges(final Set<EntryCallEdge> entryCallEdges, final long modelId) {
final ArrayNode edges = this.objectMapper.createArrayNode();
for (final EntryCallEdge entryCallEdge : entryCallEdges) {
final ObjectNode json = this.objectMapper.createObjectNode();
final String sourceSignature = entryCallEdge.getSource().getSignature();
final String targetSignature = entryCallEdge.getTarget().getSignature();
json.put("id", 0);
json.put("start", this.nodeMap.get(sourceSignature));
json.put("end", this.nodeMap.get(targetSignature));
json.put("action", String.format("%s->%s", sourceSignature, targetSignature));
json.put("count", entryCallEdge.getCalls());
this.postElement(json, this.getEdgeUrl(modelId));
edges.add(json);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project swagger-parser by swagger-api.
the class OpenAPIDeserializer method getPathItem.
public PathItem getPathItem(ObjectNode obj, String location, ParseResult result) {
PathItem pathItem = new PathItem();
if (obj.get("$ref") != null) {
JsonNode ref = obj.get("$ref");
if (ref.getNodeType().equals(JsonNodeType.STRING)) {
String mungedRef = mungedRef(ref.textValue());
if (mungedRef != null) {
pathItem.set$ref(mungedRef);
} else {
pathItem.set$ref(ref.textValue());
}
return pathItem;
} else if (ref.getNodeType().equals(JsonNodeType.OBJECT)) {
ObjectNode node = (ObjectNode) ref;
// extra keys
Set<String> keys = getKeys(node);
for (String key : keys) {
result.extra(location, key, node.get(key));
}
}
return null;
}
String value = getString("summary", obj, false, location, result);
if ((result.isAllowEmptyStrings() && value != null) || (!result.isAllowEmptyStrings() && !StringUtils.isBlank(value))) {
pathItem.setSummary(value);
}
value = getString("description", obj, false, location, result);
if ((result.isAllowEmptyStrings() && value != null) || (!result.isAllowEmptyStrings() && !StringUtils.isBlank(value))) {
pathItem.setDescription(value);
}
ArrayNode parameters = getArray("parameters", obj, false, location, result);
if (parameters != null && parameters.size() > 0) {
pathItem.setParameters(getParameterList(parameters, location, result));
}
ArrayNode servers = getArray("servers", obj, false, location, result);
if (servers != null && servers.size() > 0) {
pathItem.setServers(getServersList(servers, location, result));
}
ObjectNode node = getObject("get", obj, false, location, result);
if (node != null) {
Operation operation = getOperation(node, location + "(get)", result);
if (operation != null) {
pathItem.setGet(operation);
}
}
node = getObject("put", obj, false, location, result);
if (node != null) {
Operation operation = getOperation(node, location + "(put)", result);
if (operation != null) {
pathItem.setPut(operation);
}
}
node = getObject("post", obj, false, location, result);
if (node != null) {
Operation operation = getOperation(node, location + "(post)", result);
if (operation != null) {
pathItem.setPost(operation);
}
}
node = getObject("head", obj, false, location, result);
if (node != null) {
Operation operation = getOperation(node, location + "(head)", result);
if (operation != null) {
pathItem.setHead(operation);
}
}
node = getObject("delete", obj, false, location, result);
if (node != null) {
Operation operation = getOperation(node, location + "(delete)", result);
if (operation != null) {
pathItem.setDelete(operation);
}
}
node = getObject("patch", obj, false, location, result);
if (node != null) {
Operation operation = getOperation(node, location + "(patch)", result);
if (operation != null) {
pathItem.setPatch(operation);
}
}
node = getObject("options", obj, false, location, result);
if (node != null) {
Operation operation = getOperation(node, location + "(options)", result);
if (operation != null) {
pathItem.setOptions(operation);
}
}
node = getObject("trace", obj, false, location, result);
if (node != null) {
Operation operation = getOperation(node, location + "(trace)", result);
if (operation != null) {
pathItem.setTrace(operation);
}
}
Map<String, Object> extensions = getExtensions(obj);
if (extensions != null && extensions.size() > 0) {
pathItem.setExtensions(extensions);
}
Set<String> keys = getKeys(obj);
for (String key : keys) {
if (!PATHITEM_KEYS.contains(key) && !key.startsWith("x-")) {
result.extra(location, key, obj.get(key));
}
}
return pathItem;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project swagger-parser by swagger-api.
the class OpenAPIDeserializer method getServerVariable.
public ServerVariable getServerVariable(ObjectNode obj, String location, ParseResult result) {
if (obj == null) {
return null;
}
ServerVariable serverVariable = new ServerVariable();
ArrayNode arrayNode = getArray("enum", obj, false, location, result);
if (arrayNode != null) {
List<String> _enum = new ArrayList<>();
for (JsonNode n : arrayNode) {
if (n.isValueNode()) {
_enum.add(n.asText());
serverVariable.setEnum(_enum);
} else {
result.invalidType(location, "enum", "value", n);
}
}
}
String value = getString("default", obj, true, String.format("%s.%s", location, "default"), result);
if ((result.isAllowEmptyStrings() && value != null) || (!result.isAllowEmptyStrings() && !StringUtils.isBlank(value))) {
serverVariable.setDefault(value);
}
value = getString("description", obj, false, String.format("%s.%s", location, "description"), result);
if ((result.isAllowEmptyStrings() && value != null) || (!result.isAllowEmptyStrings() && !StringUtils.isBlank(value))) {
serverVariable.setDescription(value);
}
Map<String, Object> extensions = getExtensions(obj);
if (extensions != null && extensions.size() > 0) {
serverVariable.setExtensions(extensions);
}
Set<String> keys = getKeys(obj);
for (String key : keys) {
if (!SERVER_VARIABLE_KEYS.contains(key) && !key.startsWith("x-")) {
result.extra(location, key, obj.get(key));
}
}
return serverVariable;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project swagger-parser by swagger-api.
the class OpenAPIDeserializer method getArray.
public ArrayNode getArray(String key, ObjectNode node, boolean required, String location, ParseResult result) {
JsonNode value = node.get(key);
ArrayNode arrayNode = null;
if (value == null) {
if (required) {
result.missing(location, key);
result.invalid();
}
} else if (!value.getNodeType().equals(JsonNodeType.ARRAY)) {
result.invalidType(location, key, "array", value);
} else {
arrayNode = (ArrayNode) value;
}
return arrayNode;
}
Aggregations