org.apache.flink.runtime.rest.util.RestMapperUtils Java Examples
The following examples show how to use
org.apache.flink.runtime.rest.util.RestMapperUtils.
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: JobDetailsTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Tests that we can marshal and unmarshal JobDetails instances. */ @Test public void testJobDetailsMarshalling() throws JsonProcessingException { final JobDetails expected = new JobDetails( new JobID(), "foobar", 1L, 10L, 9L, JobStatus.RUNNING, 8L, new int[]{1, 3, 3, 7, 4, 2, 7, 3, 3}, 42); final ObjectMapper objectMapper = RestMapperUtils.getStrictObjectMapper(); final JsonNode marshalled = objectMapper.valueToTree(expected); final JobDetails unmarshalled = objectMapper.treeToValue(marshalled, JobDetails.class); assertEquals(expected, unmarshalled); }
Example #2
Source File: RestResponseMarshallingTestBase.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that we can marshal and unmarshal the response. */ @Test public void testJsonMarshalling() throws Exception { final R expected = getTestResponseInstance(); ObjectMapper objectMapper = RestMapperUtils.getStrictObjectMapper(); final String marshalled = objectMapper.writeValueAsString(expected); final Collection<Class<?>> typeParameters = getTypeParameters(); final JavaType type; if (typeParameters.isEmpty()) { type = objectMapper.getTypeFactory().constructType(getTestResponseClass()); } else { type = objectMapper.getTypeFactory().constructParametricType( getTestResponseClass(), typeParameters.toArray(new Class<?>[typeParameters.size()])); } final R unmarshalled = objectMapper.readValue(marshalled, type); assertOriginalEqualsToUnmarshalled(expected, unmarshalled); }
Example #3
Source File: JobDetailsTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that we can marshal and unmarshal JobDetails instances. */ @Test public void testJobDetailsMarshalling() throws JsonProcessingException { final JobDetails expected = new JobDetails( new JobID(), "foobar", 1L, 10L, 9L, JobStatus.RUNNING, 8L, new int[]{1, 3, 3, 7, 4, 2, 7, 3, 3}, 42); final ObjectMapper objectMapper = RestMapperUtils.getStrictObjectMapper(); final JsonNode marshalled = objectMapper.valueToTree(expected); final JobDetails unmarshalled = objectMapper.treeToValue(marshalled, JobDetails.class); assertEquals(expected, unmarshalled); }
Example #4
Source File: JobConfigInfo.java From flink with Apache License 2.0 | 6 votes |
@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 #5
Source File: RestResponseMarshallingTestBase.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that we can marshal and unmarshal the response. */ @Test public void testJsonMarshalling() throws Exception { final R expected = getTestResponseInstance(); ObjectMapper objectMapper = RestMapperUtils.getStrictObjectMapper(); final String marshalled = objectMapper.writeValueAsString(expected); final Collection<Class<?>> typeParameters = getTypeParameters(); final JavaType type; if (typeParameters.isEmpty()) { type = objectMapper.getTypeFactory().constructType(getTestResponseClass()); } else { type = objectMapper.getTypeFactory().constructParametricType( getTestResponseClass(), typeParameters.toArray(new Class<?>[typeParameters.size()])); } final R unmarshalled = objectMapper.readValue(marshalled, type); assertOriginalEqualsToUnmarshalled(expected, unmarshalled); }
Example #6
Source File: JobDetailsTest.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that we can marshal and unmarshal JobDetails instances. */ @Test public void testJobDetailsMarshalling() throws JsonProcessingException { final JobDetails expected = new JobDetails( new JobID(), "foobar", 1L, 10L, 9L, JobStatus.RUNNING, 8L, new int[]{1, 3, 3, 7, 4, 2, 7, 3, 3}, 42); final ObjectMapper objectMapper = RestMapperUtils.getStrictObjectMapper(); final JsonNode marshalled = objectMapper.valueToTree(expected); final JobDetails unmarshalled = objectMapper.treeToValue(marshalled, JobDetails.class); assertEquals(expected, unmarshalled); }
Example #7
Source File: JobConfigInfo.java From flink with Apache License 2.0 | 6 votes |
@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 #8
Source File: JobConfigInfo.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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 #9
Source File: RestResponseMarshallingTestBase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Tests that we can marshal and unmarshal the response. */ @Test public void testJsonMarshalling() throws Exception { final R expected = getTestResponseInstance(); ObjectMapper objectMapper = RestMapperUtils.getStrictObjectMapper(); final String marshalled = objectMapper.writeValueAsString(expected); final Collection<Class<?>> typeParameters = getTypeParameters(); final JavaType type; if (typeParameters.isEmpty()) { type = objectMapper.getTypeFactory().constructType(getTestResponseClass()); } else { type = objectMapper.getTypeFactory().constructParametricType( getTestResponseClass(), typeParameters.toArray(new Class<?>[typeParameters.size()])); } final R unmarshalled = objectMapper.readValue(marshalled, type); assertOriginalEqualsToUnmarshalled(expected, unmarshalled); }
Example #10
Source File: VertexBackPressureStatusTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that the enum values are serialized correctly. * Clients, such as the Web UI, expect values to be lower case. */ @Test public void testJsonValue() throws Exception { assertEquals("\"ok\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureStatus.OK)); assertEquals("\"deprecated\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureStatus.DEPRECATED)); }
Example #11
Source File: VertexBackPressureStatusTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that the enum values are serialized correctly. * Clients, such as the Web UI, expect values to be lower case. */ @Test public void testJsonValue() throws Exception { assertEquals("\"ok\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureStatus.OK)); assertEquals("\"deprecated\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureStatus.DEPRECATED)); }
Example #12
Source File: RestRequestMarshallingTestBase.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that we can marshal and unmarshal the response. */ @Test public void testJsonMarshalling() throws Exception { final R expected = getTestRequestInstance(); ObjectMapper objectMapper = RestMapperUtils.getStrictObjectMapper(); final String marshalled = objectMapper.writeValueAsString(expected); final R unmarshalled = objectMapper.readValue(marshalled, getTestRequestClass()); assertOriginalEqualsToUnmarshalled(expected, unmarshalled); }
Example #13
Source File: VertexBackPressureLevelTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that the enum values are serialized correctly. * Clients, such as the Web UI, expect values to be lower case. */ @Test public void testJsonValue() throws Exception { assertEquals("\"ok\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureLevel.OK)); assertEquals("\"low\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureLevel.LOW)); assertEquals("\"high\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureLevel.HIGH)); }
Example #14
Source File: MetricCollectionResponseBodyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testNullValueNotSerialized() throws Exception { final String json = RestMapperUtils.getStrictObjectMapper() .writeValueAsString( new MetricCollectionResponseBody( Collections.singleton(new Metric(TEST_METRIC_NAME)))); assertThat(json, not(containsString("\"value\""))); assertThat(json, not(containsString("\"metrics\""))); }
Example #15
Source File: MetricCollectionResponseBodyTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testNullValueNotSerialized() throws Exception { final String json = RestMapperUtils.getStrictObjectMapper() .writeValueAsString( new MetricCollectionResponseBody( Collections.singleton(new Metric(TEST_METRIC_NAME)))); assertThat(json, not(containsString("\"value\""))); assertThat(json, not(containsString("\"metrics\""))); }
Example #16
Source File: VertexBackPressureStatusTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Tests that the enum values are serialized correctly. * Clients, such as the Web UI, expect values to be lower case. */ @Test public void testJsonValue() throws Exception { assertEquals("\"ok\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureStatus.OK)); assertEquals("\"deprecated\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureStatus.DEPRECATED)); }
Example #17
Source File: RestRequestMarshallingTestBase.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that we can marshal and unmarshal the response. */ @Test public void testJsonMarshalling() throws Exception { final R expected = getTestRequestInstance(); ObjectMapper objectMapper = RestMapperUtils.getStrictObjectMapper(); final String marshalled = objectMapper.writeValueAsString(expected); final R unmarshalled = objectMapper.readValue(marshalled, getTestRequestClass()); assertOriginalEqualsToUnmarshalled(expected, unmarshalled); }
Example #18
Source File: VertexBackPressureLevelTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that the enum values are serialized correctly. * Clients, such as the Web UI, expect values to be lower case. */ @Test public void testJsonValue() throws Exception { assertEquals("\"ok\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureLevel.OK)); assertEquals("\"low\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureLevel.LOW)); assertEquals("\"high\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureLevel.HIGH)); }
Example #19
Source File: MetricCollectionResponseBodyTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testNullValueNotSerialized() throws Exception { final String json = RestMapperUtils.getStrictObjectMapper() .writeValueAsString( new MetricCollectionResponseBody( Collections.singleton(new Metric(TEST_METRIC_NAME)))); assertThat(json, not(containsString("\"value\""))); assertThat(json, not(containsString("\"metrics\""))); }
Example #20
Source File: VertexBackPressureLevelTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Tests that the enum values are serialized correctly. * Clients, such as the Web UI, expect values to be lower case. */ @Test public void testJsonValue() throws Exception { assertEquals("\"ok\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureLevel.OK)); assertEquals("\"low\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureLevel.LOW)); assertEquals("\"high\"", RestMapperUtils.getStrictObjectMapper() .writeValueAsString(JobVertexBackPressureInfo.VertexBackPressureLevel.HIGH)); }
Example #21
Source File: RestRequestMarshallingTestBase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Tests that we can marshal and unmarshal the response. */ @Test public void testJsonMarshalling() throws Exception { final R expected = getTestRequestInstance(); ObjectMapper objectMapper = RestMapperUtils.getStrictObjectMapper(); final String marshalled = objectMapper.writeValueAsString(expected); final R unmarshalled = objectMapper.readValue(marshalled, getTestRequestClass()); assertOriginalEqualsToUnmarshalled(expected, unmarshalled); }
Example #22
Source File: MultipleJobsDetailsTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Tests that we can un/marshal {@link MultipleJobsDetails} objects. */ @Test public void testMultipleJobsDetailsMarshalling() throws JsonProcessingException { int[] verticesPerState = new int[ExecutionState.values().length]; for (int i = 0; i < verticesPerState.length; i++) { verticesPerState[i] = i; } final JobDetails running = new JobDetails( new JobID(), "running", 1L, -1L, 9L, JobStatus.RUNNING, 9L, verticesPerState, 9); final JobDetails finished = new JobDetails( new JobID(), "finished", 1L, 5L, 4L, JobStatus.FINISHED, 8L, verticesPerState, 4); final MultipleJobsDetails expected = new MultipleJobsDetails( Arrays.asList(running, finished)); final ObjectMapper objectMapper = RestMapperUtils.getStrictObjectMapper(); final JsonNode marshalled = objectMapper.valueToTree(expected); final MultipleJobsDetails unmarshalled = objectMapper.treeToValue(marshalled, MultipleJobsDetails.class); assertEquals(expected, unmarshalled); }
Example #23
Source File: MultipleJobsDetailsTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that we can un/marshal {@link MultipleJobsDetails} objects. */ @Test public void testMultipleJobsDetailsMarshalling() throws JsonProcessingException { int[] verticesPerState = new int[ExecutionState.values().length]; for (int i = 0; i < verticesPerState.length; i++) { verticesPerState[i] = i; } final JobDetails running = new JobDetails( new JobID(), "running", 1L, -1L, 9L, JobStatus.RUNNING, 9L, verticesPerState, 9); final JobDetails finished = new JobDetails( new JobID(), "finished", 1L, 5L, 4L, JobStatus.FINISHED, 8L, verticesPerState, 4); final MultipleJobsDetails expected = new MultipleJobsDetails( Arrays.asList(running, finished)); final ObjectMapper objectMapper = RestMapperUtils.getStrictObjectMapper(); final JsonNode marshalled = objectMapper.valueToTree(expected); final MultipleJobsDetails unmarshalled = objectMapper.treeToValue(marshalled, MultipleJobsDetails.class); assertEquals(expected, unmarshalled); }
Example #24
Source File: MultipleJobsDetailsTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that we can un/marshal {@link MultipleJobsDetails} objects. */ @Test public void testMultipleJobsDetailsMarshalling() throws JsonProcessingException { int[] verticesPerState = new int[ExecutionState.values().length]; for (int i = 0; i < verticesPerState.length; i++) { verticesPerState[i] = i; } final JobDetails running = new JobDetails( new JobID(), "running", 1L, -1L, 9L, JobStatus.RUNNING, 9L, verticesPerState, 9); final JobDetails finished = new JobDetails( new JobID(), "finished", 1L, 5L, 4L, JobStatus.FINISHED, 8L, verticesPerState, 4); final MultipleJobsDetails expected = new MultipleJobsDetails( Arrays.asList(running, finished)); final ObjectMapper objectMapper = RestMapperUtils.getStrictObjectMapper(); final JsonNode marshalled = objectMapper.valueToTree(expected); final MultipleJobsDetails unmarshalled = objectMapper.treeToValue(marshalled, MultipleJobsDetails.class); assertEquals(expected, unmarshalled); }