Java源码示例:org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationContext
示例1
@Override
public JobConfigInfo deserialize(
JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException {
JsonNode rootNode = jsonParser.readValueAsTree();
final JobID jobId = JobID.fromHexString(rootNode.get(FIELD_NAME_JOB_ID).asText());
final String jobName = rootNode.get(FIELD_NAME_JOB_NAME).asText();
final ExecutionConfigInfo executionConfigInfo;
if (rootNode.has(FIELD_NAME_EXECUTION_CONFIG)) {
executionConfigInfo = RestMapperUtils.getStrictObjectMapper().treeToValue(rootNode.get(FIELD_NAME_EXECUTION_CONFIG), ExecutionConfigInfo.class);
} else {
executionConfigInfo = null;
}
return new JobConfigInfo(jobId, jobName, executionConfigInfo);
}
示例2
@SuppressWarnings("unchecked")
private Map<String, SerializedValue<OptionalFailure<Object>>> parseAccumulatorResults(
final JsonParser p,
final DeserializationContext ctxt) throws IOException {
final Map<String, SerializedValue<OptionalFailure<Object>>> accumulatorResults = new HashMap<>();
while (true) {
final JsonToken jsonToken = p.nextToken();
assertNotEndOfInput(p, jsonToken);
if (jsonToken == JsonToken.END_OBJECT) {
break;
}
final String accumulatorName = p.getValueAsString();
p.nextValue();
accumulatorResults.put(
accumulatorName,
(SerializedValue<OptionalFailure<Object>>) serializedValueDeserializer.deserialize(p, ctxt));
}
return accumulatorResults;
}
示例3
@Override
public JobConfigInfo deserialize(
JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException {
JsonNode rootNode = jsonParser.readValueAsTree();
final JobID jobId = JobID.fromHexString(rootNode.get(FIELD_NAME_JOB_ID).asText());
final String jobName = rootNode.get(FIELD_NAME_JOB_NAME).asText();
final ExecutionConfigInfo executionConfigInfo;
if (rootNode.has(FIELD_NAME_EXECUTION_CONFIG)) {
executionConfigInfo = RestMapperUtils.getStrictObjectMapper().treeToValue(rootNode.get(FIELD_NAME_EXECUTION_CONFIG), ExecutionConfigInfo.class);
} else {
executionConfigInfo = null;
}
return new JobConfigInfo(jobId, jobName, executionConfigInfo);
}
示例4
@SuppressWarnings("unchecked")
private Map<String, SerializedValue<OptionalFailure<Object>>> parseAccumulatorResults(
final JsonParser p,
final DeserializationContext ctxt) throws IOException {
final Map<String, SerializedValue<OptionalFailure<Object>>> accumulatorResults = new HashMap<>();
while (true) {
final JsonToken jsonToken = p.nextToken();
assertNotEndOfInput(p, jsonToken);
if (jsonToken == JsonToken.END_OBJECT) {
break;
}
final String accumulatorName = p.getValueAsString();
p.nextValue();
accumulatorResults.put(
accumulatorName,
(SerializedValue<OptionalFailure<Object>>) serializedValueDeserializer.deserialize(p, ctxt));
}
return accumulatorResults;
}
示例5
@Override
public JobConfigInfo deserialize(
JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException {
JsonNode rootNode = jsonParser.readValueAsTree();
final JobID jobId = JobID.fromHexString(rootNode.get(FIELD_NAME_JOB_ID).asText());
final String jobName = rootNode.get(FIELD_NAME_JOB_NAME).asText();
final ExecutionConfigInfo executionConfigInfo;
if (rootNode.has(FIELD_NAME_EXECUTION_CONFIG)) {
executionConfigInfo = RestMapperUtils.getStrictObjectMapper().treeToValue(rootNode.get(FIELD_NAME_EXECUTION_CONFIG), ExecutionConfigInfo.class);
} else {
executionConfigInfo = null;
}
return new JobConfigInfo(jobId, jobName, executionConfigInfo);
}
示例6
@SuppressWarnings("unchecked")
private Map<String, SerializedValue<OptionalFailure<Object>>> parseAccumulatorResults(
final JsonParser p,
final DeserializationContext ctxt) throws IOException {
final Map<String, SerializedValue<OptionalFailure<Object>>> accumulatorResults = new HashMap<>();
while (true) {
final JsonToken jsonToken = p.nextToken();
assertNotEndOfInput(p, jsonToken);
if (jsonToken == JsonToken.END_OBJECT) {
break;
}
final String accumulatorName = p.getValueAsString();
p.nextValue();
accumulatorResults.put(
accumulatorName,
(SerializedValue<OptionalFailure<Object>>) serializedValueDeserializer.deserialize(p, ctxt));
}
return accumulatorResults;
}
示例7
@Override
public JobDetails deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
JsonNode rootNode = jsonParser.readValueAsTree();
JobID jobId = JobID.fromHexString(rootNode.get(FIELD_NAME_JOB_ID).textValue());
String jobName = rootNode.get(FIELD_NAME_JOB_NAME).textValue();
long startTime = rootNode.get(FIELD_NAME_START_TIME).longValue();
long endTime = rootNode.get(FIELD_NAME_END_TIME).longValue();
long duration = rootNode.get(FIELD_NAME_DURATION).longValue();
JobStatus jobStatus = JobStatus.valueOf(rootNode.get(FIELD_NAME_STATUS).textValue());
long lastUpdateTime = rootNode.get(FIELD_NAME_LAST_MODIFICATION).longValue();
JsonNode tasksNode = rootNode.get("tasks");
int numTasks = tasksNode.get(FIELD_NAME_TOTAL_NUMBER_TASKS).intValue();
int[] numVerticesPerExecutionState = new int[ExecutionState.values().length];
for (ExecutionState executionState : ExecutionState.values()) {
numVerticesPerExecutionState[executionState.ordinal()] = tasksNode.get(executionState.name().toLowerCase()).intValue();
}
return new JobDetails(
jobId,
jobName,
startTime,
endTime,
duration,
jobStatus,
lastUpdateTime,
numVerticesPerExecutionState,
numTasks);
}
示例8
@Override
public RawJson deserialize(
JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException {
final JsonNode rootNode = jsonParser.readValueAsTree();
return new RawJson(rootNode.toString());
}
示例9
@Override
public MetricCollectionResponseBody deserialize(
JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException {
return new MetricCollectionResponseBody(jsonParser.readValueAs(
new TypeReference<List<Metric>>() {
}));
}
示例10
@Override
public AggregatedMetricsResponseBody deserialize(
JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException {
return new AggregatedMetricsResponseBody(jsonParser.readValueAs(
new TypeReference<List<AggregatedMetric>>() {
}));
}
示例11
@Override
public SerializedThrowable deserialize(
final JsonParser p,
final DeserializationContext ctxt) throws IOException {
final JsonNode root = p.readValueAsTree();
final byte[] serializedException = root.get(FIELD_NAME_SERIALIZED_THROWABLE).binaryValue();
try {
return InstantiationUtil.deserializeObject(serializedException, ClassLoader.getSystemClassLoader());
} catch (ClassNotFoundException e) {
throw new IOException("Failed to deserialize " + SerializedThrowable.class.getCanonicalName(), e);
}
}
示例12
@Override
public JobDetails deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
JsonNode rootNode = jsonParser.readValueAsTree();
JobID jobId = JobID.fromHexString(rootNode.get(FIELD_NAME_JOB_ID).textValue());
String jobName = rootNode.get(FIELD_NAME_JOB_NAME).textValue();
long startTime = rootNode.get(FIELD_NAME_START_TIME).longValue();
long endTime = rootNode.get(FIELD_NAME_END_TIME).longValue();
long duration = rootNode.get(FIELD_NAME_DURATION).longValue();
JobStatus jobStatus = JobStatus.valueOf(rootNode.get(FIELD_NAME_STATUS).textValue());
long lastUpdateTime = rootNode.get(FIELD_NAME_LAST_MODIFICATION).longValue();
JsonNode tasksNode = rootNode.get("tasks");
int numTasks = tasksNode.get(FIELD_NAME_TOTAL_NUMBER_TASKS).intValue();
int[] numVerticesPerExecutionState = new int[ExecutionState.values().length];
for (ExecutionState executionState : ExecutionState.values()) {
numVerticesPerExecutionState[executionState.ordinal()] = tasksNode.get(executionState.name().toLowerCase()).intValue();
}
return new JobDetails(
jobId,
jobName,
startTime,
endTime,
duration,
jobStatus,
lastUpdateTime,
numVerticesPerExecutionState,
numTasks);
}
示例13
@Override
public RawJson deserialize(
JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException {
final JsonNode rootNode = jsonParser.readValueAsTree();
return new RawJson(rootNode.toString());
}
示例14
@Override
public MetricCollectionResponseBody deserialize(
JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException {
return new MetricCollectionResponseBody(jsonParser.readValueAs(
new TypeReference<List<Metric>>() {
}));
}
示例15
@Override
public AggregatedMetricsResponseBody deserialize(
JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException {
return new AggregatedMetricsResponseBody(jsonParser.readValueAs(
new TypeReference<List<AggregatedMetric>>() {
}));
}
示例16
@Override
public SerializedThrowable deserialize(
final JsonParser p,
final DeserializationContext ctxt) throws IOException {
final JsonNode root = p.readValueAsTree();
final byte[] serializedException = root.get(FIELD_NAME_SERIALIZED_THROWABLE).binaryValue();
try {
return InstantiationUtil.deserializeObject(serializedException, ClassLoader.getSystemClassLoader());
} catch (ClassNotFoundException e) {
throw new IOException("Failed to deserialize " + SerializedThrowable.class.getCanonicalName(), e);
}
}
示例17
@Override
public JobDetails deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
JsonNode rootNode = jsonParser.readValueAsTree();
JobID jobId = JobID.fromHexString(rootNode.get(FIELD_NAME_JOB_ID).textValue());
String jobName = rootNode.get(FIELD_NAME_JOB_NAME).textValue();
long startTime = rootNode.get(FIELD_NAME_START_TIME).longValue();
long endTime = rootNode.get(FIELD_NAME_END_TIME).longValue();
long duration = rootNode.get(FIELD_NAME_DURATION).longValue();
JobStatus jobStatus = JobStatus.valueOf(rootNode.get(FIELD_NAME_STATUS).textValue());
long lastUpdateTime = rootNode.get(FIELD_NAME_LAST_MODIFICATION).longValue();
JsonNode tasksNode = rootNode.get("tasks");
int numTasks = tasksNode.get(FIELD_NAME_TOTAL_NUMBER_TASKS).intValue();
int[] numVerticesPerExecutionState = new int[ExecutionState.values().length];
for (ExecutionState executionState : ExecutionState.values()) {
numVerticesPerExecutionState[executionState.ordinal()] = tasksNode.get(executionState.name().toLowerCase()).intValue();
}
return new JobDetails(
jobId,
jobName,
startTime,
endTime,
duration,
jobStatus,
lastUpdateTime,
numVerticesPerExecutionState,
numTasks);
}
示例18
@Override
public RawJson deserialize(
JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException {
final JsonNode rootNode = jsonParser.readValueAsTree();
return new RawJson(rootNode.toString());
}
示例19
@Override
public MetricCollectionResponseBody deserialize(
JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException {
return new MetricCollectionResponseBody(jsonParser.readValueAs(
new TypeReference<List<Metric>>() {
}));
}
示例20
@Override
public AggregatedMetricsResponseBody deserialize(
JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException {
return new AggregatedMetricsResponseBody(jsonParser.readValueAs(
new TypeReference<List<AggregatedMetric>>() {
}));
}
示例21
@Override
public SerializedThrowable deserialize(
final JsonParser p,
final DeserializationContext ctxt) throws IOException {
final JsonNode root = p.readValueAsTree();
final byte[] serializedException = root.get(FIELD_NAME_SERIALIZED_THROWABLE).binaryValue();
try {
return InstantiationUtil.deserializeObject(serializedException, ClassLoader.getSystemClassLoader());
} catch (ClassNotFoundException e) {
throw new IOException("Failed to deserialize " + SerializedThrowable.class.getCanonicalName(), e);
}
}
示例22
@Override
public ProcessingMode deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException {
return ProcessingMode.valueOf(jsonParser.getValueAsString().toUpperCase());
}
示例23
@Override
public JobID deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
return JobID.fromHexString(p.getValueAsString());
}
示例24
@Override
public ResourceID deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
return new ResourceID(p.getValueAsString());
}
示例25
@Override
public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
final JsonNode jsonNode = ctxt.readValue(p, JsonNode.class);
return jsonNode.toString();
}
示例26
@Override
public JobResult deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
JobID jobId = null;
ApplicationStatus applicationStatus = ApplicationStatus.UNKNOWN;
long netRuntime = -1;
SerializedThrowable serializedThrowable = null;
Map<String, SerializedValue<OptionalFailure<Object>>> accumulatorResults = null;
while (true) {
final JsonToken jsonToken = p.nextToken();
assertNotEndOfInput(p, jsonToken);
if (jsonToken == JsonToken.END_OBJECT) {
break;
}
final String fieldName = p.getValueAsString();
switch (fieldName) {
case JobResultSerializer.FIELD_NAME_JOB_ID:
assertNextToken(p, JsonToken.VALUE_STRING);
jobId = jobIdDeserializer.deserialize(p, ctxt);
break;
case JobResultSerializer.FIELD_NAME_APPLICATION_STATUS:
assertNextToken(p, JsonToken.VALUE_STRING);
applicationStatus = ApplicationStatus.valueOf(p.getValueAsString().toUpperCase());
break;
case JobResultSerializer.FIELD_NAME_NET_RUNTIME:
assertNextToken(p, JsonToken.VALUE_NUMBER_INT);
netRuntime = p.getLongValue();
break;
case JobResultSerializer.FIELD_NAME_ACCUMULATOR_RESULTS:
assertNextToken(p, JsonToken.START_OBJECT);
accumulatorResults = parseAccumulatorResults(p, ctxt);
break;
case JobResultSerializer.FIELD_NAME_FAILURE_CAUSE:
assertNextToken(p, JsonToken.START_OBJECT);
serializedThrowable = serializedThrowableDeserializer.deserialize(p, ctxt);
break;
default:
// ignore unknown fields
}
}
try {
return new JobResult.Builder()
.jobId(jobId)
.applicationStatus(applicationStatus)
.netRuntime(netRuntime)
.accumulatorResults(accumulatorResults)
.serializedThrowable(serializedThrowable)
.build();
} catch (final RuntimeException e) {
throw new JsonMappingException(
null,
"Could not deserialize " + JobResult.class.getSimpleName(),
e);
}
}
示例27
@Override
public JobVertexID deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
return JobVertexID.fromHexString(p.getValueAsString());
}
示例28
@Override
public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException {
return JobVertexID.fromHexString(key);
}
示例29
@Override
public SerializedValue<?> deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
return SerializedValue.fromBytes(p.getBinaryValue());
}
示例30
@Override
public TriggerId deserialize(
final JsonParser p,
final DeserializationContext ctxt) throws IOException {
return TriggerId.fromHexString(p.getValueAsString());
}