diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/pom.xml index ff585f944c..fea9b92c9d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/pom.xml @@ -118,15 +118,9 @@ - org.codehaus.jackson - jackson-core-asl + com.fasterxml.jackson.core + jackson-databind - - - org.codehaus.jackson - jackson-mapper-asl - - com.fasterxml.jackson.core jackson-annotations diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/ApplicationReportSerDeser.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/ApplicationReportSerDeser.java index 2607c084be..ffaf27f129 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/ApplicationReportSerDeser.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/ApplicationReportSerDeser.java @@ -18,11 +18,7 @@ package org.apache.hadoop.yarn.service.utils; -import org.codehaus.jackson.JsonGenerationException; -import org.codehaus.jackson.JsonParseException; -import org.codehaus.jackson.map.JsonMappingException; - -import java.io.IOException; +import com.fasterxml.jackson.core.JsonProcessingException; /** * Persistence of {@link SerializedApplicationReport} @@ -43,14 +39,12 @@ public ApplicationReportSerDeser() { * object instance * @param instance object to convert * @return a JSON string description - * @throws JsonParseException parse problems - * @throws JsonMappingException O/J mapping problems + * @throws JsonProcessingException parse problems */ public static String toString(SerializedApplicationReport instance) - throws IOException, JsonGenerationException, JsonMappingException { + throws JsonProcessingException { synchronized (staticinstance) { return staticinstance.toJson(instance); } } - } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/JsonSerDeser.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/JsonSerDeser.java index 2c27ea710e..00b8e0cdbc 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/JsonSerDeser.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/JsonSerDeser.java @@ -18,19 +18,19 @@ package org.apache.hadoop.yarn.service.utils; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.SerializationFeature; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IOUtils; -import org.codehaus.jackson.JsonGenerationException; -import org.codehaus.jackson.JsonParseException; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.JsonMappingException; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.PropertyNamingStrategy; -import org.codehaus.jackson.map.SerializationConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,6 +41,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; /** * Support for marshalling objects to and from JSON. @@ -51,7 +52,6 @@ public class JsonSerDeser { private static final Logger log = LoggerFactory.getLogger(JsonSerDeser.class); - private static final String UTF_8 = "UTF-8"; private final Class classType; private final ObjectMapper mapper; @@ -64,9 +64,8 @@ public class JsonSerDeser { public JsonSerDeser(Class classType) { this.classType = classType; this.mapper = new ObjectMapper(); - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); - mapper.configure(SerializationConfig.Feature.WRITE_NULL_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); } public JsonSerDeser(Class classType, PropertyNamingStrategy namingStrategy) { @@ -164,7 +163,7 @@ public T fromInstance(T instance) throws IOException { * @throws IOException parse problems */ public T fromBytes(byte[] b) throws IOException { - String json = new String(b, 0, b.length, UTF_8); + String json = new String(b, 0, b.length, StandardCharsets.UTF_8); return fromJson(json); } @@ -226,7 +225,7 @@ private void writeJsonAsBytes(T instance, OutputStream dataOutputStream) throws IOException { try { String json = toJson(instance); - byte[] b = json.getBytes(UTF_8); + byte[] b = json.getBytes(StandardCharsets.UTF_8); dataOutputStream.write(b); dataOutputStream.flush(); dataOutputStream.close(); @@ -239,13 +238,10 @@ private void writeJsonAsBytes(T instance, * Convert an object to a JSON string * @param instance instance to convert * @return a JSON string description - * @throws JsonParseException parse problems - * @throws JsonMappingException O/J mapping problems + * @throws JsonProcessingException parse problems */ - public String toJson(T instance) throws IOException, - JsonGenerationException, - JsonMappingException { - mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true); + public String toJson(T instance) throws JsonProcessingException { + mapper.configure(SerializationFeature.INDENT_OUTPUT, true); return mapper.writeValueAsString(instance); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/PublishedConfiguration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/PublishedConfiguration.java index e3e96a6998..e7ec2d6f5e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/PublishedConfiguration.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/PublishedConfiguration.java @@ -18,12 +18,12 @@ package org.apache.hadoop.yarn.service.utils; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.yarn.service.exceptions.BadConfigException; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.SerializationConfig; -import org.codehaus.jackson.map.annotate.JsonSerialize; import java.io.IOException; import java.util.Date; @@ -38,7 +38,7 @@ * to be served up by the far end */ @JsonIgnoreProperties(ignoreUnknown = true) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(value = JsonInclude.Include.NON_NULL) public class PublishedConfiguration { public String description; @@ -155,7 +155,7 @@ public Properties asProperties() { */ public String asJson() throws IOException { ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true); + mapper.configure(SerializationFeature.INDENT_OUTPUT, true); String json = mapper.writeValueAsString(entries); return json; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/SerializedApplicationReport.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/SerializedApplicationReport.java index 140204af01..953f4c48ee 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/SerializedApplicationReport.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/SerializedApplicationReport.java @@ -18,12 +18,11 @@ package org.apache.hadoop.yarn.service.utils; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; -import org.apache.hadoop.yarn.service.utils.ApplicationReportSerDeser; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.map.annotate.JsonSerialize; import java.io.IOException; @@ -36,8 +35,7 @@ */ @JsonIgnoreProperties(ignoreUnknown = true) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) - +@JsonInclude(value = JsonInclude.Include.NON_NULL) public class SerializedApplicationReport { public String applicationId; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/ServiceApiUtil.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/ServiceApiUtil.java index c681093a30..81f84b4549 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/ServiceApiUtil.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/ServiceApiUtil.java @@ -18,6 +18,7 @@ package org.apache.hadoop.yarn.service.utils; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.collect.ArrayListMultimap; @@ -51,7 +52,6 @@ import org.apache.hadoop.yarn.service.monitor.probe.MonitorUtils; import org.apache.hadoop.yarn.service.provider.AbstractClientProvider; import org.apache.hadoop.yarn.service.provider.ProviderFactory; -import org.codehaus.jackson.map.PropertyNamingStrategy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,20 +73,20 @@ public class ServiceApiUtil { LoggerFactory.getLogger(ServiceApiUtil.class); public static JsonSerDeser jsonSerDeser = new JsonSerDeser<>(Service.class, - PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); + PropertyNamingStrategy.SNAKE_CASE); public static final JsonSerDeser CONTAINER_JSON_SERDE = new JsonSerDeser<>(Container[].class, - PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); + PropertyNamingStrategy.SNAKE_CASE); public static final JsonSerDeser COMP_CONTAINERS_JSON_SERDE = new JsonSerDeser<>( ComponentContainers[].class, - PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); + PropertyNamingStrategy.SNAKE_CASE); public static final JsonSerDeser COMP_JSON_SERDE = new JsonSerDeser<>(Component[].class, - PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); + PropertyNamingStrategy.SNAKE_CASE); private static final PatternValidator namePattern = new PatternValidator("[a-z][a-z0-9-]*"); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/ServiceTestUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/ServiceTestUtils.java index 6d236c0f64..5a522b47c3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/ServiceTestUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/test/java/org/apache/hadoop/yarn/service/ServiceTestUtils.java @@ -18,6 +18,7 @@ package org.apache.hadoop.yarn.service; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.google.common.base.Throwables; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; @@ -50,7 +51,6 @@ import org.apache.hadoop.yarn.service.utils.SliderFileSystem; import org.apache.hadoop.yarn.util.LinuxResourceCalculatorPlugin; import org.apache.hadoop.yarn.util.ProcfsBasedProcessTree; -import org.codehaus.jackson.map.PropertyNamingStrategy; import org.junit.rules.TestWatcher; import org.junit.runner.Description; import org.slf4j.Logger; @@ -98,7 +98,7 @@ public class ServiceTestUtils { public static final JsonSerDeser JSON_SER_DESER = new JsonSerDeser<>(Service.class, - PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); + PropertyNamingStrategy.SNAKE_CASE); // Example service definition // 2 components, each of which has 2 containers.