org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationContext Java Examples

The following examples show how to use org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobConfigInfo.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: JobConfigInfo.java    From flink with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: JobConfigInfo.java    From flink with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #4
Source File: JobResultDeserializer.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #5
Source File: JobResultDeserializer.java    From flink with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #6
Source File: JobResultDeserializer.java    From flink with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #7
Source File: SerializedThrowableDeserializer.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example #8
Source File: AggregatedMetricsResponseBody.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public AggregatedMetricsResponseBody deserialize(
	JsonParser jsonParser,
	DeserializationContext deserializationContext) throws IOException {

	return new AggregatedMetricsResponseBody(jsonParser.readValueAs(
		new TypeReference<List<AggregatedMetric>>() {
		}));
}
 
Example #9
Source File: MetricCollectionResponseBody.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public MetricCollectionResponseBody deserialize(
		JsonParser jsonParser,
		DeserializationContext deserializationContext) throws IOException {

	return new MetricCollectionResponseBody(jsonParser.readValueAs(
		new TypeReference<List<Metric>>() {
		}));
}
 
Example #10
Source File: AggregatedMetricsResponseBody.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public AggregatedMetricsResponseBody deserialize(
	JsonParser jsonParser,
	DeserializationContext deserializationContext) throws IOException {

	return new AggregatedMetricsResponseBody(jsonParser.readValueAs(
		new TypeReference<List<AggregatedMetric>>() {
		}));
}
 
Example #11
Source File: MetricCollectionResponseBody.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public MetricCollectionResponseBody deserialize(
		JsonParser jsonParser,
		DeserializationContext deserializationContext) throws IOException {

	return new MetricCollectionResponseBody(jsonParser.readValueAs(
		new TypeReference<List<Metric>>() {
		}));
}
 
Example #12
Source File: JobPlanInfo.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public RawJson deserialize(
		JsonParser jsonParser,
		DeserializationContext deserializationContext) throws IOException {
	final JsonNode rootNode = jsonParser.readValueAsTree();
	return new RawJson(rootNode.toString());
}
 
Example #13
Source File: JobDetails.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #14
Source File: SerializedThrowableDeserializer.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example #15
Source File: SerializedThrowableDeserializer.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example #16
Source File: JobPlanInfo.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public RawJson deserialize(
		JsonParser jsonParser,
		DeserializationContext deserializationContext) throws IOException {
	final JsonNode rootNode = jsonParser.readValueAsTree();
	return new RawJson(rootNode.toString());
}
 
Example #17
Source File: JobDetails.java    From flink with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #18
Source File: JobDetails.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #19
Source File: AggregatedMetricsResponseBody.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public AggregatedMetricsResponseBody deserialize(
	JsonParser jsonParser,
	DeserializationContext deserializationContext) throws IOException {

	return new AggregatedMetricsResponseBody(jsonParser.readValueAs(
		new TypeReference<List<AggregatedMetric>>() {
		}));
}
 
Example #20
Source File: MetricCollectionResponseBody.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public MetricCollectionResponseBody deserialize(
		JsonParser jsonParser,
		DeserializationContext deserializationContext) throws IOException {

	return new MetricCollectionResponseBody(jsonParser.readValueAs(
		new TypeReference<List<Metric>>() {
		}));
}
 
Example #21
Source File: JobPlanInfo.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public RawJson deserialize(
		JsonParser jsonParser,
		DeserializationContext deserializationContext) throws IOException {
	final JsonNode rootNode = jsonParser.readValueAsTree();
	return new RawJson(rootNode.toString());
}
 
Example #22
Source File: TriggerId.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerId deserialize(
		final JsonParser p,
		final DeserializationContext ctxt) throws IOException {
	return TriggerId.fromHexString(p.getValueAsString());
}
 
Example #23
Source File: TriggerId.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public TriggerId deserialize(
		final JsonParser p,
		final DeserializationContext ctxt) throws IOException {
	return TriggerId.fromHexString(p.getValueAsString());
}
 
Example #24
Source File: CheckpointConfigInfo.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public ProcessingMode deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
	throws IOException {
	return ProcessingMode.valueOf(jsonParser.getValueAsString().toUpperCase());
}
 
Example #25
Source File: JobIDDeserializer.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public JobID deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
	return JobID.fromHexString(p.getValueAsString());
}
 
Example #26
Source File: ResourceIDDeserializer.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceID deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
	return new ResourceID(p.getValueAsString());
}
 
Example #27
Source File: RawJsonDeserializer.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
	final JsonNode jsonNode = ctxt.readValue(p, JsonNode.class);

	return jsonNode.toString();
}
 
Example #28
Source File: JobResultDeserializer.java    From flink with Apache License 2.0 4 votes vote down vote up
@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);
	}
}
 
Example #29
Source File: JobVertexIDDeserializer.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public JobVertexID deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
	return JobVertexID.fromHexString(p.getValueAsString());
}
 
Example #30
Source File: JobVertexIDKeyDeserializer.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException {
	return JobVertexID.fromHexString(key);
}