Skip to content

Commit

Permalink
HBASE-16338 Remove Jackson1 deps
Browse files Browse the repository at this point in the history
* Change imports from org.codehaus to com.fasterxml
* Exclude transitive jackson1 from hadoop and others
* Minor test cleanup to add assert messages, fix some parameter order
* Add anti-pattern check for using jackson 1 imports
* Add explicit non-null serialization directive to ScannerModel
  • Loading branch information
madrob committed Oct 20, 2017
1 parent a43a00e commit 5facade
Show file tree
Hide file tree
Showing 53 changed files with 317 additions and 281 deletions.
6 changes: 6 additions & 0 deletions dev-support/hbase-personality.sh
Expand Up @@ -428,6 +428,12 @@ function hbaseanti_patchfile
((result=result+1))
fi

warnings=$(${GREP} 'import org.codehaus.jackson' "${patchfile}")
if [[ ${warnings} -gt 0 ]]; then
add_vote_table -1 hbaseanti "" "The patch appears use Jackson 1 classes/annotations: ${warnings}."
((result=result+1))
fi

if [[ ${result} -gt 0 ]]; then
return 1
fi
Expand Down
8 changes: 4 additions & 4 deletions hbase-client/pom.xml
Expand Up @@ -168,10 +168,6 @@
<groupId>org.apache.htrace</groupId>
<artifactId>htrace-core</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</dependency>
<dependency>
<groupId>org.jruby.jcodings</groupId>
<artifactId>jcodings</artifactId>
Expand Down Expand Up @@ -218,6 +214,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>

<profiles>
Expand Down
Expand Up @@ -21,8 +21,8 @@
import java.io.IOException;
import java.util.Map;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.yetus.audience.InterfaceAudience;
import org.codehaus.jackson.map.ObjectMapper;

