yuchen-ecnu commented on code in PR #25798:
URL: https://github.com/apache/flink/pull/25798#discussion_r1895897313


##########
flink-runtime/src/test/java/org/apache/flink/runtime/jobgraph/jsonplan/JsonGeneratorTest.java:
##########
@@ -151,4 +160,55 @@ private void checkVertexExists(String vertexId, JobGraph 
graph) {
         }
         fail("could not find vertex with id " + vertexId + " in JobGraph");
     }
+
+    @Test
+    public void testGenerateStreamGraphJson() throws JsonProcessingException {
+        StreamExecutionEnvironment env = new StreamExecutionEnvironment();
+        env.fromSequence(0L, 1L).disableChaining().print();
+        StreamGraph streamGraph = env.getStreamGraph();
+        Map<Integer, JobVertexID> jobVertexIdMap = new HashMap<>();
+        String streamGraphJson =
+                JsonPlanGenerator.generateStreamGraphJson(streamGraph, 
jobVertexIdMap);
+
+        ObjectMapper mapper = JacksonMapperFactory.createObjectMapper();
+        StreamGraphJsonSchema parsedStreamGraph =
+                mapper.readValue(streamGraphJson, StreamGraphJsonSchema.class);
+
+        List<String> expectedJobVertexIds = new ArrayList<>();
+        expectedJobVertexIds.add(null);
+        expectedJobVertexIds.add(null);
+        validateStreamGraph(streamGraph, parsedStreamGraph, 
expectedJobVertexIds);
+
+        jobVertexIdMap.put(1, new JobVertexID());
+        jobVertexIdMap.put(2, new JobVertexID());
+        streamGraphJson = 
JsonPlanGenerator.generateStreamGraphJson(streamGraph, jobVertexIdMap);
+
+        parsedStreamGraph = mapper.readValue(streamGraphJson, 
StreamGraphJsonSchema.class);
+        validateStreamGraph(
+                streamGraph,
+                parsedStreamGraph,
+                jobVertexIdMap.values().stream()
+                        .map(JobVertexID::toString)
+                        .collect(Collectors.toList()));
+    }
+
+    public static void validateStreamGraph(
+            StreamGraph streamGraph,
+            StreamGraphJsonSchema parsedStreamGraph,
+            List<String> expectedJobVertexIds) {
+        List<String> realJobVertexIds = new ArrayList<>();
+        parsedStreamGraph
+                .getNodes()
+                .forEach(
+                        node -> {

Review Comment:
   Okay, included missing field in the revised version.



##########
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ArchivedExecutionGraph.java:
##########
@@ -113,6 +113,10 @@ public class ArchivedExecutionGraph implements 
AccessExecutionGraph, Serializabl
 
     @Nullable private final String changelogStorageName;
 
+    @Nullable private final String streamGraphJson;

Review Comment:
   Thanks for the reminder. Removed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to