Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
import java.util.Properties;
import java.util.Random;

import org.apache.hadoop.util.JacksonUtil;
import org.apache.hadoop.yarn.appcatalog.model.AppEntry;
import org.apache.hadoop.yarn.appcatalog.model.AppStoreEntry;
import org.apache.hadoop.yarn.appcatalog.model.Application;
import org.apache.hadoop.yarn.appcatalog.utils.RandomWord;
import org.apache.hadoop.yarn.appcatalog.utils.WordLengthException;
import org.apache.hadoop.yarn.service.api.records.Service;
import org.apache.hadoop.yarn.util.YarnJacksonUtil;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrQuery.ORDER;
Expand Down Expand Up @@ -66,7 +66,7 @@ public class AppCatalogSolrClient {
private static final ObjectMapper OBJECT_MAPPER;

static {
OBJECT_MAPPER = JacksonUtil.createBasicObjectMapper();
OBJECT_MAPPER = YarnJacksonUtil.createBasicObjectMapper();
OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@

import java.io.IOException;


import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.JacksonUtil;
import org.apache.hadoop.yarn.appcatalog.model.AppEntry;
import org.apache.hadoop.yarn.service.api.records.Service;
import org.apache.hadoop.yarn.service.api.records.ServiceState;
import org.apache.hadoop.yarn.service.api.records.KerberosPrincipal;
import org.apache.hadoop.yarn.service.client.ApiServiceClient;
import org.apache.hadoop.yarn.util.YarnJacksonUtil;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
Expand Down Expand Up @@ -56,7 +55,7 @@ public class YarnServiceClient {
private static final ObjectMapper OBJECT_MAPPER;

static {
OBJECT_MAPPER = JacksonUtil.createBasicObjectMapper();
OBJECT_MAPPER = YarnJacksonUtil.createBasicObjectMapper();
OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.hadoop.registry.client.binding.RegistryPathUtils;
import org.apache.hadoop.registry.client.types.ServiceRecord;
import org.apache.hadoop.registry.client.types.yarn.PersistencePolicies;
import org.apache.hadoop.util.JacksonUtil;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerExitStatus;
Expand Down Expand Up @@ -64,6 +63,7 @@
import org.apache.hadoop.yarn.state.StateMachine;
import org.apache.hadoop.yarn.state.StateMachineFactory;
import org.apache.hadoop.yarn.util.BoundedAppender;
import org.apache.hadoop.yarn.util.YarnJacksonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -876,7 +876,7 @@ public void updateContainerStatus(ContainerStatus status) {
doRegistryUpdate = false;
}
}
final ObjectMapper mapper = JacksonUtil.createBasicObjectMapper();
final ObjectMapper mapper = YarnJacksonUtil.createBasicObjectMapper();
try {
Map<String, List<Map<String, String>>> ports = null;
ports = mapper.readValue(status.getExposedPorts(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.util.JacksonUtil;
import org.apache.hadoop.yarn.util.YarnJacksonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -62,7 +62,7 @@ public class JsonSerDeser<T> {
@SuppressWarnings("deprecation")
public JsonSerDeser(Class<T> classType) {
this.classType = classType;
this.mapper = JacksonUtil.createBasicObjectMapper();
this.mapper = YarnJacksonUtil.createBasicObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
Expand All @@ -77,7 +77,8 @@ public JsonSerDeser(Class<T> classType, PropertyNamingStrategy namingStrategy) {
* Convert from JSON
* @param json input
* @return the parsed JSON
* @throws IOException IO
* @throws IOException IO problems
* @throws JsonParseException if the JSON is invalid
* @throws JsonMappingException failure to map from the JSON to this class
*/
public T fromJson(String json)
Expand All @@ -95,6 +96,7 @@ public T fromJson(String json)
* @param jsonFile input file
* @return the parsed JSON
* @throws IOException IO problems
* @throws JsonParseException if the JSON is invalid
* @throws JsonMappingException failure to map from the JSON to this class
*/
public T fromFile(File jsonFile)
Expand All @@ -113,6 +115,8 @@ public T fromFile(File jsonFile)
* @param resource input file
* @return the parsed JSON
* @throws IOException IO problems
* @throws JsonParseException if the JSON is invalid

* @throws JsonMappingException failure to map from the JSON to this class
*/
public T fromResource(String resource)
Expand Down Expand Up @@ -150,7 +154,7 @@ public T fromStream(InputStream stream) throws IOException {
* This is much less efficient than any Java clone process.
* @param instance instance to duplicate
* @return a new instance
* @throws IOException problems.
* @throws IOException IO problems.
*/
public T fromInstance(T instance) throws IOException {
return fromJson(toJson(instance));
Expand Down Expand Up @@ -201,7 +205,7 @@ public void save(FileSystem fs, Path path, T instance,
* Save an instance to a file
* @param instance instance to save
* @param file file
* @throws IOException
* @throws IOException IO exception
*/
public void save(T instance, File file) throws
IOException {
Expand All @@ -210,7 +214,7 @@ public void save(T instance, File file) throws

/**
* Write the json as bytes -then close the file
* @param dataOutputStream an outout stream that will always be closed
* @param dataOutputStream an output stream that will always be closed
* @throws IOException on any failure
*/
private void writeJsonAsBytes(T instance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.JacksonUtil;
import org.apache.hadoop.yarn.service.exceptions.BadConfigException;
import org.apache.hadoop.yarn.util.YarnJacksonUtil;

import java.io.IOException;
import java.util.Date;
Expand All @@ -50,7 +50,7 @@ public class PublishedConfiguration {
private static final ObjectMapper OBJECT_MAPPER;

static {
OBJECT_MAPPER = JacksonUtil.createBasicObjectMapper();
OBJECT_MAPPER = YarnJacksonUtil.createBasicObjectMapper();
OBJECT_MAPPER.configure(SerializationFeature.INDENT_OUTPUT, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.JacksonUtil;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationId;
Expand All @@ -59,6 +58,7 @@
import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.util.YarnJacksonUtil;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonGenerator;
Expand Down Expand Up @@ -274,7 +274,7 @@ public void flush() throws IOException {
}

private ObjectMapper createObjectMapper() {
ObjectMapper mapper = JacksonUtil.createBasicObjectMapper();
ObjectMapper mapper = YarnJacksonUtil.createBasicObjectMapper();
mapper.setAnnotationIntrospector(
new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()));
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
Expand Down Expand Up @@ -365,7 +365,7 @@ public long getLastModifiedTime() {

protected void prepareForWrite() throws IOException{
this.stream = createLogFileStream(fs, logPath);
this.jsonGenerator = JacksonUtil.getSharedWriter()
this.jsonGenerator = YarnJacksonUtil.getSharedWriter()
.createGenerator((OutputStream)stream);
this.jsonGenerator.setPrettyPrinter(new MinimalPrettyPrinter("\n"));
this.lastModifiedTime = Time.monotonicNow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.hadoop.security.authentication.server.KerberosAuthenticationHandler;
import org.apache.hadoop.security.authentication.server.PseudoAuthenticationHandler;
import org.apache.hadoop.util.JacksonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hadoop.classification.VisibleForTesting;
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Evolving;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authentication.server.KerberosAuthenticationHandler;
import org.apache.hadoop.security.authentication.server.PseudoAuthenticationHandler;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticatedURL;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
Expand All @@ -51,10 +49,13 @@
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier;
import org.apache.hadoop.yarn.util.YarnJacksonUtil;
import org.apache.hadoop.yarn.webapp.YarnJacksonJaxbJsonProvider;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.hadoop.classification.VisibleForTesting;
import com.sun.jersey.api.client.Client;

@Private
Expand All @@ -63,7 +64,7 @@ public class TimelineClientImpl extends TimelineClient {

private static final Logger LOG =
LoggerFactory.getLogger(TimelineClientImpl.class);
private static final ObjectMapper MAPPER = JacksonUtil.createBasicObjectMapper();
private static final ObjectMapper MAPPER = YarnJacksonUtil.createBasicObjectMapper();
private static final String RESOURCE_URI_STR_V1 = "/ws/v1/timeline/";

private static Options opts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.apache.hadoop.security.Credentials;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
import org.apache.hadoop.util.JacksonUtil;
import org.apache.hadoop.yarn.security.DockerCredentialTokenIdentifier;

import com.fasterxml.jackson.core.JsonParser;
Expand Down Expand Up @@ -96,9 +95,8 @@ public static Credentials readCredentialsFromConfigFile(Path configFile,
}

// Parse the JSON and create the Tokens/Credentials.
ObjectMapper mapper = JacksonUtil.createBasicObjectMapper();
JsonParser parser = mapper.createParser(contents);
JsonNode rootNode = mapper.readTree(parser);
JsonParser parser = YarnJacksonUtil.getSharedReader().createParser(contents);
JsonNode rootNode = YarnJacksonUtil.getSharedReader().readTree(parser);

Credentials credentials = new Credentials();
if (rootNode.has(CONFIG_AUTHS_KEY)) {
Expand Down Expand Up @@ -160,7 +158,7 @@ public static boolean writeDockerCredentialsToPath(File outConfigFile,
Credentials credentials) throws IOException {
boolean foundDockerCred = false;
if (credentials.numberOfTokens() > 0) {
ObjectMapper mapper = JacksonUtil.createBasicObjectMapper();
ObjectMapper mapper = YarnJacksonUtil.createBasicObjectMapper();
ObjectNode rootNode = mapper.createObjectNode();
ObjectNode registryUrlNode = mapper.createObjectNode();
for (Token<? extends TokenIdentifier> tk : credentials.getAllTokens()) {
Expand Down
Loading