/** * returns full application id * @return full app id */ public String getGlobalAppId() { return String.format("app-%s-%s", getAppName(), getAppId()); }
/** * returns full application id * @return full app id */ public String getGlobalAppId() { return String.format("app-%s-%s", getAppName(), getAppId()); }
/** * returns full application id * @return full app id */ public String getGlobalAppId() { return String.format("app-%s-%s", getAppName(), getAppId()); }
/** * returns full application id * @return full app id */ public String getGlobalAppId() { return String.format("app-%s-%s", getAppName(), getAppId()); }
/** * returns full application id * @return full app id */ public String getGlobalAppId() { return String.format("app-%s-%s", getAppName(), getAppId()); }
/** * Returns the JSON representation of a {@link JobGraph} * @param jobGraph {@link JobGraph} * @return JSON of the graph * @throws Exception exception during creating JSON */ /* package private */ String toJson(JobGraph jobGraph) throws Exception { JobGraphJson jobGraphJson = new JobGraphJson(); // build StreamEdge JSON ApplicationConfig appConfig = jobGraph.getApplicationConfig(); jobGraphJson.applicationName = appConfig.getAppName(); jobGraphJson.applicationId = appConfig.getAppId(); jobGraphJson.sourceStreams = new HashMap<>(); jobGraphJson.sinkStreams = new HashMap<>(); jobGraphJson.intermediateStreams = new HashMap<>(); jobGraphJson.tables = new HashMap<>(); jobGraph.getInputStreams().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.sourceStreams)); jobGraph.getOutputStreams().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.sinkStreams)); jobGraph.getIntermediateStreamEdges().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.intermediateStreams)); jobGraph.getTables().forEach(t -> buildTableJson(t, jobGraphJson.tables)); jobGraphJson.jobs = jobGraph.getJobNodes().stream() .map(this::buildJobNodeJson) .collect(Collectors.toList()); ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(out, jobGraphJson); return new String(out.toByteArray()); }
/** * Returns the JSON representation of a {@link JobGraph} * @param jobGraph {@link JobGraph} * @return JSON of the graph * @throws Exception exception during creating JSON */ /* package private */ String toJson(JobGraph jobGraph) throws Exception { JobGraphJson jobGraphJson = new JobGraphJson(); // build StreamEdge JSON ApplicationConfig appConfig = jobGraph.getApplicationConfig(); jobGraphJson.applicationName = appConfig.getAppName(); jobGraphJson.applicationId = appConfig.getAppId(); jobGraphJson.sourceStreams = new HashMap<>(); jobGraphJson.sinkStreams = new HashMap<>(); jobGraphJson.intermediateStreams = new HashMap<>(); jobGraphJson.tables = new HashMap<>(); jobGraph.getInputStreams().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.sourceStreams)); jobGraph.getOutputStreams().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.sinkStreams)); jobGraph.getIntermediateStreamEdges().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.intermediateStreams)); jobGraph.getTables().forEach(t -> buildTableJson(t, jobGraphJson.tables)); jobGraphJson.jobs = jobGraph.getJobNodes().stream() .map(this::buildJobNodeJson) .collect(Collectors.toList()); ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(out, jobGraphJson); return new String(out.toByteArray()); }
/** * Returns the JSON representation of a {@link JobGraph} * @param jobGraph {@link JobGraph} * @return JSON of the graph * @throws Exception exception during creating JSON */ /* package private */ String toJson(JobGraph jobGraph) throws Exception { JobGraphJson jobGraphJson = new JobGraphJson(); // build StreamEdge JSON ApplicationConfig appConfig = jobGraph.getApplicationConfig(); jobGraphJson.applicationName = appConfig.getAppName(); jobGraphJson.applicationId = appConfig.getAppId(); jobGraphJson.sourceStreams = new HashMap<>(); jobGraphJson.sinkStreams = new HashMap<>(); jobGraphJson.intermediateStreams = new HashMap<>(); jobGraphJson.tables = new HashMap<>(); jobGraph.getInputStreams().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.sourceStreams)); jobGraph.getOutputStreams().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.sinkStreams)); jobGraph.getIntermediateStreamEdges().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.intermediateStreams)); jobGraph.getTables().forEach(t -> buildTableJson(t, jobGraphJson.tables)); jobGraphJson.jobs = jobGraph.getJobNodes().stream() .map(this::buildJobNodeJson) .collect(Collectors.toList()); ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(out, jobGraphJson); return new String(out.toByteArray()); }
/** * Returns the JSON representation of a {@link JobGraph} * @param jobGraph {@link JobGraph} * @return JSON of the graph * @throws Exception exception during creating JSON */ /* package private */ String toJson(JobGraph jobGraph) throws Exception { JobGraphJson jobGraphJson = new JobGraphJson(); // build StreamEdge JSON ApplicationConfig appConfig = jobGraph.getApplicationConfig(); jobGraphJson.applicationName = appConfig.getAppName(); jobGraphJson.applicationId = appConfig.getAppId(); jobGraphJson.sourceStreams = new HashMap<>(); jobGraphJson.sinkStreams = new HashMap<>(); jobGraphJson.intermediateStreams = new HashMap<>(); jobGraphJson.tables = new HashMap<>(); jobGraph.getInputStreams().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.sourceStreams)); jobGraph.getOutputStreams().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.sinkStreams)); jobGraph.getIntermediateStreamEdges().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.intermediateStreams)); jobGraph.getTables().forEach(t -> buildTableJson(t, jobGraphJson.tables)); jobGraphJson.jobs = jobGraph.getJobNodes().stream() .map(this::buildJobNodeJson) .collect(Collectors.toList()); ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(out, jobGraphJson); return new String(out.toByteArray()); }
/** * Returns the JSON representation of a {@link JobGraph} * @param jobGraph {@link JobGraph} * @return JSON of the graph * @throws Exception exception during creating JSON */ /* package private */ String toJson(JobGraph jobGraph) throws Exception { JobGraphJson jobGraphJson = new JobGraphJson(); // build StreamEdge JSON ApplicationConfig appConfig = jobGraph.getApplicationConfig(); jobGraphJson.applicationName = appConfig.getAppName(); jobGraphJson.applicationId = appConfig.getAppId(); jobGraphJson.sourceStreams = new HashMap<>(); jobGraphJson.sinkStreams = new HashMap<>(); jobGraphJson.intermediateStreams = new HashMap<>(); jobGraphJson.tables = new HashMap<>(); jobGraph.getInputStreams().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.sourceStreams)); jobGraph.getOutputStreams().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.sinkStreams)); jobGraph.getIntermediateStreamEdges().forEach(e -> buildStreamEdgeJson(e, jobGraphJson.intermediateStreams)); jobGraph.getTables().forEach(t -> buildTableJson(t, jobGraphJson.tables)); jobGraphJson.jobs = jobGraph.getJobNodes().stream() .map(this::buildJobNodeJson) .collect(Collectors.toList()); ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(out, jobGraphJson); return new String(out.toByteArray()); }
@Test public void testLegacyTaskApplication() throws Exception { JobGraphJsonGenerator jsonGenerator = new JobGraphJsonGenerator(); JobGraph mockJobGraph = mock(JobGraph.class); ApplicationConfig mockAppConfig = mock(ApplicationConfig.class); when(mockAppConfig.getAppName()).thenReturn("testTaskApp"); when(mockAppConfig.getAppId()).thenReturn("testTaskAppId"); when(mockJobGraph.getApplicationConfig()).thenReturn(mockAppConfig); String graphJson = jsonGenerator.toJson(mockJobGraph); ObjectMapper objectMapper = new ObjectMapper(); JobGraphJsonGenerator.JobGraphJson jsonObject = objectMapper.readValue(graphJson.getBytes(), JobGraphJsonGenerator.JobGraphJson.class); assertEquals("testTaskAppId", jsonObject.applicationId); assertEquals("testTaskApp", jsonObject.applicationName); JobGraphJsonGenerator.JobNodeJson expectedNodeJson = new JobGraphJsonGenerator.JobNodeJson(); expectedNodeJson.jobId = mockJobNode.getJobId(); expectedNodeJson.jobName = mockJobNode.getJobName(); assertEquals(0, jsonObject.jobs.size()); }
JobGraph mockJobGraph = mock(JobGraph.class); ApplicationConfig mockAppConfig = mock(ApplicationConfig.class); when(mockAppConfig.getAppName()).thenReturn("testTaskApp"); when(mockAppConfig.getAppId()).thenReturn("testTaskAppId"); when(mockJobGraph.getApplicationConfig()).thenReturn(mockAppConfig);