/**
* Utility class for converting objects to JSON
Expand Down
Expand Up @@ -62,10 +62,10 @@
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.BuilderStyleTest;
import org.apache.hadoop.hbase.util.Bytes;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
* Run tests that use the functionality of the Operation superclass for
Expand Down
4 changes: 4 additions & 0 deletions hbase-it/pom.xml
Expand Up @@ -294,6 +294,10 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>

<profiles>
Expand Down
Expand Up @@ -18,13 +18,13 @@

package org.apache.hadoop.hbase;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.util.ReflectionUtils;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
Expand Down Expand Up @@ -222,8 +222,8 @@ private String getHostId(String hostname) throws IOException {
if (hosts != null) {
// Iterate through the list of hosts, stopping once you've reached the requested hostname.
for (JsonNode host : hosts) {
if (host.get("hostname").getTextValue().equals(hostname)) {
hostId = host.get("hostId").getTextValue();
if (host.get("hostname").textValue().equals(hostname)) {
hostId = host.get("hostId").textValue();
break;
}
}
Expand Down Expand Up @@ -272,12 +272,12 @@ private String getRolePropertyValue(String serviceName, String roleType, String
if (roles != null) {
// Iterate through the list of roles, stopping once the requested one is found.
for (JsonNode role : roles) {
if (role.get("hostRef").get("hostId").getTextValue().equals(hostId) &&
if (role.get("hostRef").get("hostId").textValue().equals(hostId) &&
role.get("type")
.getTextValue()
.textValue()
.toLowerCase(Locale.ROOT)
.equals(roleType.toLowerCase(Locale.ROOT))) {
roleValue = role.get(property).getTextValue();
roleValue = role.get(property).textValue();
break;
}
}
Expand Down Expand Up @@ -306,8 +306,8 @@ private String getServiceName(Service service) throws IOException {
if (services != null) {
// Iterate through the list of services, stopping once the requested one is found.
for (JsonNode serviceEntry : services) {
if (serviceEntry.get("type").getTextValue().equals(service.toString())) {
serviceName = serviceEntry.get("name").getTextValue();
if (serviceEntry.get("type").textValue().equals(service.toString())) {
serviceName = serviceEntry.get("name").textValue();
break;
}
}
Expand Down
12 changes: 4 additions & 8 deletions hbase-mapreduce/pom.xml
Expand Up @@ -285,14 +285,6 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -305,6 +297,10 @@
<version>${netty.hadoop.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
<profiles>
<!-- Skip the tests in this module -->
Expand Down
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.hadoop.hbase;

import static org.codehaus.jackson.map.SerializationConfig.Feature.SORT_PROPERTIES_ALPHABETICALLY;

import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.Constructor;
Expand Down Expand Up @@ -71,8 +69,6 @@
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.filter.BinaryComparator;
import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.FilterAllFilter;
import org.apache.hadoop.hbase.filter.FilterList;
Expand All @@ -85,7 +81,6 @@
import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
import org.apache.hadoop.hbase.regionserver.BloomType;
import org.apache.hadoop.hbase.regionserver.CompactingMemStore;
import org.apache.hadoop.hbase.regionserver.TestHRegionFileSystem;
import org.apache.hadoop.hbase.trace.HBaseHTraceConfiguration;
import org.apache.hadoop.hbase.trace.SpanReceiverHost;
import org.apache.hadoop.hbase.util.*;
Expand All @@ -98,7 +93,6 @@
import org.apache.hadoop.mapreduce.lib.reduce.LongSumReducer;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
import org.codehaus.jackson.map.ObjectMapper;
import org.apache.htrace.Sampler;
import org.apache.htrace.Trace;
import org.apache.htrace.TraceScope;
Expand All @@ -108,6 +102,8 @@

import com.codahale.metrics.Histogram;
import com.codahale.metrics.UniformReservoir;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.MapperFeature;

/**
* Script used evaluating HBase performance and scalability. Runs a HBase
Expand All @@ -133,7 +129,7 @@ public class PerformanceEvaluation extends Configured implements Tool {
private static final Log LOG = LogFactory.getLog(PerformanceEvaluation.class.getName());
private static final ObjectMapper MAPPER = new ObjectMapper();
static {
MAPPER.configure(SORT_PROPERTIES_ALPHABETICALLY, true);
MAPPER.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
}

public static final String TABLE_NAME = "TestTable";
Expand Down
Expand Up @@ -37,16 +37,16 @@
import org.apache.hadoop.hbase.PerformanceEvaluation.TestOptions;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.codahale.metrics.Histogram;
import com.codahale.metrics.Snapshot;
import com.codahale.metrics.UniformReservoir;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

@Category({MiscTests.class, SmallTests.class})
public class TestPerformanceEvaluation {
Expand Down
13 changes: 0 additions & 13 deletions hbase-resource-bundle/src/main/resources/supplemental-models.xml
Expand Up @@ -512,19 +512,6 @@ under the License.
</licenses>
</project>
</supplement>
<supplement>
<project>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson1</artifactId>
<licenses>
<license>
<name>CDDL 1.1</name>
<url>https://glassfish.java.net/public/CDDL+GPL_1_1.html</url>
<distribution>repo</distribution>
</license>
</licenses>
</project>
</supplement>
<supplement>
<project>
<groupId>org.glassfish.web</groupId>
Expand Down
21 changes: 11 additions & 10 deletions hbase-rest/pom.xml
Expand Up @@ -206,6 +206,15 @@
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-server</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-hadoop-compat</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>${compat.module}</artifactId>
<version>${project.version}</version>
</dependency>
<!--Below MR wanted by PE-->
<dependency>
<groupId>org.apache.hbase</groupId>
Expand Down Expand Up @@ -300,8 +309,8 @@
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson1</artifactId>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
</dependency>
<dependency>
<!--For JspC used in ant task-->
Expand All @@ -320,14 +329,6 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
Expand Down
Expand Up @@ -35,23 +35,22 @@
import org.apache.hadoop.hbase.rest.model.RowModel;
import org.apache.hadoop.hbase.util.Bytes;

public class ProtobufStreamingOutput implements StreamingOutput {
private static final Log LOG = LogFactory.getLog(ProtobufStreamingOutput.class);

public class ProtobufStreamingUtil implements StreamingOutput {

private static final Log LOG = LogFactory.getLog(ProtobufStreamingUtil.class);
private String contentType;
private ResultScanner resultScanner;
private int limit;
private int fetchSize;

protected ProtobufStreamingUtil(ResultScanner scanner, String type, int limit, int fetchSize) {
protected ProtobufStreamingOutput(ResultScanner scanner, String type, int limit, int fetchSize) {
this.resultScanner = scanner;
this.contentType = type;
this.limit = limit;
this.fetchSize = fetchSize;
if (LOG.isTraceEnabled()) {
LOG.trace("Created ScanStreamingUtil with content type = " + this.contentType
+ " user limit : " + this.limit + " scan fetch size : " + this.fetchSize);
LOG.trace("Created StreamingOutput with content type = " + this.contentType
+ " user limit : " + this.limit + " scan fetch size : " + this.fetchSize);
}
}

Expand Down
Expand Up @@ -27,6 +27,7 @@
import java.util.EnumSet;
import java.util.concurrent.ArrayBlockingQueue;

import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
Expand Down Expand Up @@ -67,7 +68,6 @@
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.servlet.FilterHolder;

import org.glassfish.jersey.jackson1.Jackson1Feature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer;

Expand Down Expand Up @@ -238,7 +238,7 @@ public static void main(String[] args) throws Exception {

// set up the Jersey servlet container for Jetty
ResourceConfig application = new ResourceConfig().
packages("org.apache.hadoop.hbase.rest").register(Jackson1Feature.class);
packages("org.apache.hadoop.hbase.rest").register(JacksonJaxbJsonProvider.class);
ServletHolder sh = new ServletHolder(new ServletContainer(application));

// Set the default max thread number to 100 to limit
Expand Down

0 comments on commit 5facade

Please sign in to comment.