From 04b6b9a87bf024e82aa50328b4994aea4268d98e Mon Sep 17 00:00:00 2001 From: Viraj Jasani Date: Mon, 20 Dec 2021 12:31:34 +0530 Subject: [PATCH] HADOOP-16908. Prune Jackson 1 from the codebase and restrict it's usage for future (#3789) Signed-off-by: Akira Ajisaka --- hadoop-common-project/hadoop-common/pom.xml | 18 +++++ .../hadoop/metrics2/MetricsJsonBuilder.java | 5 +- .../TestRouterClientRejectOverload.java | 3 +- .../fsdataset/impl/ProvidedVolumeImpl.java | 14 ++-- hadoop-project/pom.xml | 16 +++++ hadoop-tools/hadoop-azure/pom.xml | 12 ---- .../services/ListResultEntrySchema.java | 4 +- .../contracts/services/ListResultSchema.java | 4 +- .../azurebfs/oauth2/AzureADAuthenticator.java | 9 +-- .../azurebfs/services/AbfsHttpOperation.java | 10 +-- .../contract/ListResultSchemaTest.java | 2 +- .../tools/dynamometer/DynoInfraUtils.java | 11 +-- hadoop-tools/hadoop-resourceestimator/pom.xml | 18 +++++ .../sls/synthetic/SynthTraceJobProducer.java | 45 +++++++------ .../yarn/sls/TestSynthJobGeneration.java | 23 ++++--- .../pom.xml | 18 +++++ .../hadoop-yarn/hadoop-yarn-common/pom.xml | 18 +++++ .../yarn/util/DockerClientConfigHandler.java | 21 +++--- .../pom.xml | 18 +++++ .../hadoop-yarn-server-nodemanager/pom.xml | 18 +++++ .../NetworkTagMappingJsonManager.java | 8 ++- .../linux/runtime/RuncContainerRuntime.java | 9 +-- .../runc/ImageTagToManifestPlugin.java | 3 +- .../runc/RuncContainerExecutorConfig.java | 67 ++++++++++--------- .../runtime/TestDockerContainerRuntime.java | 1 - .../runtime/TestImageTagToManifestPlugin.java | 3 +- .../runtime/TestRuncContainerRuntime.java | 7 +- .../pom.xml | 18 +++++ .../resource/ResourceProfilesManagerImpl.java | 3 +- .../documentstore/DocumentStoreTestUtils.java | 3 +- .../documentstore/JsonUtils.java | 13 ++-- pom.xml | 8 +++ 32 files changed, 290 insertions(+), 140 deletions(-) diff --git a/hadoop-common-project/hadoop-common/pom.xml b/hadoop-common-project/hadoop-common/pom.xml index a75ab5ecc45..84da42a3204 100644 --- a/hadoop-common-project/hadoop-common/pom.xml +++ b/hadoop-common-project/hadoop-common/pom.xml @@ -147,6 +147,24 @@ com.sun.jersey jersey-json compile + + + org.codehaus.jackson + jackson-core-asl + + + org.codehaus.jackson + jackson-mapper-asl + + + org.codehaus.jackson + jackson-jaxrs + + + org.codehaus.jackson + jackson-xc + + com.sun.jersey diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/MetricsJsonBuilder.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/MetricsJsonBuilder.java index 1d62c0a29fc..3a9be128031 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/MetricsJsonBuilder.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/MetricsJsonBuilder.java @@ -21,8 +21,9 @@ package org.apache.hadoop.metrics2; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.ObjectWriter; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterClientRejectOverload.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterClientRejectOverload.java index cc7f5a61a22..71ec747af4c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterClientRejectOverload.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterClientRejectOverload.java @@ -50,7 +50,8 @@ import org.apache.hadoop.hdfs.server.namenode.NameNode; import org.apache.hadoop.ipc.RemoteException; import org.apache.hadoop.ipc.StandbyException; import org.apache.hadoop.test.GenericTestUtils; -import org.codehaus.jackson.map.ObjectMapper; + +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.After; import org.junit.Rule; import org.junit.Test; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/ProvidedVolumeImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/ProvidedVolumeImpl.java index 7c6562f58d1..eae119712f7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/ProvidedVolumeImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/ProvidedVolumeImpl.java @@ -32,6 +32,10 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.ReentrantReadWriteLock; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; + import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; @@ -60,10 +64,6 @@ import org.apache.hadoop.util.DiskChecker.DiskErrorException; import org.apache.hadoop.util.ReflectionUtils; import org.apache.hadoop.util.Time; import org.apache.hadoop.util.Timer; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.ObjectReader; -import org.codehaus.jackson.map.ObjectWriter; import org.apache.hadoop.classification.VisibleForTesting; @@ -371,14 +371,11 @@ class ProvidedVolumeImpl extends FsVolumeImpl { private static final ObjectWriter WRITER = new ObjectMapper().writerWithDefaultPrettyPrinter(); - private static final ObjectReader READER = - new ObjectMapper().reader(ProvidedBlockIteratorState.class); private static class ProvidedBlockIteratorState { ProvidedBlockIteratorState() { iterStartMs = Time.now(); lastSavedMs = iterStartMs; - atEnd = false; lastBlockId = -1L; } @@ -390,9 +387,6 @@ class ProvidedVolumeImpl extends FsVolumeImpl { @JsonProperty private long iterStartMs; - @JsonProperty - private boolean atEnd; - // The id of the last block read when the state of the iterator is saved. // This implementation assumes that provided blocks are returned // in sorted order of the block ids. diff --git a/hadoop-project/pom.xml b/hadoop-project/pom.xml index cc45975a3f0..681143c336e 100644 --- a/hadoop-project/pom.xml +++ b/hadoop-project/pom.xml @@ -870,6 +870,22 @@ stax stax-api + + org.codehaus.jackson + jackson-core-asl + + + org.codehaus.jackson + jackson-mapper-asl + + + org.codehaus.jackson + jackson-jaxrs + + + org.codehaus.jackson + jackson-xc + diff --git a/hadoop-tools/hadoop-azure/pom.xml b/hadoop-tools/hadoop-azure/pom.xml index 1896e15d270..a9f58e39c6a 100644 --- a/hadoop-tools/hadoop-azure/pom.xml +++ b/hadoop-tools/hadoop-azure/pom.xml @@ -178,18 +178,6 @@ compile - - org.codehaus.jackson - jackson-mapper-asl - compile - - - - org.codehaus.jackson - jackson-core-asl - compile - - org.wildfly.openssl wildfly-openssl diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/contracts/services/ListResultEntrySchema.java b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/contracts/services/ListResultEntrySchema.java index cdf3decdc98..a9883dd2ce5 100644 --- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/contracts/services/ListResultEntrySchema.java +++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/contracts/services/ListResultEntrySchema.java @@ -18,8 +18,8 @@ package org.apache.hadoop.fs.azurebfs.contracts.services; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.hadoop.classification.InterfaceStability; diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/contracts/services/ListResultSchema.java b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/contracts/services/ListResultSchema.java index e3519fb429b..dc7da04b5bd 100644 --- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/contracts/services/ListResultSchema.java +++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/contracts/services/ListResultSchema.java @@ -20,8 +20,8 @@ package org.apache.hadoop.fs.azurebfs.contracts.services; import java.util.List; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.hadoop.classification.InterfaceStability; diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/oauth2/AzureADAuthenticator.java b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/oauth2/AzureADAuthenticator.java index aad805fe999..dd4ec7c2009 100644 --- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/oauth2/AzureADAuthenticator.java +++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/oauth2/AzureADAuthenticator.java @@ -30,9 +30,10 @@ import java.util.Hashtable; import java.util.Map; import org.apache.hadoop.util.Preconditions; -import org.codehaus.jackson.JsonFactory; -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonToken; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -451,7 +452,7 @@ public final class AzureADAuthenticator { long expiresOnInSecs = -1; JsonFactory jf = new JsonFactory(); - JsonParser jp = jf.createJsonParser(httpResponseStream); + JsonParser jp = jf.createParser(httpResponseStream); String fieldName, fieldValue; jp.nextToken(); while (jp.hasCurrentToken()) { diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsHttpOperation.java b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsHttpOperation.java index 6e13d4cec67..413bf368689 100644 --- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsHttpOperation.java +++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsHttpOperation.java @@ -30,11 +30,11 @@ import javax.net.ssl.SSLSocketFactory; import org.apache.hadoop.fs.azurebfs.utils.UriUtils; import org.apache.hadoop.security.ssl.DelegatingSSLSocketFactory; -import org.codehaus.jackson.JsonFactory; -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonToken; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -467,7 +467,7 @@ public class AbfsHttpOperation implements AbfsPerfLoggable { return; } JsonFactory jf = new JsonFactory(); - try (JsonParser jp = jf.createJsonParser(stream)) { + try (JsonParser jp = jf.createParser(stream)) { String fieldName, fieldValue; jp.nextToken(); // START_OBJECT - { jp.nextToken(); // FIELD_NAME - "error": diff --git a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/contract/ListResultSchemaTest.java b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/contract/ListResultSchemaTest.java index 8a33ea5de06..3f6a4872c5d 100644 --- a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/contract/ListResultSchemaTest.java +++ b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/contract/ListResultSchemaTest.java @@ -20,7 +20,7 @@ package org.apache.hadoop.fs.azurebfs.contract; import java.io.IOException; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Test; import org.apache.hadoop.fs.azurebfs.contracts.services.ListResultEntrySchema; diff --git a/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-infra/src/main/java/org/apache/hadoop/tools/dynamometer/DynoInfraUtils.java b/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-infra/src/main/java/org/apache/hadoop/tools/dynamometer/DynoInfraUtils.java index ee0810d6439..f6c8a6ac4d5 100644 --- a/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-infra/src/main/java/org/apache/hadoop/tools/dynamometer/DynoInfraUtils.java +++ b/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-infra/src/main/java/org/apache/hadoop/tools/dynamometer/DynoInfraUtils.java @@ -54,9 +54,10 @@ import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.util.Time; import org.apache.hadoop.yarn.YarnUncaughtExceptionHandler; import org.apache.hadoop.yarn.api.ApplicationConstants.Environment; -import org.codehaus.jackson.JsonFactory; -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.JsonToken; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; import org.slf4j.Logger; @@ -484,7 +485,7 @@ public final class DynoInfraUtils { final Set dataNodesToReport = new HashSet<>(); JsonFactory fac = new JsonFactory(); - JsonParser parser = fac.createJsonParser(IOUtils + JsonParser parser = fac.createParser(IOUtils .toInputStream(liveNodeJsonString, StandardCharsets.UTF_8.name())); int objectDepth = 0; @@ -554,7 +555,7 @@ public final class DynoInfraUtils { } InputStream in = conn.getInputStream(); JsonFactory fac = new JsonFactory(); - JsonParser parser = fac.createJsonParser(in); + JsonParser parser = fac.createParser(in); if (parser.nextToken() != JsonToken.START_OBJECT || parser.nextToken() != JsonToken.FIELD_NAME || !parser.getCurrentName().equals("beans") diff --git a/hadoop-tools/hadoop-resourceestimator/pom.xml b/hadoop-tools/hadoop-resourceestimator/pom.xml index 961aa2933e3..1ef264ba212 100644 --- a/hadoop-tools/hadoop-resourceestimator/pom.xml +++ b/hadoop-tools/hadoop-resourceestimator/pom.xml @@ -81,6 +81,24 @@ com.sun.jersey jersey-json + + + org.codehaus.jackson + jackson-core-asl + + + org.codehaus.jackson + jackson-mapper-asl + + + org.codehaus.jackson + jackson-jaxrs + + + org.codehaus.jackson + jackson-xc + + junit diff --git a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/synthetic/SynthTraceJobProducer.java b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/synthetic/SynthTraceJobProducer.java index 7a3e22bd4cb..3527d6b7668 100644 --- a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/synthetic/SynthTraceJobProducer.java +++ b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/synthetic/SynthTraceJobProducer.java @@ -17,6 +17,13 @@ */ package org.apache.hadoop.yarn.sls.synthetic; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonFactoryBuilder; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.commons.math3.distribution.AbstractRealDistribution; @@ -30,18 +37,13 @@ import org.apache.hadoop.tools.rumen.JobStoryProducer; import org.apache.hadoop.yarn.api.records.ExecutionType; import org.apache.hadoop.yarn.exceptions.YarnRuntimeException; import org.apache.hadoop.yarn.sls.appmaster.MRAMSimulator; -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.JsonMappingException; -import org.codehaus.jackson.map.ObjectMapper; import javax.xml.bind.annotation.XmlRootElement; import java.io.IOException; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; -import static org.codehaus.jackson.JsonParser.Feature.INTERN_FIELD_NAMES; -import static org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES; +import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; /** * This is a JobStoryProducer that operates from distribution of different @@ -84,15 +86,16 @@ public class SynthTraceJobProducer implements JobStoryProducer { this.conf = conf; this.rand = new JDKRandomGenerator(); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(INTERN_FIELD_NAMES, true); + JsonFactoryBuilder jsonFactoryBuilder = new JsonFactoryBuilder(); + jsonFactoryBuilder.configure(JsonFactory.Feature.INTERN_FIELD_NAMES, true); + ObjectMapper mapper = new ObjectMapper(jsonFactoryBuilder.build()); mapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false); FileSystem ifs = path.getFileSystem(conf); FSDataInputStream fileIn = ifs.open(path); // Initialize the random generator and the seed - this.trace = mapper.readValue(fileIn, Trace.class); + this.trace = mapper.readValue(fileIn.getWrappedStream(), Trace.class); this.seed = trace.rand_seed; this.rand.setSeed(seed); // Initialize the trace @@ -538,9 +541,9 @@ public class SynthTraceJobProducer implements JobStoryProducer { if(val!=null){ if(std==null){ // Constant - if(dist!=null || discrete!=null || weights!=null){ - throw new JsonMappingException("Instantiation of " + Sample.class - + " failed"); + if (dist != null || discrete != null || weights != null) { + throw JsonMappingException + .from((JsonParser) null, "Instantiation of " + Sample.class + " failed"); } mode = Mode.CONST; this.val = val; @@ -550,9 +553,9 @@ public class SynthTraceJobProducer implements JobStoryProducer { this.weights = null; } else { // Distribution - if(discrete!=null || weights != null){ - throw new JsonMappingException("Instantiation of " + Sample.class - + " failed"); + if (discrete != null || weights != null) { + throw JsonMappingException + .from((JsonParser) null, "Instantiation of " + Sample.class + " failed"); } mode = Mode.DIST; this.val = val; @@ -563,9 +566,9 @@ public class SynthTraceJobProducer implements JobStoryProducer { } } else { // Discrete - if(discrete==null){ - throw new JsonMappingException("Instantiation of " + Sample.class - + " failed"); + if (discrete == null) { + throw JsonMappingException + .from((JsonParser) null, "Instantiation of " + Sample.class + " failed"); } mode = Mode.DISC; this.val = 0; @@ -576,9 +579,9 @@ public class SynthTraceJobProducer implements JobStoryProducer { weights = new ArrayList<>(Collections.nCopies( discrete.size(), 1.0)); } - if(weights.size() != discrete.size()){ - throw new JsonMappingException("Instantiation of " + Sample.class - + " failed"); + if (weights.size() != discrete.size()) { + throw JsonMappingException + .from((JsonParser) null, "Instantiation of " + Sample.class + " failed"); } this.weights = weights; } diff --git a/hadoop-tools/hadoop-sls/src/test/java/org/apache/hadoop/yarn/sls/TestSynthJobGeneration.java b/hadoop-tools/hadoop-sls/src/test/java/org/apache/hadoop/yarn/sls/TestSynthJobGeneration.java index 0792eece51e..14e74751577 100644 --- a/hadoop-tools/hadoop-sls/src/test/java/org/apache/hadoop/yarn/sls/TestSynthJobGeneration.java +++ b/hadoop-tools/hadoop-sls/src/test/java/org/apache/hadoop/yarn/sls/TestSynthJobGeneration.java @@ -19,11 +19,14 @@ package org.apache.hadoop.yarn.sls; import org.apache.commons.math3.random.JDKRandomGenerator; import org.apache.hadoop.yarn.api.records.ExecutionType; -import org.codehaus.jackson.map.JsonMappingException; -import org.codehaus.jackson.map.ObjectMapper; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.yarn.sls.synthetic.SynthJob; import org.apache.hadoop.yarn.sls.synthetic.SynthTraceJobProducer; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonFactoryBuilder; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Assert; import org.junit.Test; import org.slf4j.Logger; @@ -32,12 +35,10 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.Arrays; +import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.codehaus.jackson.JsonParser.Feature.INTERN_FIELD_NAMES; -import static org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES; - /** * Simple test class driving the {@code SynthTraceJobProducer}, and validating * jobs produce are within expected range. @@ -56,8 +57,9 @@ public class TestSynthJobGeneration { + "{\"time\": 60, \"weight\": 2}," + "{\"time\": 90, \"weight\": 1}" + "]}"; - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(INTERN_FIELD_NAMES, true); + JsonFactoryBuilder jsonFactoryBuilder = new JsonFactoryBuilder(); + jsonFactoryBuilder.configure(JsonFactory.Feature.INTERN_FIELD_NAMES, true); + ObjectMapper mapper = new ObjectMapper(jsonFactoryBuilder.build()); mapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false); SynthTraceJobProducer.Workload wl = mapper.readValue(workloadJson, SynthTraceJobProducer.Workload.class); @@ -176,8 +178,9 @@ public class TestSynthJobGeneration { @Test public void testSample() throws IOException { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(INTERN_FIELD_NAMES, true); + JsonFactoryBuilder jsonFactoryBuilder = new JsonFactoryBuilder(); + jsonFactoryBuilder.configure(JsonFactory.Feature.INTERN_FIELD_NAMES, true); + ObjectMapper mapper = new ObjectMapper(jsonFactoryBuilder.build()); mapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false); JDKRandomGenerator rand = new JDKRandomGenerator(); @@ -235,7 +238,7 @@ public class TestSynthJobGeneration { mapper.readValue(invalidDistJson, SynthTraceJobProducer.Sample.class); Assert.fail(); } catch (JsonMappingException e) { - Assert.assertTrue(e.getMessage().startsWith("Instantiation of")); + Assert.assertTrue(e.getMessage().startsWith("Cannot construct instance of")); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-catalog/hadoop-yarn-applications-catalog-webapp/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-catalog/hadoop-yarn-applications-catalog-webapp/pom.xml index 57edd96871e..cbcd13abb95 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-catalog/hadoop-yarn-applications-catalog-webapp/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-catalog/hadoop-yarn-applications-catalog-webapp/pom.xml @@ -95,6 +95,24 @@ com.sun.jersey jersey-json ${jersey.version} + + + org.codehaus.jackson + jackson-core-asl + + + org.codehaus.jackson + jackson-mapper-asl + + + org.codehaus.jackson + jackson-jaxrs + + + org.codehaus.jackson + jackson-xc + + diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml index 489236acf39..e2146e73469 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml @@ -158,6 +158,24 @@ com.sun.jersey jersey-json + + + org.codehaus.jackson + jackson-core-asl + + + org.codehaus.jackson + jackson-mapper-asl + + + org.codehaus.jackson + jackson-jaxrs + + + org.codehaus.jackson + jackson-xc + + com.sun.jersey.contribs diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/DockerClientConfigHandler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/DockerClientConfigHandler.java index c996225c9a7..91002e40d6a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/DockerClientConfigHandler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/DockerClientConfigHandler.java @@ -28,11 +28,12 @@ import org.apache.hadoop.security.Credentials; import org.apache.hadoop.security.token.Token; import org.apache.hadoop.security.token.TokenIdentifier; import org.apache.hadoop.yarn.security.DockerCredentialTokenIdentifier; -import org.codehaus.jackson.JsonFactory; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.JsonParser; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.node.ObjectNode; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; import org.slf4j.LoggerFactory; import java.io.File; @@ -97,13 +98,13 @@ public final class DockerClientConfigHandler { // Parse the JSON and create the Tokens/Credentials. ObjectMapper mapper = new ObjectMapper(); - JsonFactory factory = mapper.getJsonFactory(); - JsonParser parser = factory.createJsonParser(contents); + JsonFactory factory = mapper.getFactory(); + JsonParser parser = factory.createParser(contents); JsonNode rootNode = mapper.readTree(parser); Credentials credentials = new Credentials(); if (rootNode.has(CONFIG_AUTHS_KEY)) { - Iterator iter = rootNode.get(CONFIG_AUTHS_KEY).getFieldNames(); + Iterator iter = rootNode.get(CONFIG_AUTHS_KEY).fieldNames(); for (; iter.hasNext();) { String registryUrl = iter.next(); String registryCred = rootNode.get(CONFIG_AUTHS_KEY) @@ -169,14 +170,14 @@ public final class DockerClientConfigHandler { DockerCredentialTokenIdentifier ti = (DockerCredentialTokenIdentifier) tk.decodeIdentifier(); ObjectNode registryCredNode = mapper.createObjectNode(); - registryUrlNode.put(ti.getRegistryUrl(), registryCredNode); + registryUrlNode.set(ti.getRegistryUrl(), registryCredNode); registryCredNode.put(CONFIG_AUTH_KEY, new String(tk.getPassword(), Charset.forName("UTF-8"))); LOG.debug("Prepared token for write: {}", tk); } } if (foundDockerCred) { - rootNode.put(CONFIG_AUTHS_KEY, registryUrlNode); + rootNode.set(CONFIG_AUTHS_KEY, registryUrlNode); String json = mapper.writerWithDefaultPrettyPrinter() .writeValueAsString(rootNode); FileUtils.writeStringToFile( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml index 06e98fd2b7c..9c87f44a6d7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml @@ -94,6 +94,24 @@ com.sun.jersey jersey-json + + + org.codehaus.jackson + jackson-core-asl + + + org.codehaus.jackson + jackson-mapper-asl + + + org.codehaus.jackson + jackson-jaxrs + + + org.codehaus.jackson + jackson-xc + + com.sun.jersey.contribs diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml index 79bb6cfa22d..b51d51cffde 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml @@ -154,6 +154,24 @@ com.sun.jersey jersey-json + + + org.codehaus.jackson + jackson-core-asl + + + org.codehaus.jackson + jackson-mapper-asl + + + org.codehaus.jackson + jackson-jaxrs + + + org.codehaus.jackson + jackson-xc + + com.sun.jersey.contribs diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/NetworkTagMappingJsonManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/NetworkTagMappingJsonManager.java index 36cb5e3b08c..cc2ded4422b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/NetworkTagMappingJsonManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/NetworkTagMappingJsonManager.java @@ -25,15 +25,17 @@ import java.util.LinkedList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.ObjectMapper; + import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.exceptions.YarnRuntimeException; import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container; -import org.codehaus.jackson.annotate.JsonIgnore; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.ObjectMapper; /** * The NetworkTagMapping JsonManager implementation. diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/RuncContainerRuntime.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/RuncContainerRuntime.java index 78ed5a6b977..e43f7788d78 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/RuncContainerRuntime.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/RuncContainerRuntime.java @@ -62,8 +62,6 @@ import org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.Contai import org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerRuntimeContext; import org.apache.hadoop.yarn.server.nodemanager.containermanager.volume.csi.ContainerVolumePublisher; import org.apache.hadoop.yarn.server.nodemanager.executor.ContainerExecContext; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; import java.io.File; import java.io.IOException; @@ -81,6 +79,9 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + import static org.apache.hadoop.yarn.conf.YarnConfiguration.DEFAULT_NM_RUNC_IMAGE_TAG_TO_MANIFEST_PLUGIN; import static org.apache.hadoop.yarn.conf.YarnConfiguration.DEFAULT_NM_RUNC_LAYER_MOUNTS_TO_KEEP; import static org.apache.hadoop.yarn.conf.YarnConfiguration.DEFAULT_NM_REAP_RUNC_LAYER_MOUNTS_INTERVAL; @@ -642,7 +643,7 @@ public class RuncContainerRuntime extends OCIContainerRuntime { if (envNode.isMissingNode()) { return null; } - return mapper.readValue(envNode, List.class); + return mapper.readValue(envNode.traverse(), List.class); } @SuppressWarnings("unchecked") @@ -653,7 +654,7 @@ public class RuncContainerRuntime extends OCIContainerRuntime { if (entrypointNode.isMissingNode()) { return null; } - return mapper.readValue(entrypointNode, List.class); + return mapper.readValue(entrypointNode.traverse(), List.class); } private RuncContainerExecutorConfig createRuncContainerExecutorConfig( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/runc/ImageTagToManifestPlugin.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/runc/ImageTagToManifestPlugin.java index 629785dfcd7..fbec3ee6f5e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/runc/ImageTagToManifestPlugin.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/runc/ImageTagToManifestPlugin.java @@ -29,7 +29,6 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.service.AbstractService; import org.apache.hadoop.util.concurrent.HadoopExecutors; -import org.codehaus.jackson.map.ObjectMapper; import java.io.BufferedReader; import java.io.File; @@ -45,6 +44,8 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; +import com.fasterxml.jackson.databind.ObjectMapper; + import static org.apache.hadoop.yarn.conf.YarnConfiguration.DEFAULT_NM_RUNC_CACHE_REFRESH_INTERVAL; import static org.apache.hadoop.yarn.conf.YarnConfiguration.DEFAULT_NM_RUNC_IMAGE_TOPLEVEL_DIR; import static org.apache.hadoop.yarn.conf.YarnConfiguration.DEFAULT_NUM_MANIFESTS_TO_CACHE; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/runc/RuncContainerExecutorConfig.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/runc/RuncContainerExecutorConfig.java index 88a01a22e13..3333b820c89 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/runc/RuncContainerExecutorConfig.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/runc/RuncContainerExecutorConfig.java @@ -20,12 +20,13 @@ package org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.runc; import org.apache.hadoop.classification.InterfaceStability; -import org.codehaus.jackson.annotate.JsonRawValue; -import org.codehaus.jackson.map.annotate.JsonSerialize; import java.util.List; import java.util.Map; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonRawValue; + /** * This class is used by the * {@link org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.RuncContainerRuntime} @@ -35,7 +36,7 @@ import java.util.Map; * a JSON object named ociRuntimeConfig that mirrors the * OCI runtime specification. */ -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +@JsonInclude(JsonInclude.Include.NON_DEFAULT) @InterfaceStability.Unstable public class RuncContainerExecutorConfig { final private String version; @@ -164,7 +165,7 @@ public class RuncContainerExecutorConfig { /** * This class is a Java representation of an OCI image layer. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) @InterfaceStability.Unstable public static class OCILayer { final private String mediaType; @@ -192,7 +193,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the OCI Runtime Specification. */ @InterfaceStability.Unstable - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class OCIRuntimeConfig { final private OCIRootConfig root; final private List mounts; @@ -254,7 +255,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the oci root config section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class OCIRootConfig { public String getPath() { return path; @@ -281,7 +282,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the oci mount section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class OCIMount { final private String destination; final private String type; @@ -329,7 +330,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the oci process section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class OCIProcessConfig { final private boolean terminal; final private ConsoleSize consoleSize; @@ -422,7 +423,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the console size section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class ConsoleSize { public int getHeight() { return height; @@ -450,7 +451,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the rlimits section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class RLimits { public String getType() { return type; @@ -484,7 +485,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the capabilities section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class Capabilities { final private List effective; final private List bounding; @@ -554,7 +555,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the oci hooks section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class OCIHooksConfig { final private List prestart; final private List poststart; @@ -587,7 +588,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the hook type section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class HookType { final private String path; final private List args; @@ -650,7 +651,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the oci linux config section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class OCILinuxConfig { final private List namespaces; final private List uidMappings; @@ -768,7 +769,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the idmapping section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class IDMapping { final private int containerID; final private int hostID; @@ -802,7 +803,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the device section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class Device { final private String type; final private String path; @@ -861,7 +862,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the resources section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class Resources { final private List device; final private Memory memory; @@ -927,7 +928,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the device section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class Device { final private boolean allow; final private String type; @@ -973,7 +974,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the memory section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class Memory { final private long limit; final private long reservation; @@ -1032,7 +1033,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the cpu section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class CPU { final private long quota; final private long period; @@ -1092,7 +1093,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the blockio section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class BlockIO { final private int weight; final private int leafWeight; @@ -1153,7 +1154,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the weight device section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class WeightDevice { final private long major; final private long minor; @@ -1193,7 +1194,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the throttle device section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class ThrottleDevice { final private long major; final private long minor; @@ -1227,7 +1228,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the huge page limits section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class HugePageLimits { final private String pageSize; final private long limit; @@ -1254,7 +1255,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the network section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class Network { final private int classID; final private List priorities; @@ -1280,7 +1281,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the network priority section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class NetworkPriority { final private String name; final private int priority; @@ -1308,7 +1309,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the pid section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class PID { final private long limit; @@ -1329,7 +1330,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the rdma section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class RDMA { final private int hcaHandles; final private int hcaObjects; @@ -1357,7 +1358,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the intelrdt section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class IntelRdt { final private String closID; final private String l3CacheSchema; @@ -1391,7 +1392,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the sysctl section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class Sysctl { // for kernel params } @@ -1400,7 +1401,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the seccomp section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class Seccomp { final private String defaultAction; final private List architectures; @@ -1433,7 +1434,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the syscall section * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class Syscall { final private List names; final private String action; @@ -1466,7 +1467,7 @@ public class RuncContainerExecutorConfig { * This class is a Java representation of the seccomp arguments * of the OCI Runtime Specification. */ - @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) + @JsonInclude(JsonInclude.Include.NON_DEFAULT) public static class SeccompArg { final private int index; final private long value; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/TestDockerContainerRuntime.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/TestDockerContainerRuntime.java index bb1abf51df0..af1f7571264 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/TestDockerContainerRuntime.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/TestDockerContainerRuntime.java @@ -57,7 +57,6 @@ import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.Reso import org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerExecutionException; import org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerRuntimeConstants; import org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerRuntimeContext; -import org.codehaus.jackson.map.ObjectMapper; import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/TestImageTagToManifestPlugin.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/TestImageTagToManifestPlugin.java index 73bfa026f14..3c2a951597e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/TestImageTagToManifestPlugin.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/TestImageTagToManifestPlugin.java @@ -24,7 +24,8 @@ import org.apache.commons.io.FileUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.runc.ImageManifest; import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.runtime.runc.ImageTagToManifestPlugin; -import org.codehaus.jackson.map.ObjectMapper; + +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/TestRuncContainerRuntime.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/TestRuncContainerRuntime.java index 1e06d03dda4..8a541bbe1ae 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/TestRuncContainerRuntime.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/runtime/TestRuncContainerRuntime.java @@ -58,8 +58,9 @@ import org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.Contai import org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerRuntimeConstants; import org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerRuntimeContext; import org.apache.hadoop.yarn.server.nodemanager.LocalDirsHandlerService; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -501,7 +502,7 @@ public class TestRuncContainerRuntime { JsonNode configNode = mapper.readTree(configFile); RuncContainerExecutorConfig runcContainerExecutorConfig = - mapper.readValue(configNode, RuncContainerExecutorConfig.class); + mapper.readValue(configNode.traverse(), RuncContainerExecutorConfig.class); configSize = configNode.size(); OCIRuntimeConfig ociRuntimeConfig = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml index f17ef707ef4..1a0f4c00f77 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml @@ -109,6 +109,24 @@ com.sun.jersey jersey-json + + + org.codehaus.jackson + jackson-core-asl + + + org.codehaus.jackson + jackson-mapper-asl + + + org.codehaus.jackson + jackson-jaxrs + + + org.codehaus.jackson + jackson-xc + + com.sun.jersey.contribs diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/resource/ResourceProfilesManagerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/resource/ResourceProfilesManagerImpl.java index 1f101ee3860..24cb34327b7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/resource/ResourceProfilesManagerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/resource/ResourceProfilesManagerImpl.java @@ -19,6 +19,8 @@ package org.apache.hadoop.yarn.server.resourcemanager.resource; import org.apache.hadoop.classification.VisibleForTesting; + +import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.hadoop.conf.Configuration; @@ -29,7 +31,6 @@ import org.apache.hadoop.yarn.exceptions.YARNFeatureNotEnabledException; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.util.resource.ResourceUtils; import org.apache.hadoop.yarn.util.resource.Resources; -import org.codehaus.jackson.map.ObjectMapper; import java.io.File; import java.io.IOException; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/test/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/DocumentStoreTestUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/test/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/DocumentStoreTestUtils.java index cf57085023f..5d442152fe9 100755 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/test/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/DocumentStoreTestUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/test/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/DocumentStoreTestUtils.java @@ -23,11 +23,12 @@ import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity; import org.apache.hadoop.yarn.server.timelineservice.documentstore.collection.document.entity.TimelineEntityDocument; import org.apache.hadoop.yarn.server.timelineservice.documentstore.collection.document.flowactivity.FlowActivityDocument; import org.apache.hadoop.yarn.server.timelineservice.documentstore.collection.document.flowrun.FlowRunDocument; -import org.codehaus.jackson.type.TypeReference; import java.io.IOException; import java.util.List; +import com.fasterxml.jackson.core.type.TypeReference; + /** * This is util class for baking sample TimelineEntities data for test. */ diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/test/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/JsonUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/test/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/JsonUtils.java index c1da4f6ce43..a644bc1d191 100755 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/test/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/JsonUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/test/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/JsonUtils.java @@ -18,12 +18,12 @@ package org.apache.hadoop.yarn.server.timelineservice.documentstore; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.type.TypeReference; - import java.io.IOException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + /** * A simple util class for Json SerDe. */ @@ -34,8 +34,7 @@ public final class JsonUtils { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); static { - OBJECT_MAPPER.configure( - DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); } /** @@ -48,7 +47,7 @@ public final class JsonUtils { * @throws IOException if Json String is not valid or error * while deserialization */ - public static T fromJson(final String jsonStr, final TypeReference type) + public static T fromJson(final String jsonStr, final TypeReference type) throws IOException { return OBJECT_MAPPER.readValue(jsonStr, type); } diff --git a/pom.xml b/pom.xml index 09f1ccb6d24..6e295b83833 100644 --- a/pom.xml +++ b/pom.xml @@ -273,6 +273,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/x static org.apache.hadoop.thirdparty.com.google.common.base.Preconditions.** + + true + Use Fasterxml Jackson 2 dependency in place of org.codehaus Jackson 1 + + org.codehaus.jackson.** + static org.codehaus.jackson.** + +