[
https://issues.apache.org/jira/browse/FLINK-8233?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16298732#comment-16298732
]
ASF GitHub Bot commented on FLINK-8233:
---------------------------------------
Github user GJL commented on a diff in the pull request:
https://github.com/apache/flink/pull/5194#discussion_r158078273
--- Diff:
flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/json/JobExecutionResultDeserializer.java
---
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest.messages.json;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.jobmaster.JobExecutionResult;
+import org.apache.flink.util.SerializedThrowable;
+import org.apache.flink.util.SerializedValue;
+
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser;
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken;
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.type.TypeReference;
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationContext;
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType;
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.deser.std.StdDeserializer;
+import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.type.TypeFactory;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * JSON deserializer for {@link JobExecutionResult}.
+ *
+ * @see JobExecutionResultSerializer
+ */
+public class JobExecutionResultDeserializer extends
StdDeserializer<JobExecutionResult> {
+
+ private static final long serialVersionUID = 1L;
+
+ private final JobIDDeserializer jobIdDeserializer = new
JobIDDeserializer();
+
+ private final SerializedThrowableDeserializer
serializedThrowableDeserializer =
+ new SerializedThrowableDeserializer();
+
+ private final SerializedValueDeserializer serializedValueDeserializer;
+
+ public JobExecutionResultDeserializer() {
+ super(JobExecutionResult.class);
+ final JavaType objectSerializedValueType =
TypeFactory.defaultInstance()
+ .constructType(new
TypeReference<SerializedValue<Object>>() {
+ });
+ serializedValueDeserializer = new
SerializedValueDeserializer(objectSerializedValueType);
+ }
+
+ @Override
+ public JobExecutionResult deserialize(final JsonParser p, final
DeserializationContext ctxt) throws IOException {
+ JobID jobId = null;
+ long netRuntime = -1;
+ SerializedThrowable serializedThrowable = null;
+ Map<String, SerializedValue<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
JobExecutionResultSerializer.FIELD_NAME_JOB_ID:
+ assertNextToken(p,
JsonToken.VALUE_STRING);
+ jobId =
jobIdDeserializer.deserialize(p, ctxt);
+ break;
+ case
JobExecutionResultSerializer.FIELD_NAME_NET_RUNTIME:
+ assertNextToken(p,
JsonToken.VALUE_NUMBER_INT);
+ netRuntime = p.getLongValue();
+ break;
+ case
JobExecutionResultSerializer.FIELD_NAME_ACCUMULATOR_RESULTS:
+ assertNextToken(p,
JsonToken.START_OBJECT);
+ accumulatorResults =
parseAccumulatorResults(p, ctxt);
--- End diff --
Actually now I would prefer to register the
`SerializedThrowableDeserializer` as a Jackson module in the `ObjectMapper`.
This is ugly.
> Expose JobExecutionResult via HTTP
> ----------------------------------
>
> Key: FLINK-8233
> URL: https://issues.apache.org/jira/browse/FLINK-8233
> Project: Flink
> Issue Type: Sub-task
> Components: REST
> Affects Versions: 1.5.0
> Reporter: Till Rohrmann
> Assignee: Gary Yao
> Priority: Blocker
> Labels: flip-6
> Fix For: 1.5.0
>
>
> Expose {{JobExecutionResult}} from a finished Flink job via HTTP:
> * Add a new AbstractRestHandler that returns the information in
> {{JobExecutionResult}}.
> * Register new handler in {{WebMonitorEndpoint}}.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)