use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project flink by apache.
the class SubtasksTimesHandlerTest method compareSubtaskTimes.
private static void compareSubtaskTimes(AccessExecutionJobVertex originalTask, AccessExecution originalAttempt, String json) throws IOException {
JsonNode result = ArchivedJobGenerationUtils.mapper.readTree(json);
Assert.assertEquals(originalTask.getJobVertexId().toString(), result.get("id").asText());
Assert.assertEquals(originalTask.getName(), result.get("name").asText());
Assert.assertTrue(result.get("now").asLong() > 0L);
ArrayNode subtasks = (ArrayNode) result.get("subtasks");
JsonNode subtask = subtasks.get(0);
Assert.assertEquals(0, subtask.get("subtask").asInt());
Assert.assertEquals(originalAttempt.getAssignedResourceLocation().getHostname(), subtask.get("host").asText());
Assert.assertEquals(originalAttempt.getStateTimestamp(originalAttempt.getState()) - originalAttempt.getStateTimestamp(ExecutionState.SCHEDULED), subtask.get("duration").asLong());
JsonNode timestamps = subtask.get("timestamps");
Assert.assertEquals(originalAttempt.getStateTimestamp(ExecutionState.CREATED), timestamps.get(ExecutionState.CREATED.name()).asLong());
Assert.assertEquals(originalAttempt.getStateTimestamp(ExecutionState.SCHEDULED), timestamps.get(ExecutionState.SCHEDULED.name()).asLong());
Assert.assertEquals(originalAttempt.getStateTimestamp(ExecutionState.DEPLOYING), timestamps.get(ExecutionState.DEPLOYING.name()).asLong());
Assert.assertEquals(originalAttempt.getStateTimestamp(ExecutionState.RUNNING), timestamps.get(ExecutionState.RUNNING.name()).asLong());
Assert.assertEquals(originalAttempt.getStateTimestamp(ExecutionState.FINISHED), timestamps.get(ExecutionState.FINISHED.name()).asLong());
Assert.assertEquals(originalAttempt.getStateTimestamp(ExecutionState.CANCELING), timestamps.get(ExecutionState.CANCELING.name()).asLong());
Assert.assertEquals(originalAttempt.getStateTimestamp(ExecutionState.CANCELED), timestamps.get(ExecutionState.CANCELED.name()).asLong());
Assert.assertEquals(originalAttempt.getStateTimestamp(ExecutionState.FAILED), timestamps.get(ExecutionState.FAILED.name()).asLong());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project flink by apache.
the class WebFrontendITCase method getTaskmanagers.
@Test
public void getTaskmanagers() {
try {
String json = getFromHTTP("http://localhost:" + port + "/taskmanagers/");
ObjectMapper mapper = new ObjectMapper();
JsonNode parsed = mapper.readTree(json);
ArrayNode taskManagers = (ArrayNode) parsed.get("taskmanagers");
assertNotNull(taskManagers);
assertEquals(cluster.numTaskManagers(), taskManagers.size());
JsonNode taskManager = taskManagers.get(0);
assertNotNull(taskManager);
assertEquals(NUM_SLOTS, taskManager.get("slotsNumber").asInt());
assertTrue(taskManager.get("freeSlots").asInt() <= NUM_SLOTS);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project swagger-parser by swagger-api.
the class SwaggerJsonValidator method fillMessages.
private static boolean fillMessages(final ProcessingReport report, final MessageBuilder builder) {
final Severity severity = LEVEL_MAP.get(report.getLogLevel());
final ArrayNode node = JacksonUtils.nodeFactory().arrayNode();
for (final ProcessingMessage processingMessage : report) {
node.add(processingMessage.asJson());
}
final String reportAsString = JacksonUtils.prettyPrint(node);
final Message message = new Message("", reportAsString, severity);
builder.append(message);
return report.isSuccess();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project swagger-parser by swagger-api.
the class SwaggerCompatConverter method propertyFromTypedObject.
public Property propertyFromTypedObject(ExtendedTypedObject obj) {
String type = obj.getType() == null ? null : obj.getType().toString();
String format = obj.getFormat() == null ? null : obj.getFormat().toString();
Property output = null;
if ("array".equals(type)) {
ArrayProperty am = new ArrayProperty();
Items items = obj.getItems();
if (items == null) {
LOGGER.error("Error! Missing array type for property! Assuming `object` -- please fix your spec");
items = new Items();
items.setType("object");
}
type = items.getType() == null ? null : items.getType().toString();
format = items.getFormat() == null ? null : items.getFormat().toString();
Map<PropertyBuilder.PropertyId, Object> args = new HashMap<>();
if (items.getExtraFields().get("enum") != null && items.getExtraFields().get("enum").isArray()) {
ArrayNode an = (ArrayNode) items.getExtraFields().get("enum");
List<String> enumValues = new ArrayList<>();
for (JsonNode jn : an) {
enumValues.add(jn.textValue());
}
args.put(PropertyBuilder.PropertyId.ENUM, enumValues);
}
Property innerType = PropertyBuilder.build(type, format, args);
if (innerType != null && !(innerType instanceof UntypedProperty)) {
am.setItems(innerType);
} else if (items.getRef() != null) {
am.setItems(new RefProperty(items.getRef()));
} else {
am.setItems(new RefProperty(type));
}
output = am;
} else {
Map<PropertyBuilder.PropertyId, Object> args = new HashMap<PropertyBuilder.PropertyId, Object>();
if (obj.getEnumValues() != null && obj.getEnumValues().size() > 0) {
args.put(PropertyBuilder.PropertyId.ENUM, obj.getEnumValues());
}
if (obj.getMinimum() != null) {
args.put(PropertyBuilder.PropertyId.MINIMUM, new BigDecimal(obj.getMinimum()));
}
if (obj.getMaximum() != null) {
args.put(PropertyBuilder.PropertyId.MAXIMUM, new BigDecimal(obj.getMaximum()));
}
Property i = PropertyBuilder.build(type, format, args);
if (i != null && !(i instanceof UntypedProperty)) {
output = i;
} else {
if (obj.getRef() != null) {
output = new RefProperty(obj.getRef());
} else if (type != null && !type.equals("void")) {
output = new RefProperty(type);
}
}
}
return output;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project swagger-parser by swagger-api.
the class MutableJsonTree method applyMigratorToElements.
/**
* Apply a migrator to all elements of the array at the current pointer
*
* <p>Note that if the migrator fails to apply to at least one element, the
* original array is left untouched; its elements are replaced if and only
* if the migrator applies successfully to <strong>all</strong> elements.
* </p>
*
* @param migrator the migrator to apply
* @throws SwaggerMigrationException current node is not a JSON Array, or
* migrator failed to apply to at least one array element
*/
public void applyMigratorToElements(final SwaggerMigrator migrator) throws SwaggerMigrationException {
if (!currentNode.isArray()) {
throw new SwaggerMigrationException();
}
final ArrayNode array = (ArrayNode) currentNode;
final ArrayNode transformed = array.arrayNode();
for (final JsonNode element : array) {
transformed.add(migrator.migrate(element));
}
array.removeAll().addAll(transformed);
}
Aggregations