diff --git a/LICENSE-binary b/LICENSE-binary
index 4e6f688fcb896..0343e3ac9fb46 100644
--- a/LICENSE-binary
+++ b/LICENSE-binary
@@ -218,12 +218,12 @@ com.aliyun.oss:aliyun-sdk-oss:3.13.2
com.amazonaws:aws-java-sdk-bundle:1.11.901
com.cedarsoftware:java-util:1.9.0
com.cedarsoftware:json-io:2.5.1
-com.fasterxml.jackson.core:jackson-annotations:2.12.7
-com.fasterxml.jackson.core:jackson-core:2.12.7
-com.fasterxml.jackson.core:jackson-databind:2.12.7
-com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:2.12.7
-com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.12.7
-com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.12.7
+com.fasterxml.jackson.core:jackson-annotations:2.13.2
+com.fasterxml.jackson.core:jackson-core:2.13.2
+com.fasterxml.jackson.core:jackson-databind:2.13.2.2
+com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:2.13.2
+com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.13.2
+com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.13.2
com.fasterxml.uuid:java-uuid-generator:3.1.4
com.fasterxml.woodstox:woodstox-core:5.3.0
com.github.davidmoten:rxjava-extras:0.8.0.17
@@ -510,6 +510,7 @@ javax.annotation:javax.annotation-api:1.3.2
javax.servlet:javax.servlet-api:3.1.0
javax.servlet.jsp:jsp-api:2.1
javax.websocket:javax.websocket-api:1.0
+javax.ws.rs:javax.ws.rs-api:2.1.1
javax.ws.rs:jsr311-api:1.1.1
javax.xml.bind:jaxb-api:2.2.11
diff --git a/hadoop-client-modules/hadoop-client-minicluster/pom.xml b/hadoop-client-modules/hadoop-client-minicluster/pom.xml
index b8cb525669b1f..cecda5a0f793c 100644
--- a/hadoop-client-modules/hadoop-client-minicluster/pom.xml
+++ b/hadoop-client-modules/hadoop-client-minicluster/pom.xml
@@ -396,78 +396,19 @@
-
-
- org.mockito
- mockito-core
- true
-
-
-
-
-
-
- com.sun.jersey
- jersey-core
- true
-
-
- javax.ws.rs
- jsr311-api
-
-
-
-
- com.sun.jersey
- jersey-client
- true
-
+
- com.github.pjfanning
- jersey-json
- true
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
- com.fasterxml.jackson.jaxrs
- jackson-jaxrs-json-provider
-
-
- javax.xml.bind
- jaxb-api
-
-
-
-
- com.sun.jersey
- jersey-server
+ javax.ws.rs
+ javax.ws.rs-api
+ compile
true
+
+
- com.sun.jersey
- jersey-servlet
+ org.mockito
+ mockito-core
true
-
-
- javax.servlet
- servlet-api
-
-
- javax.enterprise
- cdi-api
-
-
- ch.qos.cal10n
- cal10n-api
-
-
@@ -611,24 +552,7 @@
-
- com.sun.jersey.jersey-test-framework
- jersey-test-framework-grizzly2
- true
-
-
-
- org.glassfish
- javax.servlet
-
-
-
-
- com.sun.jersey.contribs
- jersey-guice
- true
-
@@ -704,6 +628,7 @@
org.bouncycastle:*
org.xerial.snappy:*
+ javax.ws.rs:javax.ws.rs-api
diff --git a/hadoop-cloud-storage-project/hadoop-cloud-storage/pom.xml b/hadoop-cloud-storage-project/hadoop-cloud-storage/pom.xml
index 33d3f9578172f..dee6da16ab8c4 100644
--- a/hadoop-cloud-storage-project/hadoop-cloud-storage/pom.xml
+++ b/hadoop-cloud-storage-project/hadoop-cloud-storage/pom.xml
@@ -69,18 +69,6 @@
org.mortbay.jetty
servlet-api-2.5
-
- com.sun.jersey
- jersey-core
-
-
- com.sun.jersey
- jersey-json
-
-
- com.sun.jersey
- jersey-server
-
org.eclipse.jdt
core
diff --git a/hadoop-common-project/hadoop-common/pom.xml b/hadoop-common-project/hadoop-common/pom.xml
index d8e2dd3542223..ce0263f6cbfd9 100644
--- a/hadoop-common-project/hadoop-common/pom.xml
+++ b/hadoop-common-project/hadoop-common/pom.xml
@@ -133,57 +133,38 @@
runtime
- com.sun.jersey
- jersey-core
+ commons-logging
+ commons-logging
compile
- com.sun.jersey
- jersey-servlet
+ org.glassfish.jersey.core
+ jersey-server
compile
-
-
- javax.enterprise
- cdi-api
-
-
- javax.servlet
- servlet-api
-
-
- ch.qos.cal10n
- cal10n-api
-
-
- com.github.pjfanning
- jersey-json
- compile
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
- com.fasterxml.jackson.jaxrs
- jackson-jaxrs-json-provider
-
-
+ javax.ws.rs
+ javax.ws.rs-api
- com.sun.jersey
- jersey-server
+ org.glassfish.jersey.containers
+ jersey-container-servlet-core
compile
- commons-logging
- commons-logging
- compile
+ org.glassfish.grizzly
+ grizzly-http-servlet
+ test
+
+
+ org.glassfish.grizzly
+ grizzly-http
+ test
+
+
+ org.glassfish.grizzly
+ grizzly-http-server
+ test
log4j
@@ -200,11 +181,6 @@
assertj-core
test
-
- org.glassfish.grizzly
- grizzly-http-servlet
- test
-
commons-beanutils
commons-beanutils
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java
index 1db8c750cef93..8fb72be55e71f 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java
@@ -58,7 +58,6 @@
import org.apache.hadoop.classification.VisibleForTesting;
import org.apache.hadoop.util.Preconditions;
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
-import com.sun.jersey.spi.container.servlet.ServletContainer;
import org.apache.hadoop.HadoopIllegalArgumentException;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
@@ -114,6 +113,8 @@
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.webapp.WebAppContext;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.servlet.ServletContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -1017,10 +1018,24 @@ public void addJerseyResourcePackage(final String packageName,
final String pathSpec, Map params) {
LOG.info("addJerseyResourcePackage: packageName=" + packageName
+ ", pathSpec=" + pathSpec);
- final ServletHolder sh = new ServletHolder(ServletContainer.class);
- sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
- "com.sun.jersey.api.core.PackagesResourceConfig");
- sh.setInitParameter("com.sun.jersey.config.property.packages", packageName);
+ final ResourceConfig config = new ResourceConfig().packages(packageName);
+ final ServletHolder sh = new ServletHolder(new ServletContainer(config));
+ for (Map.Entry entry : params.entrySet()) {
+ sh.setInitParameter(entry.getKey(), entry.getValue());
+ }
+ webAppContext.addServlet(sh, pathSpec);
+ }
+
+ /**
+ * Add a Jersey resource config.
+ * @param config The Jersey ResourceConfig to be registered.
+ * @param pathSpec The path spec for the servlet
+ * @param params properties and features for ResourceConfig
+ */
+ public void addJerseyResourceConfig(final ResourceConfig config,
+ final String pathSpec, Map params) {
+ LOG.info("addJerseryResourceConfig: pathSpec={}", pathSpec);
+ final ServletHolder sh = new ServletHolder(new ServletContainer(config));
for (Map.Entry entry : params.entrySet()) {
sh.setInitParameter(entry.getKey(), entry.getValue());
}
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/DNS.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/DNS.java
index 53bb44fb2e9ef..806d5db6e51a2 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/DNS.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/DNS.java
@@ -73,7 +73,7 @@ public class DNS {
* @return The host name associated with the provided IP
* @throws NamingException If a NamingException is encountered
*/
- public static String reverseDns(InetAddress hostIp, @Nullable String ns)
+ public static String reverseDns(InetAddress hostIp, String ns)
throws NamingException {
//
// Builds the reverse IP lookup form
@@ -246,7 +246,7 @@ public static String getDefaultIP(String strInterface)
* @throws UnknownHostException if the given interface is invalid
*/
public static String[] getHosts(String strInterface,
- @Nullable String nameserver,
+ String nameserver,
boolean tryfallbackResolution)
throws UnknownHostException {
final List hosts = new Vector();
@@ -357,8 +357,8 @@ public static String[] getHosts(String strInterface)
* @throws UnknownHostException
* If one is encountered while querying the default interface
*/
- public static String getDefaultHost(@Nullable String strInterface,
- @Nullable String nameserver,
+ public static String getDefaultHost(String strInterface,
+ String nameserver,
boolean tryfallbackResolution)
throws UnknownHostException {
if (strInterface == null || "default".equals(strInterface)) {
@@ -385,7 +385,7 @@ public static String getDefaultHost(@Nullable String strInterface,
* @throws UnknownHostException
* If one is encountered while querying the default interface
*/
- public static String getDefaultHost(@Nullable String strInterface)
+ public static String getDefaultHost(String strInterface)
throws UnknownHostException {
return getDefaultHost(strInterface, null, false);
}
@@ -401,8 +401,8 @@ public static String getDefaultHost(@Nullable String strInterface)
* @throws UnknownHostException
* If one is encountered while querying the default interface
*/
- public static String getDefaultHost(@Nullable String strInterface,
- @Nullable String nameserver)
+ public static String getDefaultHost(String strInterface,
+ String nameserver)
throws UnknownHostException {
return getDefaultHost(strInterface, nameserver, false);
}
diff --git a/hadoop-common-project/hadoop-kms/pom.xml b/hadoop-common-project/hadoop-kms/pom.xml
index 96588a22b9419..88ba9b4938d7e 100644
--- a/hadoop-common-project/hadoop-kms/pom.xml
+++ b/hadoop-common-project/hadoop-kms/pom.xml
@@ -59,15 +59,30 @@
compile
- com.sun.jersey
- jersey-core
+ com.fasterxml.jackson.jaxrs
+ jackson-jaxrs-json-provider
compile
- com.sun.jersey
+ org.glassfish.jersey.core
+ jersey-common
+ compile
+
+
+ org.glassfish.jersey.core
jersey-server
compile
+
+ org.glassfish.jersey.containers
+ jersey-container-servlet-core
+ compile
+
+
+ org.glassfish.jersey.inject
+ jersey-hk2
+ runtime
+
javax.servlet
javax.servlet-api
diff --git a/hadoop-common-project/hadoop-kms/src/main/conf/kms-log4j.properties b/hadoop-common-project/hadoop-kms/src/main/conf/kms-log4j.properties
index e2afd41be0898..10a26ff5b7481 100644
--- a/hadoop-common-project/hadoop-kms/src/main/conf/kms-log4j.properties
+++ b/hadoop-common-project/hadoop-kms/src/main/conf/kms-log4j.properties
@@ -34,7 +34,6 @@ log4j.additivity.kms-audit=false
log4j.rootLogger=INFO, kms
log4j.logger.org.apache.hadoop=INFO
-log4j.logger.com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator=OFF
# make zookeeper log level an explicit config, and not changing with rootLogger.
log4j.logger.org.apache.zookeeper=INFO
log4j.logger.org.apache.curator=INFO
diff --git a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMS.java b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMS.java
index 82f1bde1fac64..4e0daba9dc05e 100644
--- a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMS.java
+++ b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMS.java
@@ -39,6 +39,7 @@
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
+import javax.ws.rs.OPTIONS;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@@ -114,6 +115,14 @@ private static URI getKeyURI(String domain, String keyName) {
.build(domain, KMSRESTConstants.KEY_RESOURCE, keyName);
}
+ @OPTIONS
+ public Response handleOptions() {
+ return Response.ok()
+ .header("Allow", "GET")
+ .header("Allow", "OPTIONS")
+ .build();
+ }
+
@POST
@Path(KMSRESTConstants.KEYS_RESOURCE)
@Consumes(MediaType.APPLICATION_JSON)
@@ -175,13 +184,9 @@ public KeyVersion run() throws Exception {
keyVersion = removeKeyMaterial(keyVersion);
}
Map json = KMSUtil.toJSON(keyVersion);
- String requestURL = KMSMDCFilter.getURL();
- int idx = requestURL.lastIndexOf(KMSRESTConstants.KEYS_RESOURCE);
- requestURL = requestURL.substring(0, idx);
LOG.trace("Exiting createKey Method.");
return Response.created(getKeyURI(KMSRESTConstants.SERVICE_VERSION, name))
- .type(MediaType.APPLICATION_JSON)
- .header("Location", getKeyURI(requestURL, name)).entity(json).build();
+ .type(MediaType.APPLICATION_JSON).entity(json).build();
} catch (Exception e) {
LOG.debug("Exception in createKey.", e);
throw e;
diff --git a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSExceptionsProvider.java b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSExceptionsProvider.java
index ceaa8bc815e5f..1bc142773666d 100644
--- a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSExceptionsProvider.java
+++ b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSExceptionsProvider.java
@@ -19,13 +19,12 @@
import org.apache.hadoop.classification.InterfaceAudience;
-import com.sun.jersey.api.container.ContainerException;
-
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authentication.client.AuthenticationException;
import org.apache.hadoop.security.authorize.AuthorizationException;
import org.apache.hadoop.util.HttpExceptionUtils;
+import org.glassfish.jersey.server.ContainerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/hadoop-common-project/hadoop-kms/src/main/resources/webapps/kms/WEB-INF/web.xml b/hadoop-common-project/hadoop-kms/src/main/resources/webapps/kms/WEB-INF/web.xml
index 737236c24a1b5..9565d378d444e 100644
--- a/hadoop-common-project/hadoop-kms/src/main/resources/webapps/kms/WEB-INF/web.xml
+++ b/hadoop-common-project/hadoop-kms/src/main/resources/webapps/kms/WEB-INF/web.xml
@@ -20,23 +20,11 @@
webservices-driver
- com.sun.jersey.spi.container.servlet.ServletContainer
+ org.glassfish.jersey.servlet.ServletContainer
- com.sun.jersey.config.property.packages
+ jersey.config.server.provider.packages
org.apache.hadoop.crypto.key.kms.server
-
-
-
1
diff --git a/hadoop-common-project/hadoop-kms/src/test/resources/log4j.properties b/hadoop-common-project/hadoop-kms/src/test/resources/log4j.properties
index 73c48534a0a01..50f5d4edf8c8b 100644
--- a/hadoop-common-project/hadoop-kms/src/test/resources/log4j.properties
+++ b/hadoop-common-project/hadoop-kms/src/test/resources/log4j.properties
@@ -25,8 +25,6 @@ log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %-5p %c{1} - %m%n
log4j.rootLogger=INFO, stdout
log4j.logger.org.apache.hadoop.conf=ERROR
log4j.logger.org.apache.hadoop.crytpo.key.kms.server=ALL
-log4j.logger.com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator=OFF
-log4j.logger.com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator=OFF
log4j.logger.org.apache.hadoop.security=OFF
log4j.logger.org.apache.directory.server.core=OFF
log4j.logger.org.apache.hadoop.util.NativeCodeLoader=OFF
diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/pom.xml b/hadoop-hdfs-project/hadoop-hdfs-httpfs/pom.xml
index a1b3ab1f92397..5ad4d229cde1b 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/pom.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/pom.xml
@@ -58,12 +58,12 @@
compile
- com.sun.jersey
- jersey-core
+ org.glassfish.jersey.core
+ jersey-common
compile
- com.sun.jersey
+ org.glassfish.jersey.core
jersey-server
compile
diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSExceptionProvider.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSExceptionProvider.java
index 4739e42137ccb..e1eaf424087b3 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSExceptionProvider.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSExceptionProvider.java
@@ -18,10 +18,10 @@
package org.apache.hadoop.fs.http.server;
-import com.sun.jersey.api.container.ContainerException;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.lib.service.FileSystemAccessException;
import org.apache.hadoop.lib.wsrs.ExceptionProvider;
+import org.glassfish.jersey.server.ContainerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSParametersProvider.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSParametersProvider.java
index 41009c7b5169f..283647aba7ade 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSParametersProvider.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSParametersProvider.java
@@ -34,7 +34,6 @@
import org.apache.hadoop.lib.wsrs.ShortParam;
import org.apache.hadoop.lib.wsrs.StringParam;
import org.apache.hadoop.util.StringUtils;
-import javax.ws.rs.ext.Provider;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
@@ -42,7 +41,6 @@
/**
* HttpFS ParametersProvider.
*/
-@Provider
@InterfaceAudience.Private
@SuppressWarnings("unchecked")
public class HttpFSParametersProvider extends ParametersProvider {
@@ -129,7 +127,7 @@ public class HttpFSParametersProvider extends ParametersProvider {
PARAMS_DEF.put(Operation.SATISFYSTORAGEPOLICY, new Class[] {});
}
- public HttpFSParametersProvider() {
+ HttpFSParametersProvider() {
super(HttpFSFileSystem.OP_PARAM, HttpFSFileSystem.Operation.class,
PARAMS_DEF);
}
diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
index 399ff3bde9c5b..f5b6330e000b6 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSServer.java
@@ -140,6 +140,15 @@ private UserGroupInformation getHttpUGI(HttpServletRequest request) {
}
+ private static final HttpFSParametersProvider PARAMETERS_PROVIDER =
+ new HttpFSParametersProvider();
+
+ private Parameters getParams(HttpServletRequest request) {
+ return PARAMETERS_PROVIDER.get(request);
+ }
+
+ private static final Object[] NULL = new Object[0];
+
/**
* Executes a {@link FileSystemAccess.FileSystemExecutor} using a filesystem for the effective
* user.
@@ -199,7 +208,6 @@ private void enforceRootPath(HttpFSFileSystem.Operation op, String path) {
*
* @param uriInfo uri info of the request.
* @param op the HttpFS operation of the request.
- * @param params the HttpFS parameters of the request.
*
* @return the request response.
*
@@ -213,10 +221,9 @@ private void enforceRootPath(HttpFSFileSystem.Operation op, String path) {
@Produces(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8)
public Response getRoot(@Context UriInfo uriInfo,
@QueryParam(OperationParam.NAME) OperationParam op,
- @Context Parameters params,
@Context HttpServletRequest request)
throws IOException, FileSystemAccessException {
- return get("", uriInfo, op, params, request);
+ return get("", uriInfo, op, request);
}
private String makeAbsolute(String path) {
@@ -229,7 +236,6 @@ private String makeAbsolute(String path) {
* @param path the path for operation.
* @param uriInfo uri info of the request.
* @param op the HttpFS operation of the request.
- * @param params the HttpFS parameters of the request.
*
* @return the request response.
*
@@ -246,7 +252,6 @@ private String makeAbsolute(String path) {
public Response get(@PathParam("path") String path,
@Context UriInfo uriInfo,
@QueryParam(OperationParam.NAME) OperationParam op,
- @Context Parameters params,
@Context HttpServletRequest request)
throws IOException, FileSystemAccessException {
// Restrict access to only GETFILESTATUS and LISTSTATUS in write-only mode
@@ -258,6 +263,7 @@ public Response get(@PathParam("path") String path,
UserGroupInformation user = HttpUserGroupInformation.get();
Response response;
path = makeAbsolute(path);
+ final Parameters params = getParams(request);
MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
MDC.put("hostname", request.getRemoteAddr());
switch (op.value()) {
@@ -535,7 +541,6 @@ private URI createOpenRedirectionURL(UriInfo uriInfo) {
*
* @param path the path for operation.
* @param op the HttpFS operation of the request.
- * @param params the HttpFS parameters of the request.
*
* @return the request response.
*
@@ -550,7 +555,6 @@ private URI createOpenRedirectionURL(UriInfo uriInfo) {
@Produces(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8)
public Response delete(@PathParam("path") String path,
@QueryParam(OperationParam.NAME) OperationParam op,
- @Context Parameters params,
@Context HttpServletRequest request)
throws IOException, FileSystemAccessException {
// Do not allow DELETE commands in read-only mode
@@ -560,6 +564,7 @@ public Response delete(@PathParam("path") String path,
UserGroupInformation user = HttpUserGroupInformation.get();
Response response;
path = makeAbsolute(path);
+ final Parameters params = getParams(request);
MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
MDC.put("hostname", request.getRemoteAddr());
switch (op.value()) {
@@ -597,7 +602,7 @@ public Response delete(@PathParam("path") String path,
* @param is the inputstream for the request payload.
* @param uriInfo the of the request.
* @param op the HttpFS operation of the request.
- * @param params the HttpFS parameters of the request.
+ * @param request the HttpFS request.
*
* @return the request response.
*
@@ -611,9 +616,9 @@ public Response delete(@PathParam("path") String path,
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 })
public Response postRoot(InputStream is, @Context UriInfo uriInfo,
@QueryParam(OperationParam.NAME) OperationParam op,
- @Context Parameters params, @Context HttpServletRequest request)
+ @Context HttpServletRequest request)
throws IOException, FileSystemAccessException {
- return post(is, uriInfo, "/", op, params, request);
+ return post(is, uriInfo, "/", op, request);
}
/**
@@ -623,7 +628,6 @@ public Response postRoot(InputStream is, @Context UriInfo uriInfo,
* @param uriInfo the of the request.
* @param path the path for operation.
* @param op the HttpFS operation of the request.
- * @param params the HttpFS parameters of the request.
*
* @return the request response.
*
@@ -641,7 +645,6 @@ public Response post(InputStream is,
@Context UriInfo uriInfo,
@PathParam("path") String path,
@QueryParam(OperationParam.NAME) OperationParam op,
- @Context Parameters params,
@Context HttpServletRequest request)
throws IOException, FileSystemAccessException {
// Do not allow POST commands in read-only mode
@@ -651,6 +654,7 @@ public Response post(InputStream is,
UserGroupInformation user = HttpUserGroupInformation.get();
Response response;
path = makeAbsolute(path);
+ final Parameters params = getParams(request);
MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
MDC.put("hostname", request.getRemoteAddr());
switch (op.value()) {
@@ -727,10 +731,11 @@ public Response post(InputStream is,
*/
protected URI createUploadRedirectionURL(UriInfo uriInfo, Enum> uploadOperation) {
UriBuilder uriBuilder = uriInfo.getRequestUriBuilder();
- uriBuilder = uriBuilder.replaceQueryParam(OperationParam.NAME, uploadOperation).
- queryParam(DataParam.NAME, Boolean.TRUE)
- .replaceQueryParam(NoRedirectParam.NAME, (Object[]) null);
- return uriBuilder.build(null);
+ uriBuilder = uriBuilder.replaceQueryParam(OperationParam.NAME, uploadOperation)
+ .queryParam(DataParam.NAME, Boolean.TRUE)
+ .replaceQueryParam(NoRedirectParam.NAME, (Object[]) null);
+ // Workaround: NPE occurs when using null in Jersey 2.29
+ return uriBuilder.build(NULL);
}
/**
@@ -738,7 +743,7 @@ protected URI createUploadRedirectionURL(UriInfo uriInfo, Enum> uploadOperatio
* @param is the inputstream for the request payload.
* @param uriInfo the of the request.
* @param op the HttpFS operation of the request.
- * @param params the HttpFS parameters of the request.
+ * @param request the HttpFS request.
*
* @return the request response.
*
@@ -752,9 +757,9 @@ protected URI createUploadRedirectionURL(UriInfo uriInfo, Enum> uploadOperatio
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 })
public Response putRoot(InputStream is, @Context UriInfo uriInfo,
@QueryParam(OperationParam.NAME) OperationParam op,
- @Context Parameters params, @Context HttpServletRequest request)
+ @Context HttpServletRequest request)
throws IOException, FileSystemAccessException {
- return put(is, uriInfo, "/", op, params, request);
+ return put(is, uriInfo, "/", op, request);
}
/**
@@ -764,7 +769,6 @@ public Response putRoot(InputStream is, @Context UriInfo uriInfo,
* @param uriInfo the of the request.
* @param path the path for operation.
* @param op the HttpFS operation of the request.
- * @param params the HttpFS parameters of the request.
*
* @return the request response.
*
@@ -782,7 +786,6 @@ public Response put(InputStream is,
@Context UriInfo uriInfo,
@PathParam("path") String path,
@QueryParam(OperationParam.NAME) OperationParam op,
- @Context Parameters params,
@Context HttpServletRequest request)
throws IOException, FileSystemAccessException {
// Do not allow PUT commands in read-only mode
@@ -792,6 +795,7 @@ public Response put(InputStream is,
UserGroupInformation user = HttpUserGroupInformation.get();
Response response;
path = makeAbsolute(path);
+ final Parameters params = getParams(request);
MDC.put(HttpFSFileSystem.OP_PARAM, op.value().name());
MDC.put("hostname", request.getRemoteAddr());
switch (op.value()) {
diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/ParametersProvider.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/ParametersProvider.java
index 7addec58c2fb2..3ddb0faab561e 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/ParametersProvider.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/wsrs/ParametersProvider.java
@@ -18,32 +18,22 @@
package org.apache.hadoop.lib.wsrs;
-import com.sun.jersey.api.core.HttpContext;
-import com.sun.jersey.core.spi.component.ComponentContext;
-import com.sun.jersey.core.spi.component.ComponentScope;
-import com.sun.jersey.server.impl.inject.AbstractHttpContextInjectable;
-import com.sun.jersey.spi.inject.Injectable;
-import com.sun.jersey.spi.inject.InjectableProvider;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.util.Lists;
import org.apache.hadoop.util.StringUtils;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MultivaluedMap;
-import java.lang.reflect.Type;
+import javax.servlet.http.HttpServletRequest;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
- * Jersey provider that parses the request parameters based on the
- * given parameter definition.
+ * Provider that parses the request parameters based on the
+ * given parameter definition.
*/
@InterfaceAudience.Private
-public class ParametersProvider
- extends AbstractHttpContextInjectable
- implements InjectableProvider {
+public class ParametersProvider {
private String driverParam;
private Class extends Enum> enumClass;
@@ -56,34 +46,42 @@ public ParametersProvider(String driverParam, Class extends Enum> enumClass,
this.paramsDef = paramsDef;
}
- @Override
- @SuppressWarnings("unchecked")
- public Parameters getValue(HttpContext httpContext) {
- Map>> map = new HashMap>>();
- Map> queryString =
- httpContext.getRequest().getQueryParameters();
- String str = ((MultivaluedMap) queryString).
- getFirst(driverParam);
+ private Param> newParam(Class> paramClass) {
+ try {
+ return paramClass.newInstance();
+ } catch (Exception ex) {
+ throw new UnsupportedOperationException(
+ MessageFormat.format(
+ "Param class [{0}] does not have default constructor",
+ paramClass.getName()));
+ }
+ }
+
+ public Parameters get(HttpServletRequest request) {
+ Map>> map = new HashMap<>();
+
+ Map queryString = request.getParameterMap();
+ String str = queryString.get(driverParam)[0];
if (str == null) {
throw new IllegalArgumentException(
- MessageFormat.format("Missing Operation parameter [{0}]",
- driverParam));
+ MessageFormat.format("Missing Operation parameter [{0}]",
+ driverParam));
}
Enum op;
try {
op = Enum.valueOf(enumClass, StringUtils.toUpperCase(str));
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException(
- MessageFormat.format("Invalid Operation [{0}]", str));
+ MessageFormat.format("Invalid Operation [{0}]", str));
}
if (!paramsDef.containsKey(op)) {
throw new IllegalArgumentException(
- MessageFormat.format("Unsupported Operation [{0}]", op));
+ MessageFormat.format("Unsupported Operation [{0}]", op));
}
for (Class> paramClass : paramsDef.get(op)) {
Param> param = newParam(paramClass);
List> paramList = Lists.newArrayList();
- List ps = queryString.get(param.getName());
+ String[] ps = queryString.get(param.getName());
if (ps != null) {
for (String p : ps) {
try {
@@ -103,25 +101,4 @@ public Parameters getValue(HttpContext httpContext) {
}
return new Parameters(map);
}
-
- private Param> newParam(Class> paramClass) {
- try {
- return paramClass.newInstance();
- } catch (Exception ex) {
- throw new UnsupportedOperationException(
- MessageFormat.format(
- "Param class [{0}] does not have default constructor",
- paramClass.getName()));
- }
- }
-
- @Override
- public ComponentScope getScope() {
- return ComponentScope.PerRequest;
- }
-
- @Override
- public Injectable getInjectable(ComponentContext componentContext, Context context, Type type) {
- return (type.equals(Parameters.class)) ? this : null;
- }
}
diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/resources/webapps/webhdfs/WEB-INF/web.xml b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/resources/webapps/webhdfs/WEB-INF/web.xml
index 3da9a5cf9761f..c0567ba96edcf 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/resources/webapps/webhdfs/WEB-INF/web.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/resources/webapps/webhdfs/WEB-INF/web.xml
@@ -20,23 +20,11 @@
webservices-driver
- com.sun.jersey.spi.container.servlet.ServletContainer
+ org.glassfish.jersey.servlet.ServletContainer
- com.sun.jersey.config.property.packages
+ jersey.config.server.provider.packages
org.apache.hadoop.fs.http.server,org.apache.hadoop.lib.wsrs
-
-
-
1
diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/webapp/WEB-INF/web.xml b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/webapp/WEB-INF/web.xml
index 4c0b3aedb0ef0..a4ba0abd892ea 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/webapp/WEB-INF/web.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/webapp/WEB-INF/web.xml
@@ -20,23 +20,11 @@
webservices-driver
- com.sun.jersey.spi.container.servlet.ServletContainer
+ org.glassfish.jersey.servlet.ServletContainer
- com.sun.jersey.config.property.packages
+ jersey.config.server.provider.packages
org.apache.hadoop.fs.http.server,org.apache.hadoop.lib.wsrs
-
-
-
1
diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/resources/default-log4j.properties b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/resources/default-log4j.properties
index 45a8412f5a76c..9ef5ec63d3464 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/resources/default-log4j.properties
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/resources/default-log4j.properties
@@ -23,4 +23,3 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %-5p %c{1} - %m%n
-log4j.logger.com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator=OFF
diff --git a/hadoop-hdfs-project/hadoop-hdfs-nfs/pom.xml b/hadoop-hdfs-project/hadoop-hdfs-nfs/pom.xml
index 24599a2b244a4..78f5878e2c6e0 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-nfs/pom.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs-nfs/pom.xml
@@ -108,16 +108,6 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
jetty-util
compile
-
- com.sun.jersey
- jersey-core
- compile
-
-
- com.sun.jersey
- jersey-server
- compile
-
commons-cli
commons-cli
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/pom.xml b/hadoop-hdfs-project/hadoop-hdfs-rbf/pom.xml
index d4d5c1eb33983..9d30b2ec3c720 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/pom.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/pom.xml
@@ -121,6 +121,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
com.fasterxml.jackson.core
jackson-databind
+
+ org.codehaus.jettison
+ jettison
+
junit
junit
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterWebHdfsMethods.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterWebHdfsMethods.java
index a66953b1bd752..567d595c20df6 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterWebHdfsMethods.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterWebHdfsMethods.java
@@ -37,9 +37,7 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import com.sun.jersey.spi.container.ResourceFilters;
import org.apache.hadoop.hdfs.web.JsonUtil;
-import org.apache.hadoop.hdfs.web.ParamFilter;
import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
import org.apache.hadoop.hdfs.web.resources.AccessTimeParam;
import org.apache.hadoop.hdfs.web.resources.AclPermissionParam;
@@ -117,7 +115,6 @@
* {@link NamenodeWebHdfsMethods}, and tries to reuse as much as possible.
*/
@Path("")
-@ResourceFilters(ParamFilter.class)
public class RouterWebHdfsMethods extends NamenodeWebHdfsMethods {
private static final Logger LOG =
LoggerFactory.getLogger(RouterWebHdfsMethods.class);
diff --git a/hadoop-hdfs-project/hadoop-hdfs/pom.xml b/hadoop-hdfs-project/hadoop-hdfs/pom.xml
index b51c7154f7b92..b0239f4a5d5b6 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/pom.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs/pom.xml
@@ -93,15 +93,25 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
compile
- com.sun.jersey
- jersey-core
+ org.glassfish.jersey.core
+ jersey-common
compile
- com.sun.jersey
+ org.glassfish.jersey.core
jersey-server
compile
+
+ org.glassfish.jersey.inject
+ jersey-hk2
+ runtime
+
+
+ org.glassfish.jersey.media
+ jersey-media-json-jettison
+ test
+
commons-cli
commons-cli
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/web/webhdfs/ExceptionHandler.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/web/webhdfs/ExceptionHandler.java
index 02ec25c13c874..b74558aaf631c 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/web/webhdfs/ExceptionHandler.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/web/webhdfs/ExceptionHandler.java
@@ -18,11 +18,11 @@
package org.apache.hadoop.hdfs.server.datanode.web.webhdfs;
import org.apache.hadoop.thirdparty.com.google.common.base.Charsets;
-import com.sun.jersey.api.ParamException;
-import com.sun.jersey.api.container.ContainerException;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.HttpResponseStatus;
+import org.glassfish.jersey.server.ContainerException;
+import org.glassfish.jersey.server.ParamException;
import org.slf4j.Logger;
import org.apache.hadoop.hdfs.web.JsonUtil;
import org.apache.hadoop.ipc.RemoteException;
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeHttpServer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeHttpServer.java
index e265742978d85..562156d2d8c0a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeHttpServer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeHttpServer.java
@@ -39,16 +39,19 @@
import org.apache.hadoop.hdfs.server.common.TokenVerifier;
import org.apache.hadoop.hdfs.server.namenode.startupprogress.StartupProgress;
import org.apache.hadoop.hdfs.server.namenode.web.resources.NamenodeWebHdfsMethods;
+import org.apache.hadoop.hdfs.web.ParamFilter;
import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
import org.apache.hadoop.hdfs.web.resources.AclPermissionParam;
import org.apache.hadoop.hdfs.web.resources.Param;
import org.apache.hadoop.hdfs.web.resources.UserParam;
+import org.apache.hadoop.hdfs.web.resources.UserProvider;
import org.apache.hadoop.http.HttpConfig;
import org.apache.hadoop.http.HttpServer2;
import org.apache.hadoop.net.NetUtils;
+import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.http.RestCsrfPreventionFilter;
-
-import com.sun.jersey.api.core.ResourceConfig;
+import org.glassfish.jersey.internal.inject.AbstractBinder;
+import org.glassfish.jersey.server.ResourceConfig;
/**
* Encapsulates the HTTP server started by the NameNode.
@@ -101,12 +104,24 @@ public static void initWebHdfs(Configuration conf, String hostname,
new String[] {pathSpec});
}
+ // add a filter to change parameter names to lower cases
+ HttpServer2.defineFilter(httpServer2.getWebAppContext(),
+ ParamFilter.class.getName(), ParamFilter.class.getName(), null,
+ new String[] {pathSpec});
+
// add webhdfs packages
final Map params = new HashMap<>();
- params.put(ResourceConfig.FEATURE_MATCH_MATRIX_PARAMS, "true");
- httpServer2.addJerseyResourcePackage(
- jerseyResourcePackage + ";" + Param.class.getPackage().getName(),
- pathSpec, params);
+ ResourceConfig config = new ResourceConfig();
+ config.packages(jerseyResourcePackage, Param.class.getPackage().getName());
+ config.register(new AbstractBinder() {
+ // add a factory to generate UserGroupInformation
+ @Override
+ protected void configure() {
+ bindFactory(UserProvider.class)
+ .to(UserGroupInformation.class);
+ }
+ });
+ httpServer2.addJerseyResourceConfig(config, pathSpec, params);
}
/**
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
index a3250c213caf0..9120c3f50ac5a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
@@ -54,6 +54,7 @@
import javax.ws.rs.core.StreamingOutput;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
import org.apache.hadoop.fs.InvalidPathException;
import org.apache.hadoop.fs.QuotaUsage;
@@ -100,7 +101,6 @@
import org.apache.hadoop.hdfs.server.namenode.NameNode;
import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols;
import org.apache.hadoop.hdfs.web.JsonUtil;
-import org.apache.hadoop.hdfs.web.ParamFilter;
import org.apache.hadoop.hdfs.web.WebHdfsConstants;
import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
import org.apache.hadoop.hdfs.web.resources.*;
@@ -119,11 +119,9 @@
import org.apache.hadoop.classification.VisibleForTesting;
import org.apache.hadoop.thirdparty.com.google.common.base.Charsets;
-import com.sun.jersey.spi.container.ResourceFilters;
/** Web-hdfs NameNode implementation. */
@Path("")
-@ResourceFilters(ParamFilter.class)
public class NamenodeWebHdfsMethods {
public static final Logger LOG =
LoggerFactory.getLogger(NamenodeWebHdfsMethods.class);
@@ -463,12 +461,12 @@ private URI redirectURI(ResponseBuilder rb, final NameNode namenode,
/** Handle HTTP PUT request for the root. */
@PUT
- @Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM + "; " + JettyUtils.UTF_8,
MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8})
public Response putRoot(
@Context final UserGroupInformation ugi,
+ @Context final UriInfo uriInfo,
@QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
final DelegationParam delegation,
@QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
@@ -538,7 +536,7 @@ public Response putRoot(
@DefaultValue(StorageTypeParam.DEFAULT)
final StorageTypeParam storageType
) throws IOException, InterruptedException {
- return put(ugi, delegation, username, doAsUser, ROOT, op, destination,
+ return put(ugi, uriInfo, delegation, username, doAsUser, op, destination,
owner, group, permission, unmaskedPermission, overwrite, bufferSize,
replication, blockSize, modificationTime, accessTime, renameOptions,
createParent, delegationTokenArgument, aclPermission, xattrName,
@@ -567,13 +565,13 @@ protected void validateOpParams(HttpOpParam> op, Param... params) {
MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8})
public Response put(
@Context final UserGroupInformation ugi,
+ @Context final UriInfo uriInfo,
@QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
final DelegationParam delegation,
@QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
final UserParam username,
@QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
final DoAsParam doAsUser,
- @PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
@QueryParam(PutOpParam.NAME) @DefaultValue(PutOpParam.DEFAULT)
final PutOpParam op,
@QueryParam(DestinationParam.NAME) @DefaultValue(DestinationParam.DEFAULT)
@@ -636,6 +634,7 @@ public Response put(
@QueryParam(StorageTypeParam.NAME) @DefaultValue(StorageTypeParam.DEFAULT)
final StorageTypeParam storageType
) throws IOException, InterruptedException {
+ final UriFsPathParam path = new UriFsPathParam(uriInfo.getPath());
init(ugi, delegation, username, doAsUser, path, op, destination, owner,
group, permission, unmaskedPermission, overwrite, bufferSize,
replication, blockSize, modificationTime, accessTime, renameOptions,
@@ -889,7 +888,6 @@ protected Response put(
/** Handle HTTP POST request for the root. */
@POST
- @Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM + "; " + JettyUtils.UTF_8,
MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8})
@@ -1019,11 +1017,11 @@ protected Response post(
/** Handle HTTP GET request for the root. */
@GET
- @Path("/")
@Produces({MediaType.APPLICATION_OCTET_STREAM + "; " + JettyUtils.UTF_8,
MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8})
public Response getRoot(
@Context final UserGroupInformation ugi,
+ @Context final UriInfo uriInfo,
@QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
final DelegationParam delegation,
@QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
@@ -1065,7 +1063,7 @@ public Response getRoot(
@QueryParam(StartAfterParam.NAME) @DefaultValue(StartAfterParam.DEFAULT)
final StartAfterParam startAfter
) throws IOException, InterruptedException {
- return get(ugi, delegation, username, doAsUser, ROOT, op, offset, length,
+ return get(ugi, uriInfo, delegation, username, doAsUser, op, offset, length,
renewer, bufferSize, xattrNames, xattrEncoding, excludeDatanodes,
fsAction, snapshotName, oldSnapshotName,
snapshotDiffStartPath, snapshotDiffIndex,
@@ -1080,13 +1078,13 @@ public Response getRoot(
MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8})
public Response get(
@Context final UserGroupInformation ugi,
+ @Context final UriInfo uriInfo,
@QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
final DelegationParam delegation,
@QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
final UserParam username,
@QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
final DoAsParam doAsUser,
- @PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
@QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
final GetOpParam op,
@QueryParam(OffsetParam.NAME) @DefaultValue(OffsetParam.DEFAULT)
@@ -1122,7 +1120,7 @@ public Response get(
@QueryParam(StartAfterParam.NAME) @DefaultValue(StartAfterParam.DEFAULT)
final StartAfterParam startAfter
) throws IOException, InterruptedException {
-
+ final UriFsPathParam path = new UriFsPathParam(uriInfo.getPath());
init(ugi, delegation, username, doAsUser, path, op, offset, length,
renewer, bufferSize, xattrEncoding, excludeDatanodes, fsAction,
snapshotName, oldSnapshotName, tokenKind, tokenService, startAfter);
@@ -1524,10 +1522,10 @@ public Void run() throws IOException {
/** Handle HTTP DELETE request for the root. */
@DELETE
- @Path("/")
@Produces(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8)
public Response deleteRoot(
@Context final UserGroupInformation ugi,
+ @Context final UriInfo uriInfo,
@QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
final DelegationParam delegation,
@QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
@@ -1541,7 +1539,7 @@ public Response deleteRoot(
@QueryParam(SnapshotNameParam.NAME) @DefaultValue(SnapshotNameParam.DEFAULT)
final SnapshotNameParam snapshotName
) throws IOException, InterruptedException {
- return delete(ugi, delegation, username, doAsUser, ROOT, op, recursive,
+ return delete(ugi, uriInfo, delegation, username, doAsUser, op, recursive,
snapshotName);
}
@@ -1551,13 +1549,13 @@ public Response deleteRoot(
@Produces(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8)
public Response delete(
@Context final UserGroupInformation ugi,
+ @Context final UriInfo uriInfo,
@QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
final DelegationParam delegation,
@QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
final UserParam username,
@QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
final DoAsParam doAsUser,
- @PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
@QueryParam(DeleteOpParam.NAME) @DefaultValue(DeleteOpParam.DEFAULT)
final DeleteOpParam op,
@QueryParam(RecursiveParam.NAME) @DefaultValue(RecursiveParam.DEFAULT)
@@ -1565,7 +1563,7 @@ public Response delete(
@QueryParam(SnapshotNameParam.NAME) @DefaultValue(SnapshotNameParam.DEFAULT)
final SnapshotNameParam snapshotName
) throws IOException, InterruptedException {
-
+ final UriFsPathParam path = new UriFsPathParam(uriInfo.getPath());
init(ugi, delegation, username, doAsUser, path, op, recursive, snapshotName);
return doAs(ugi, new PrivilegedExceptionAction() {
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/ParamFilter.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/ParamFilter.java
index febe1253a829d..e8d0f7f515174 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/ParamFilter.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/ParamFilter.java
@@ -17,70 +17,82 @@
*/
package org.apache.hadoop.hdfs.web;
-import java.net.URI;
-import java.util.List;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Map;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriBuilder;
-
-import com.sun.jersey.spi.container.ContainerRequest;
-import com.sun.jersey.spi.container.ContainerRequestFilter;
-import com.sun.jersey.spi.container.ContainerResponseFilter;
-import com.sun.jersey.spi.container.ResourceFilter;
-import org.apache.hadoop.util.StringUtils;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
/**
* A filter to change parameter names to lower cases
* so that parameter names are considered as case insensitive.
*/
-public class ParamFilter implements ResourceFilter {
- private static final ContainerRequestFilter LOWER_CASE
- = new ContainerRequestFilter() {
- @Override
- public ContainerRequest filter(final ContainerRequest request) {
- final MultivaluedMap parameters = request.getQueryParameters();
- if (containsUpperCase(parameters.keySet())) {
- //rebuild URI
- final URI lower = rebuildQuery(request.getRequestUri(), parameters);
- request.setUris(request.getBaseUri(), lower);
- }
- return request;
- }
- };
+public class ParamFilter implements Filter {
@Override
- public ContainerRequestFilter getRequestFilter() {
- return LOWER_CASE;
+ public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
- public ContainerResponseFilter getResponseFilter() {
- return null;
+ public void destroy() {
}
- /** Do the strings contain upper case letters? */
- static boolean containsUpperCase(final Iterable strings) {
- for(String s : strings) {
- for(int i = 0; i < s.length(); i++) {
- if (Character.isUpperCase(s.charAt(i))) {
- return true;
- }
- }
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response,
+ FilterChain chain)
+ throws IOException, ServletException {
+ if (request instanceof HttpServletRequest) {
+ chain.doFilter(new CustomHttpServletRequestWrapper(
+ (HttpServletRequest) request), response);
+ } else {
+ chain.doFilter(request, response);
}
- return false;
}
- /** Rebuild the URI query with lower case parameter names. */
- private static URI rebuildQuery(final URI uri,
- final MultivaluedMap parameters) {
- UriBuilder b = UriBuilder.fromUri(uri).replaceQuery("");
- for(Map.Entry> e : parameters.entrySet()) {
- final String key = StringUtils.toLowerCase(e.getKey());
- for(String v : e.getValue()) {
- b = b.queryParam(key, v);
+ private static final class CustomHttpServletRequestWrapper
+ extends HttpServletRequestWrapper {
+
+ private Map lowerCaseParams = new HashMap<>();
+
+ private CustomHttpServletRequestWrapper(HttpServletRequest request) {
+ super(request);
+ Map originalParams = request.getParameterMap();
+ for (Map.Entry entry : originalParams.entrySet()) {
+ lowerCaseParams.put(entry.getKey().toLowerCase(), entry.getValue());
+ }
+ }
+
+ public String getParameter(String name) {
+ String[] values = getParameterValues(name);
+ if (values != null && values.length > 0) {
+ return values[0];
+ } else {
+ return null;
}
}
- return b.build();
+
+ @Override
+ public Map getParameterMap() {
+ return Collections.unmodifiableMap(lowerCaseParams);
+ }
+
+ @Override
+ public Enumeration getParameterNames() {
+ return Collections.enumeration(lowerCaseParams.keySet());
+ }
+
+ @Override
+ public String[] getParameterValues(String name) {
+ return lowerCaseParams.get(name);
+ }
}
}
\ No newline at end of file
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/ExceptionHandler.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/ExceptionHandler.java
index f4704f77b104f..bbc35e22f8d5d 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/ExceptionHandler.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/ExceptionHandler.java
@@ -27,6 +27,8 @@
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
+import org.glassfish.jersey.server.ContainerException;
+import org.glassfish.jersey.server.ParamException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hadoop.hdfs.web.JsonUtil;
@@ -36,8 +38,6 @@
import org.apache.hadoop.security.token.SecretManager.InvalidToken;
import org.apache.hadoop.classification.VisibleForTesting;
-import com.sun.jersey.api.ParamException;
-import com.sun.jersey.api.container.ContainerException;
/** Handle exceptions. */
@Provider
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/UserProvider.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/UserProvider.java
index 32b3369f7a5a2..8e8977d4dd3b5 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/UserProvider.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/resources/UserProvider.java
@@ -17,57 +17,44 @@
*/
package org.apache.hadoop.hdfs.web.resources;
-import java.io.IOException;
-import java.lang.reflect.Type;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.ext.Provider;
-
+import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.server.common.JspHelper;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
-import com.sun.jersey.api.core.HttpContext;
-import com.sun.jersey.core.spi.component.ComponentContext;
-import com.sun.jersey.core.spi.component.ComponentScope;
-import com.sun.jersey.server.impl.inject.AbstractHttpContextInjectable;
-import com.sun.jersey.spi.inject.Injectable;
-import com.sun.jersey.spi.inject.InjectableProvider;
+import javax.inject.Inject;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.function.Supplier;
-/** Inject user information to http operations. */
-@Provider
-public class UserProvider
- extends AbstractHttpContextInjectable
- implements InjectableProvider {
- @Context HttpServletRequest request;
- @Context ServletContext servletcontext;
+/**
+ * Jersey provider to acquire {@link UserGroupInformation}
+ * from {@link HttpServletRequest}.
+ */
+@InterfaceAudience.Private
+public class UserProvider implements Supplier {
+
+ private final HttpServletRequest request;
+ private final ServletContext servletcontext;
+
+ @Inject
+ public UserProvider(HttpServletRequest request) {
+ this.request = request;
+ this.servletcontext = request.getServletContext();
+ }
@Override
- public UserGroupInformation getValue(final HttpContext context) {
+ public UserGroupInformation get() {
final Configuration conf = (Configuration) servletcontext
.getAttribute(JspHelper.CURRENT_CONF);
try {
return JspHelper.getUGI(servletcontext, request, conf,
- AuthenticationMethod.KERBEROS, false);
+ UserGroupInformation.AuthenticationMethod.KERBEROS, false);
} catch (IOException e) {
throw new SecurityException(
SecurityUtil.FAILED_TO_GET_UGI_MSG_HEADER + " " + e, e);
}
}
-
- @Override
- public ComponentScope getScope() {
- return ComponentScope.PerRequest;
- }
-
- @Override
- public Injectable getInjectable(
- final ComponentContext componentContext, final Context context,
- final Type type) {
- return type.equals(UserGroupInformation.class)? this : null;
- }
-}
\ No newline at end of file
+}
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/log4j.properties b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/log4j.properties
index 997854dcce7a3..73788467112e8 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/log4j.properties
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/log4j.properties
@@ -47,6 +47,3 @@ log4j.appender.DNMETRICSRFA.layout=org.apache.log4j.PatternLayout
log4j.appender.DNMETRICSRFA.layout.ConversionPattern=%d{ISO8601} %m%n
log4j.appender.DNMETRICSRFA.MaxBackupIndex=1
log4j.appender.DNMETRICSRFA.MaxFileSize=64MB
-
-# Supress KMS error log
-log4j.logger.com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator=OFF
\ No newline at end of file
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml
index e3b3511c0ce17..fa9dcb96bb0c6 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/pom.xml
@@ -57,6 +57,10 @@
+
+ org.glassfish.jersey.media
+ jersey-media-json-jettison
+
org.apache.hadoop
hadoop-yarn-server-common
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JobHistoryEventHandler.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JobHistoryEventHandler.java
index 9023f6a11ad84..00d168567207b 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JobHistoryEventHandler.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JobHistoryEventHandler.java
@@ -31,6 +31,8 @@
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
+import javax.ws.rs.ProcessingException;
+
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
@@ -80,7 +82,6 @@
import org.apache.hadoop.yarn.util.TimelineServiceHelper;
import org.apache.hadoop.classification.VisibleForTesting;
-import com.sun.jersey.api.client.ClientHandlerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -1141,7 +1142,7 @@ private void processEventForTimelineServer(HistoryEvent event, JobId jobId,
+ error.getErrorCode());
}
}
- } catch (YarnException | IOException | ClientHandlerException ex) {
+ } catch (YarnException | IOException | ProcessingException ex) {
LOG.error("Error putting entity " + tEntity.getEntityId() + " to Timeline"
+ "Server", ex);
}
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/JAXBContextResolver.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/JAXBContextResolver.java
index 625eb4ef32e42..3372587fb54e9 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/JAXBContextResolver.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/JAXBContextResolver.java
@@ -21,9 +21,8 @@
import java.util.HashMap;
import java.util.Map;
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.api.json.JSONJAXBContext;
import com.google.inject.Singleton;
+import org.glassfish.jersey.jettison.JettisonJaxbContext;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
@@ -72,13 +71,9 @@ public JAXBContextResolver() throws Exception {
JAXBContext context;
JAXBContext unWrappedRootContext;
- this.typesContextMap = new HashMap();
- context =
- new JSONJAXBContext(JSONConfiguration.natural().rootUnwrapping(false)
- .build(), cTypes);
- unWrappedRootContext =
- new JSONJAXBContext(JSONConfiguration.natural().rootUnwrapping(true)
- .build(), rootUnwrappedTypes);
+ this.typesContextMap = new HashMap<>();
+ context = new JettisonJaxbContext(cTypes);
+ unWrappedRootContext = new JettisonJaxbContext(rootUnwrappedTypes);
for (Class type : cTypes) {
typesContextMap.put(type, context);
}
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServices.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServices.java
index 5def1d91494c4..f76232d183a6e 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServices.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServices.java
@@ -26,7 +26,11 @@
import java.io.StringReader;
import java.util.Set;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -37,11 +41,14 @@
import org.apache.hadoop.util.Sets;
import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
import org.apache.hadoop.yarn.webapp.GuiceServletConfig;
-import org.apache.hadoop.yarn.webapp.JerseyTestBase;
import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
+
+import com.google.inject.Scopes;
+import com.google.inject.servlet.GuiceFilter;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
+import org.glassfish.jersey.test.JerseyTest;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
@@ -51,12 +58,6 @@
import com.google.inject.Guice;
import com.google.inject.servlet.ServletModule;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.ClientResponse.Status;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
-import com.sun.jersey.test.framework.WebAppDescriptor;
/**
* Test the MapReduce Application master info web services api's. Also test
@@ -65,7 +66,7 @@
* /ws/v1/mapreduce
* /ws/v1/mapreduce/info
*/
-public class TestAMWebServices extends JerseyTestBase {
+public class TestAMWebServices extends JerseyTest {
private static Configuration conf = new Configuration();
private static MockAppContext appContext;
@@ -83,7 +84,7 @@ protected void configureServlets() {
bind(AppContext.class).toInstance(appContext);
bind(Configuration.class).toInstance(conf);
- serve("/*").with(GuiceContainer.class);
+ bind(GuiceFilter.class).in(Scopes.SINGLETON);
}
}
@@ -101,191 +102,179 @@ public void setUp() throws Exception {
}
public TestAMWebServices() {
- super(new WebAppDescriptor.Builder(
- "org.apache.hadoop.mapreduce.v2.app.webapp")
- .contextListenerClass(GuiceServletConfig.class)
- .filterClass(com.google.inject.servlet.GuiceFilter.class)
- .contextPath("jersey-guice-filter").servletPath("/").build());
}
@Test
public void testAM() throws JSONException, Exception {
- WebResource r = resource();
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ WebTarget r = target();
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").request(MediaType.APPLICATION_JSON)
+ .get(Response.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
verifyAMInfo(json.getJSONObject("info"), appContext);
}
@Test
public void testAMSlash() throws JSONException, Exception {
- WebResource r = resource();
- ClientResponse response = r.path("ws").path("v1").path("mapreduce/")
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ WebTarget r = target();
+ Response response =
+ r.path("ws").path("v1").path("mapreduce/").request(MediaType.APPLICATION_JSON)
+ .get(Response.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
verifyAMInfo(json.getJSONObject("info"), appContext);
}
@Test
public void testAMDefault() throws JSONException, Exception {
- WebResource r = resource();
- ClientResponse response = r.path("ws").path("v1").path("mapreduce/")
- .get(ClientResponse.class);
+ WebTarget r = target();
+ Response response = r.path("ws").path("v1").path("mapreduce/").request().get(Response.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
verifyAMInfo(json.getJSONObject("info"), appContext);
}
@Test
public void testAMXML() throws JSONException, Exception {
- WebResource r = resource();
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
+ WebTarget r = target();
+ Response response = r.path("ws").path("v1").path("mapreduce").request(MediaType.APPLICATION_XML)
+ .get(Response.class);
assertEquals(MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- String xml = response.getEntity(String.class);
+ response.getMediaType().toString());
+ String xml = response.readEntity(String.class);
verifyAMInfoXML(xml, appContext);
}
@Test
public void testInfo() throws JSONException, Exception {
- WebResource r = resource();
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("info").accept(MediaType.APPLICATION_JSON)
- .get(ClientResponse.class);
+ WebTarget r = target();
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("info").request(MediaType.APPLICATION_JSON)
+ .get(Response.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
verifyAMInfo(json.getJSONObject("info"), appContext);
}
@Test
public void testInfoSlash() throws JSONException, Exception {
- WebResource r = resource();
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("info/").accept(MediaType.APPLICATION_JSON)
- .get(ClientResponse.class);
+ WebTarget r = target();
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("info/").request(MediaType.APPLICATION_JSON)
+ .get(Response.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
verifyAMInfo(json.getJSONObject("info"), appContext);
}
@Test
public void testInfoDefault() throws JSONException, Exception {
- WebResource r = resource();
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("info/").get(ClientResponse.class);
+ WebTarget r = target();
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("info/").request().get(Response.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
verifyAMInfo(json.getJSONObject("info"), appContext);
}
@Test
public void testInfoXML() throws JSONException, Exception {
- WebResource r = resource();
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("info/").accept(MediaType.APPLICATION_XML)
- .get(ClientResponse.class);
+ WebTarget r = target();
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("info/").request(MediaType.APPLICATION_XML)
+ .get(Response.class);
assertEquals(MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- String xml = response.getEntity(String.class);
+ response.getMediaType().toString());
+ String xml = response.readEntity(String.class);
verifyAMInfoXML(xml, appContext);
}
@Test
public void testInvalidUri() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
String responseStr = "";
try {
responseStr = r.path("ws").path("v1").path("mapreduce").path("bogus")
- .accept(MediaType.APPLICATION_JSON).get(String.class);
+ .request(MediaType.APPLICATION_JSON).get(String.class);
fail("should have thrown exception on invalid uri");
- } catch (UniformInterfaceException ue) {
- ClientResponse response = ue.getResponse();
+ } catch (WebApplicationException ue) {
+ Response response = ue.getResponse();
assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
- WebServicesTestUtils.checkStringMatch(
- "error string exists and shouldn't", "", responseStr);
+ WebServicesTestUtils.checkStringMatch("error string exists and shouldn't", "", responseStr);
}
}
@Test
public void testInvalidUri2() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
String responseStr = "";
try {
- responseStr = r.path("ws").path("v1").path("invalid")
- .accept(MediaType.APPLICATION_JSON).get(String.class);
+ responseStr = r.path("ws").path("v1").path("invalid").request(MediaType.APPLICATION_JSON)
+ .get(String.class);
fail("should have thrown exception on invalid uri");
- } catch (UniformInterfaceException ue) {
- ClientResponse response = ue.getResponse();
+ } catch (WebApplicationException ue) {
+ Response response = ue.getResponse();
assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
- WebServicesTestUtils.checkStringMatch(
- "error string exists and shouldn't", "", responseStr);
+ WebServicesTestUtils.checkStringMatch("error string exists and shouldn't", "", responseStr);
}
}
@Test
public void testInvalidAccept() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
String responseStr = "";
try {
- responseStr = r.path("ws").path("v1").path("mapreduce")
- .accept(MediaType.TEXT_PLAIN).get(String.class);
+ responseStr =
+ r.path("ws").path("v1").path("mapreduce").request(MediaType.TEXT_PLAIN).get(String.class);
fail("should have thrown exception on invalid uri");
- } catch (UniformInterfaceException ue) {
- ClientResponse response = ue.getResponse();
- assertResponseStatusCode(Status.INTERNAL_SERVER_ERROR,
- response.getStatusInfo());
- WebServicesTestUtils.checkStringMatch(
- "error string exists and shouldn't", "", responseStr);
+ } catch (WebApplicationException ue) {
+ Response response = ue.getResponse();
+ assertResponseStatusCode(Status.INTERNAL_SERVER_ERROR, response.getStatusInfo());
+ WebServicesTestUtils.checkStringMatch("error string exists and shouldn't", "", responseStr);
}
}
-
+
@Test
public void testBlacklistedNodes() throws JSONException, Exception {
- WebResource r = resource();
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("blacklistednodes").accept(MediaType.APPLICATION_JSON)
- .get(ClientResponse.class);
+ WebTarget r = target();
+ Response response = r.path("ws").path("v1").path("mapreduce").path("blacklistednodes")
+ .request(MediaType.APPLICATION_JSON).get(Response.class);
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
verifyBlacklistedNodesInfo(json, appContext);
}
-
+
@Test
public void testBlacklistedNodesXML() throws Exception {
- WebResource r = resource();
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("blacklistednodes").accept(MediaType.APPLICATION_XML)
- .get(ClientResponse.class);
+ WebTarget r = target();
+ Response response = r.path("ws").path("v1").path("mapreduce").path("blacklistednodes")
+ .request(MediaType.APPLICATION_XML).get(Response.class);
assertEquals(MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- String xml = response.getEntity(String.class);
+ response.getMediaType().toString());
+ String xml = response.readEntity(String.class);
verifyBlacklistedNodesInfoXML(xml, appContext);
}
- public void verifyAMInfo(JSONObject info, AppContext ctx)
- throws JSONException {
+ public void verifyAMInfo(JSONObject info, AppContext ctx) throws JSONException {
assertEquals("incorrect number of elements", 5, info.length());
verifyAMInfoGeneric(ctx, info.getString("appId"), info.getString("user"),
- info.getString("name"), info.getLong("startedOn"),
- info.getLong("elapsedTime"));
+ info.getString("name"), info.getLong("startedOn"), info.getLong("elapsedTime"));
}
public void verifyAMInfoXML(String xml, AppContext ctx)
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesAttempt.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesAttempt.java
index f20ac6ff1b88d..8214cd8acf6ad 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesAttempt.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesAttempt.java
@@ -46,9 +46,9 @@
import org.apache.hadoop.security.authentication.server.PseudoAuthenticationHandler;
import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
import org.apache.hadoop.yarn.webapp.GuiceServletConfig;
-import org.apache.hadoop.yarn.webapp.JerseyTestBase;
import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
import org.codehaus.jettison.json.JSONObject;
+import org.glassfish.jersey.test.JerseyTest;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
@@ -59,10 +59,6 @@
import com.google.inject.Guice;
import com.google.inject.Singleton;
import com.google.inject.servlet.ServletModule;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
-import com.sun.jersey.test.framework.WebAppDescriptor;
/**
* Test the app master web service Rest API for getting task attempts, a
@@ -70,7 +66,7 @@
*
* /ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}/attempts/{attemptid}/state
*/
-public class TestAMWebServicesAttempt extends JerseyTestBase {
+public class TestAMWebServicesAttempt extends JerseyTest {
private static Configuration conf = new Configuration();
private static AppContext appContext;
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesAttempts.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesAttempts.java
index 32d054ff5c514..be42c23546570 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesAttempts.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesAttempts.java
@@ -29,7 +29,10 @@
import java.util.List;
import java.util.Map;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -46,11 +49,14 @@
import org.apache.hadoop.mapreduce.v2.util.MRApps;
import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
import org.apache.hadoop.yarn.webapp.GuiceServletConfig;
-import org.apache.hadoop.yarn.webapp.JerseyTestBase;
import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
+
+import com.google.inject.Scopes;
+import com.google.inject.servlet.GuiceFilter;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
+import org.glassfish.jersey.test.JerseyTest;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
@@ -60,12 +66,6 @@
import com.google.inject.Guice;
import com.google.inject.servlet.ServletModule;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.ClientResponse.Status;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
-import com.sun.jersey.test.framework.WebAppDescriptor;
/**
* Test the app master web service Rest API for getting task attempts, a
@@ -75,7 +75,7 @@
* /ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}/attempts/{attemptid}
* /ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}/attempts/{attemptid}/counters
*/
-public class TestAMWebServicesAttempts extends JerseyTestBase {
+public class TestAMWebServicesAttempts extends JerseyTest {
private static Configuration conf = new Configuration();
private static AppContext appContext;
@@ -91,7 +91,7 @@ protected void configureServlets() {
bind(AppContext.class).toInstance(appContext);
bind(Configuration.class).toInstance(conf);
- serve("/*").with(GuiceContainer.class);
+ bind(GuiceFilter.class).in(Scopes.SINGLETON);
}
}
@@ -109,28 +109,23 @@ public void setUp() throws Exception {
}
public TestAMWebServicesAttempts() {
- super(new WebAppDescriptor.Builder(
- "org.apache.hadoop.mapreduce.v2.app.webapp")
- .contextListenerClass(GuiceServletConfig.class)
- .filterClass(com.google.inject.servlet.GuiceFilter.class)
- .contextPath("jersey-guice-filter").servletPath("/").build());
}
@Test
public void testTaskAttempts() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
for (Task task : jobsMap.get(id).getTasks().values()) {
String tid = MRApps.toString(task.getID());
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("jobs").path(jobId).path("tasks").path(tid).path("attempts")
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks")
+ .path(tid).path("attempts").request(MediaType.APPLICATION_JSON).get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
verifyAMTaskAttempts(json, task);
}
}
@@ -138,19 +133,20 @@ public void testTaskAttempts() throws JSONException, Exception {
@Test
public void testTaskAttemptsSlash() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
for (Task task : jobsMap.get(id).getTasks().values()) {
String tid = MRApps.toString(task.getID());
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("jobs").path(jobId).path("tasks").path(tid).path("attempts/")
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks")
+ .path(tid).path("attempts/").request(MediaType.APPLICATION_JSON)
+ .get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
verifyAMTaskAttempts(json, task);
}
}
@@ -158,19 +154,19 @@ public void testTaskAttemptsSlash() throws JSONException, Exception {
@Test
public void testTaskAttemptsDefault() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
for (Task task : jobsMap.get(id).getTasks().values()) {
String tid = MRApps.toString(task.getID());
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("jobs").path(jobId).path("tasks").path(tid).path("attempts")
- .get(ClientResponse.class);
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks")
+ .path(tid).path("attempts").request().get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
verifyAMTaskAttempts(json, task);
}
}
@@ -178,20 +174,20 @@ public void testTaskAttemptsDefault() throws JSONException, Exception {
@Test
public void testTaskAttemptsXML() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
for (Task task : jobsMap.get(id).getTasks().values()) {
String tid = MRApps.toString(task.getID());
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("jobs").path(jobId).path("tasks").path(tid).path("attempts")
- .accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks")
+ .path(tid).path("attempts").request(MediaType.APPLICATION_XML).get(Response.class);
assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- String xml = response.getEntity(String.class);
+ response.getMediaType().toString());
+ String xml = response.readEntity(String.class);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
@@ -208,7 +204,7 @@ public void testTaskAttemptsXML() throws JSONException, Exception {
@Test
public void testTaskAttemptId() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
@@ -221,13 +217,13 @@ public void testTaskAttemptId() throws JSONException, Exception {
TaskAttemptId attemptid = att.getID();
String attid = MRApps.toString(attemptid);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("jobs").path(jobId).path("tasks").path(tid)
- .path("attempts").path(attid).accept(MediaType.APPLICATION_JSON)
- .get(ClientResponse.class);
- assertEquals(MediaType.APPLICATION_JSON_TYPE + "; "
- + JettyUtils.UTF_8, response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks")
+ .path(tid).path("attempts").path(attid).request(MediaType.APPLICATION_JSON)
+ .get(Response.class);
+ assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("taskAttempt");
verifyAMTaskAttempt(info, att, task.getType());
@@ -238,7 +234,7 @@ public void testTaskAttemptId() throws JSONException, Exception {
@Test
public void testTaskAttemptIdSlash() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
@@ -251,13 +247,13 @@ public void testTaskAttemptIdSlash() throws JSONException, Exception {
TaskAttemptId attemptid = att.getID();
String attid = MRApps.toString(attemptid);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("jobs").path(jobId).path("tasks").path(tid)
- .path("attempts").path(attid + "/")
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
- assertEquals(MediaType.APPLICATION_JSON_TYPE + "; "
- + JettyUtils.UTF_8, response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks")
+ .path(tid).path("attempts").path(attid + "/").request(MediaType.APPLICATION_JSON)
+ .get(Response.class);
+ assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("taskAttempt");
verifyAMTaskAttempt(info, att, task.getType());
@@ -268,7 +264,7 @@ public void testTaskAttemptIdSlash() throws JSONException, Exception {
@Test
public void testTaskAttemptIdDefault() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
@@ -281,12 +277,12 @@ public void testTaskAttemptIdDefault() throws JSONException, Exception {
TaskAttemptId attemptid = att.getID();
String attid = MRApps.toString(attemptid);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("jobs").path(jobId).path("tasks").path(tid)
- .path("attempts").path(attid).get(ClientResponse.class);
- assertEquals(MediaType.APPLICATION_JSON_TYPE + "; "
- + JettyUtils.UTF_8, response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks")
+ .path(tid).path("attempts").path(attid).request().get(Response.class);
+ assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("taskAttempt");
verifyAMTaskAttempt(info, att, task.getType());
@@ -297,7 +293,7 @@ public void testTaskAttemptIdDefault() throws JSONException, Exception {
@Test
public void testTaskAttemptIdXML() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
@@ -308,14 +304,14 @@ public void testTaskAttemptIdXML() throws JSONException, Exception {
TaskAttemptId attemptid = att.getID();
String attid = MRApps.toString(attemptid);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("jobs").path(jobId).path("tasks").path(tid)
- .path("attempts").path(attid).accept(MediaType.APPLICATION_XML)
- .get(ClientResponse.class);
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("tasks")
+ .path(tid).path("attempts").path(attid).request(MediaType.APPLICATION_XML)
+ .get(Response.class);
assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- String xml = response.getEntity(String.class);
+ response.getMediaType().toString());
+ String xml = response.readEntity(String.class);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
@@ -369,7 +365,7 @@ public void testTaskAttemptIdInvalid3() throws JSONException, Exception {
private void testTaskAttemptIdErrorGeneric(String attid, String error)
throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
@@ -381,14 +377,14 @@ private void testTaskAttemptIdErrorGeneric(String attid, String error)
try {
r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId)
.path("tasks").path(tid).path("attempts").path(attid)
- .accept(MediaType.APPLICATION_JSON).get(JSONObject.class);
+ .request(MediaType.APPLICATION_JSON).get(JSONObject.class);
fail("should have thrown exception on invalid uri");
- } catch (UniformInterfaceException ue) {
- ClientResponse response = ue.getResponse();
- assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
+ } catch (WebApplicationException ue) {
+ Response response = ue.getResponse();
+ assertResponseStatusCode(Response.Status.NOT_FOUND, response.getStatusInfo());
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; "
- + JettyUtils.UTF_8, response.getType().toString());
- JSONObject msg = response.getEntity(JSONObject.class);
+ + JettyUtils.UTF_8, response.getMediaType().toString());
+ JSONObject msg = response.readEntity(JSONObject.class);
JSONObject exception = msg.getJSONObject("RemoteException");
assertEquals("incorrect number of elements", 3, exception.length());
String message = exception.getString("message");
@@ -551,7 +547,7 @@ public void verifyReduceTaskAttemptGeneric(TaskAttempt ta,
@Test
public void testTaskAttemptIdCounters() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
@@ -564,13 +560,13 @@ public void testTaskAttemptIdCounters() throws JSONException, Exception {
TaskAttemptId attemptid = att.getID();
String attid = MRApps.toString(attemptid);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks").path(tid)
.path("attempts").path(attid).path("counters")
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ .request(MediaType.APPLICATION_JSON).get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; "
- + JettyUtils.UTF_8, response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ + JettyUtils.UTF_8, response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("jobTaskAttemptCounters");
verifyAMJobTaskAttemptCounters(info, att);
@@ -581,7 +577,7 @@ public void testTaskAttemptIdCounters() throws JSONException, Exception {
@Test
public void testTaskAttemptIdXMLCounters() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
@@ -592,14 +588,14 @@ public void testTaskAttemptIdXMLCounters() throws JSONException, Exception {
TaskAttemptId attemptid = att.getID();
String attid = MRApps.toString(attemptid);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks").path(tid)
.path("attempts").path(attid).path("counters")
- .accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
+ .request(MediaType.APPLICATION_XML).get(Response.class);
assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- String xml = response.getEntity(String.class);
+ response.getMediaType().toString());
+ String xml = response.readEntity(String.class);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesJobConf.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesJobConf.java
index ee7bb0e3c27dd..69698546deaa9 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesJobConf.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesJobConf.java
@@ -29,7 +29,9 @@
import java.io.StringReader;
import java.util.Map;
+import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -46,11 +48,14 @@
import org.apache.hadoop.mapreduce.v2.util.MRApps;
import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
import org.apache.hadoop.yarn.webapp.GuiceServletConfig;
-import org.apache.hadoop.yarn.webapp.JerseyTestBase;
import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
+
+import com.google.inject.Scopes;
+import com.google.inject.servlet.GuiceFilter;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
+import org.glassfish.jersey.test.JerseyTest;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
@@ -61,10 +66,6 @@
import com.google.inject.Guice;
import com.google.inject.servlet.ServletModule;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
-import com.sun.jersey.test.framework.WebAppDescriptor;
/**
* Test the app master web service Rest API for getting the job conf. This
@@ -72,7 +73,7 @@
*
* /ws/v1/mapreduce/job/{jobid}/conf
*/
-public class TestAMWebServicesJobConf extends JerseyTestBase {
+public class TestAMWebServicesJobConf extends JerseyTest {
private static Configuration conf = new Configuration();
private static AppContext appContext;
@@ -116,7 +117,7 @@ protected void configureServlets() {
bind(AppContext.class).toInstance(appContext);
bind(Configuration.class).toInstance(conf);
- serve("/*").with(GuiceContainer.class);
+ bind(GuiceFilter.class).in(Scopes.SINGLETON);
}
};
@@ -140,26 +141,21 @@ static public void stop() {
}
public TestAMWebServicesJobConf() {
- super(new WebAppDescriptor.Builder(
- "org.apache.hadoop.mapreduce.v2.app.webapp")
- .contextListenerClass(GuiceServletConfig.class)
- .filterClass(com.google.inject.servlet.GuiceFilter.class)
- .contextPath("jersey-guice-filter").servletPath("/").build());
}
@Test
public void testJobConf() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("jobs").path(jobId).path("conf")
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("conf")
+ .request(MediaType.APPLICATION_JSON).get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("conf");
verifyAMJobConf(info, jobsMap.get(id));
@@ -168,17 +164,17 @@ public void testJobConf() throws JSONException, Exception {
@Test
public void testJobConfSlash() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("jobs").path(jobId).path("conf/")
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("conf/")
+ .request(MediaType.APPLICATION_JSON).get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("conf");
verifyAMJobConf(info, jobsMap.get(id));
@@ -187,16 +183,17 @@ public void testJobConfSlash() throws JSONException, Exception {
@Test
public void testJobConfDefault() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("jobs").path(jobId).path("conf").get(ClientResponse.class);
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("conf").request()
+ .get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("conf");
verifyAMJobConf(info, jobsMap.get(id));
@@ -205,17 +202,17 @@ public void testJobConfDefault() throws JSONException, Exception {
@Test
public void testJobConfXML() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("jobs").path(jobId).path("conf")
- .accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
+ Response response =
+ r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId).path("conf")
+ .request(MediaType.APPLICATION_XML).get(Response.class);
assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- String xml = response.getEntity(String.class);
+ response.getMediaType().toString());
+ String xml = response.readEntity(String.class);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesTasks.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesTasks.java
index ab4d818f33868..0ac5fd26bb44f 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesTasks.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebServicesTasks.java
@@ -27,7 +27,11 @@
import java.io.StringReader;
import java.util.Map;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -44,11 +48,14 @@
import org.apache.hadoop.mapreduce.v2.util.MRApps;
import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
import org.apache.hadoop.yarn.webapp.GuiceServletConfig;
-import org.apache.hadoop.yarn.webapp.JerseyTestBase;
import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
+
+import com.google.inject.Scopes;
+import com.google.inject.servlet.GuiceFilter;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
+import org.glassfish.jersey.test.JerseyTest;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
@@ -58,12 +65,6 @@
import com.google.inject.Guice;
import com.google.inject.servlet.ServletModule;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.ClientResponse.Status;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
-import com.sun.jersey.test.framework.WebAppDescriptor;
/**
* Test the app master web service Rest API for getting tasks, a specific task,
@@ -73,7 +74,7 @@
* /ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}
* /ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}/counters
*/
-public class TestAMWebServicesTasks extends JerseyTestBase {
+public class TestAMWebServicesTasks extends JerseyTest {
private static Configuration conf = new Configuration();
private static AppContext appContext;
@@ -89,7 +90,7 @@ protected void configureServlets() {
bind(AppContext.class).toInstance(appContext);
bind(Configuration.class).toInstance(conf);
- serve("/*").with(GuiceContainer.class);
+ bind(GuiceFilter.class).in(Scopes.SINGLETON);
}
}
@@ -107,25 +108,20 @@ public void setUp() throws Exception {
}
public TestAMWebServicesTasks() {
- super(new WebAppDescriptor.Builder(
- "org.apache.hadoop.mapreduce.v2.app.webapp")
- .contextListenerClass(GuiceServletConfig.class)
- .filterClass(com.google.inject.servlet.GuiceFilter.class)
- .contextPath("jersey-guice-filter").servletPath("/").build());
}
@Test
public void testTasks() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks")
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ .request(MediaType.APPLICATION_JSON).get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject tasks = json.getJSONObject("tasks");
JSONArray arr = tasks.getJSONArray("task");
@@ -137,15 +133,15 @@ public void testTasks() throws JSONException, Exception {
@Test
public void testTasksDefault() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
- .path("jobs").path(jobId).path("tasks").get(ClientResponse.class);
+ Response response = r.path("ws").path("v1").path("mapreduce")
+ .path("jobs").path(jobId).path("tasks").request().get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject tasks = json.getJSONObject("tasks");
JSONArray arr = tasks.getJSONArray("task");
@@ -157,16 +153,16 @@ public void testTasksDefault() throws JSONException, Exception {
@Test
public void testTasksSlash() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks/")
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ .request(MediaType.APPLICATION_JSON).get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject tasks = json.getJSONObject("tasks");
JSONArray arr = tasks.getJSONArray("task");
@@ -179,16 +175,16 @@ public void testTasksSlash() throws JSONException, Exception {
@Test
public void testTasksXML() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks")
- .accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
+ .request(MediaType.APPLICATION_XML).get(Response.class);
assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- String xml = response.getEntity(String.class);
+ response.getMediaType().toString());
+ String xml = response.readEntity(String.class);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
@@ -203,17 +199,17 @@ public void testTasksXML() throws JSONException, Exception {
@Test
public void testTasksQueryMap() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
String type = "m";
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks").queryParam("type", type)
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ .request(MediaType.APPLICATION_JSON).get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject tasks = json.getJSONObject("tasks");
JSONArray arr = tasks.getJSONArray("task");
@@ -224,17 +220,17 @@ public void testTasksQueryMap() throws JSONException, Exception {
@Test
public void testTasksQueryReduce() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
String type = "r";
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks").queryParam("type", type)
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ .request(MediaType.APPLICATION_JSON).get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject tasks = json.getJSONObject("tasks");
JSONArray arr = tasks.getJSONArray("task");
@@ -245,7 +241,7 @@ public void testTasksQueryReduce() throws JSONException, Exception {
@Test
public void testTasksQueryInvalid() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
@@ -255,14 +251,14 @@ public void testTasksQueryInvalid() throws JSONException, Exception {
try {
r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId)
.path("tasks").queryParam("type", tasktype)
- .accept(MediaType.APPLICATION_JSON).get(JSONObject.class);
+ .request(MediaType.APPLICATION_JSON).get(JSONObject.class);
fail("should have thrown exception on invalid uri");
- } catch (UniformInterfaceException ue) {
- ClientResponse response = ue.getResponse();
+ } catch (WebApplicationException ue) {
+ Response response = ue.getResponse();
assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo());
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject msg = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject msg = response.readEntity(JSONObject.class);
JSONObject exception = msg.getJSONObject("RemoteException");
assertEquals("incorrect number of elements", 3, exception.length());
String message = exception.getString("message");
@@ -280,19 +276,19 @@ public void testTasksQueryInvalid() throws JSONException, Exception {
@Test
public void testTaskId() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
for (Task task : jobsMap.get(id).getTasks().values()) {
String tid = MRApps.toString(task.getID());
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks").path(tid)
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ .request(MediaType.APPLICATION_JSON).get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("task");
verifyAMSingleTask(info, task);
@@ -302,19 +298,19 @@ public void testTaskId() throws JSONException, Exception {
@Test
public void testTaskIdSlash() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
for (Task task : jobsMap.get(id).getTasks().values()) {
String tid = MRApps.toString(task.getID());
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks").path(tid + "/")
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ .request(MediaType.APPLICATION_JSON).get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("task");
verifyAMSingleTask(info, task);
@@ -324,19 +320,19 @@ public void testTaskIdSlash() throws JSONException, Exception {
@Test
public void testTaskIdDefault() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
for (Task task : jobsMap.get(id).getTasks().values()) {
String tid = MRApps.toString(task.getID());
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks").path(tid)
- .get(ClientResponse.class);
+ .request().get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("task");
verifyAMSingleTask(info, task);
@@ -346,21 +342,21 @@ public void testTaskIdDefault() throws JSONException, Exception {
@Test
public void testTaskIdBogus() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
String tid = "bogustaskid";
try {
r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId)
- .path("tasks").path(tid).get(JSONObject.class);
+ .path("tasks").path(tid).request().get(JSONObject.class);
fail("should have thrown exception on invalid uri");
- } catch (UniformInterfaceException ue) {
- ClientResponse response = ue.getResponse();
+ } catch (WebApplicationException ue) {
+ Response response = ue.getResponse();
assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject msg = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject msg = response.readEntity(JSONObject.class);
JSONObject exception = msg.getJSONObject("RemoteException");
assertEquals("incorrect number of elements", 3, exception.length());
String message = exception.getString("message");
@@ -381,21 +377,21 @@ public void testTaskIdBogus() throws JSONException, Exception {
@Test
public void testTaskIdNonExist() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
String tid = "task_0_0000_m_000000";
try {
r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId)
- .path("tasks").path(tid).get(JSONObject.class);
+ .path("tasks").path(tid).request().get(JSONObject.class);
fail("should have thrown exception on invalid uri");
- } catch (UniformInterfaceException ue) {
- ClientResponse response = ue.getResponse();
+ } catch (WebApplicationException ue) {
+ Response response = ue.getResponse();
assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject msg = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject msg = response.readEntity(JSONObject.class);
JSONObject exception = msg.getJSONObject("RemoteException");
assertEquals("incorrect number of elements", 3, exception.length());
String message = exception.getString("message");
@@ -414,21 +410,21 @@ public void testTaskIdNonExist() throws JSONException, Exception {
@Test
public void testTaskIdInvalid() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
String tid = "task_0_0000_d_000000";
try {
r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId)
- .path("tasks").path(tid).get(JSONObject.class);
+ .path("tasks").path(tid).request().get(JSONObject.class);
fail("should have thrown exception on invalid uri");
- } catch (UniformInterfaceException ue) {
- ClientResponse response = ue.getResponse();
+ } catch (WebApplicationException ue) {
+ Response response = ue.getResponse();
assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject msg = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject msg = response.readEntity(JSONObject.class);
JSONObject exception = msg.getJSONObject("RemoteException");
assertEquals("incorrect number of elements", 3, exception.length());
String message = exception.getString("message");
@@ -449,21 +445,21 @@ public void testTaskIdInvalid() throws JSONException, Exception {
@Test
public void testTaskIdInvalid2() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
String tid = "task_0_m_000000";
try {
r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId)
- .path("tasks").path(tid).get(JSONObject.class);
+ .path("tasks").path(tid).request().get(JSONObject.class);
fail("should have thrown exception on invalid uri");
- } catch (UniformInterfaceException ue) {
- ClientResponse response = ue.getResponse();
+ } catch (WebApplicationException ue) {
+ Response response = ue.getResponse();
assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject msg = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject msg = response.readEntity(JSONObject.class);
JSONObject exception = msg.getJSONObject("RemoteException");
assertEquals("incorrect number of elements", 3, exception.length());
String message = exception.getString("message");
@@ -484,21 +480,21 @@ public void testTaskIdInvalid2() throws JSONException, Exception {
@Test
public void testTaskIdInvalid3() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
String tid = "task_0_0000_m";
try {
r.path("ws").path("v1").path("mapreduce").path("jobs").path(jobId)
- .path("tasks").path(tid).get(JSONObject.class);
+ .path("tasks").path(tid).request().get(JSONObject.class);
fail("should have thrown exception on invalid uri");
- } catch (UniformInterfaceException ue) {
- ClientResponse response = ue.getResponse();
+ } catch (WebApplicationException ue) {
+ Response response = ue.getResponse();
assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject msg = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject msg = response.readEntity(JSONObject.class);
JSONObject exception = msg.getJSONObject("RemoteException");
assertEquals("incorrect number of elements", 3, exception.length());
String message = exception.getString("message");
@@ -519,20 +515,20 @@ public void testTaskIdInvalid3() throws JSONException, Exception {
@Test
public void testTaskIdXML() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
for (Task task : jobsMap.get(id).getTasks().values()) {
String tid = MRApps.toString(task.getID());
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks").path(tid)
- .accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
+ .request(MediaType.APPLICATION_XML).get(Response.class);
assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- String xml = response.getEntity(String.class);
+ response.getMediaType().toString());
+ String xml = response.readEntity(String.class);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
@@ -634,19 +630,19 @@ public void verifyAMTaskXML(NodeList nodes, Job job) {
@Test
public void testTaskIdCounters() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
for (Task task : jobsMap.get(id).getTasks().values()) {
String tid = MRApps.toString(task.getID());
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks").path(tid).path("counters")
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ .request(MediaType.APPLICATION_JSON).get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("jobTaskCounters");
verifyAMJobTaskCounters(info, task);
@@ -656,19 +652,19 @@ public void testTaskIdCounters() throws JSONException, Exception {
@Test
public void testTaskIdCountersSlash() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
for (Task task : jobsMap.get(id).getTasks().values()) {
String tid = MRApps.toString(task.getID());
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks").path(tid).path("counters/")
- .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+ .request(MediaType.APPLICATION_JSON).get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("jobTaskCounters");
verifyAMJobTaskCounters(info, task);
@@ -678,19 +674,19 @@ public void testTaskIdCountersSlash() throws JSONException, Exception {
@Test
public void testTaskIdCountersDefault() throws JSONException, Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
for (Task task : jobsMap.get(id).getTasks().values()) {
String tid = MRApps.toString(task.getID());
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks").path(tid).path("counters")
- .get(ClientResponse.class);
+ .request().get(Response.class);
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- JSONObject json = response.getEntity(JSONObject.class);
+ response.getMediaType().toString());
+ JSONObject json = response.readEntity(JSONObject.class);
assertEquals("incorrect number of elements", 1, json.length());
JSONObject info = json.getJSONObject("jobTaskCounters");
verifyAMJobTaskCounters(info, task);
@@ -700,19 +696,19 @@ public void testTaskIdCountersDefault() throws JSONException, Exception {
@Test
public void testJobTaskCountersXML() throws Exception {
- WebResource r = resource();
+ WebTarget r = target();
Map jobsMap = appContext.getAllJobs();
for (JobId id : jobsMap.keySet()) {
String jobId = MRApps.toString(id);
for (Task task : jobsMap.get(id).getTasks().values()) {
String tid = MRApps.toString(task.getID());
- ClientResponse response = r.path("ws").path("v1").path("mapreduce")
+ Response response = r.path("ws").path("v1").path("mapreduce")
.path("jobs").path(jobId).path("tasks").path(tid).path("counters")
- .accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
+ .request(MediaType.APPLICATION_XML).get(Response.class);
assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8,
- response.getType().toString());
- String xml = response.getEntity(String.class);
+ response.getMediaType().toString());
+ String xml = response.readEntity(String.class);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/JAXBContextResolver.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/JAXBContextResolver.java
index ad1c7a9fad2a0..0368f6a1dca57 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/JAXBContextResolver.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/JAXBContextResolver.java
@@ -19,8 +19,7 @@
package org.apache.hadoop.mapreduce.v2.hs.webapp;
import com.google.inject.Singleton;
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.api.json.JSONJAXBContext;
+import org.glassfish.jersey.jettison.JettisonJaxbContext;
import java.util.Arrays;
import java.util.HashSet;
@@ -69,9 +68,8 @@ public class JAXBContextResolver implements ContextResolver {
RemoteExceptionData.class };
public JAXBContextResolver() throws Exception {
- this.types = new HashSet(Arrays.asList(cTypes));
- this.context = new JSONJAXBContext(JSONConfiguration.natural()
- .rootUnwrapping(false).build(), cTypes);
+ this.types = new HashSet<>(Arrays.asList(cTypes));
+ this.context = new JettisonJaxbContext(cTypes);
}
@Override
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/pom.xml b/hadoop-mapreduce-project/hadoop-mapreduce-client/pom.xml
index b394fe5be18ef..487cb873e9d3a 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/pom.xml
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/pom.xml
@@ -74,6 +74,10 @@
+
+ javax.ws.rs
+ javax.ws.rs-api
+
org.apache.hadoop
hadoop-common
@@ -157,11 +161,6 @@
commons-collections
provided
-
- com.sun.jersey.jersey-test-framework
- jersey-test-framework-grizzly2
- test
-
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/pom.xml b/hadoop-mapreduce-project/hadoop-mapreduce-examples/pom.xml
index 11932e04e3784..15b21e542de07 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/pom.xml
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/pom.xml
@@ -98,11 +98,6 @@
test-jar
test
-
- com.sun.jersey.jersey-test-framework
- jersey-test-framework-grizzly2
- test
-
org.apache.hadoop
hadoop-mapreduce-client-hs
diff --git a/hadoop-mapreduce-project/pom.xml b/hadoop-mapreduce-project/pom.xml
index 3ce66a10a84f7..52db98456517a 100644
--- a/hadoop-mapreduce-project/pom.xml
+++ b/hadoop-mapreduce-project/pom.xml
@@ -118,14 +118,6 @@
com.google.inject
guice
-
- com.sun.jersey
- jersey-server
-
-
- com.sun.jersey.contribs
- jersey-guice
-
com.google.inject.extensions
guice-servlet
diff --git a/hadoop-project/pom.xml b/hadoop-project/pom.xml
index 2caad449b5cbf..a2d478581b92f 100644
--- a/hadoop-project/pom.xml
+++ b/hadoop-project/pom.xml
@@ -66,11 +66,16 @@
1.9.2
- 1.19.4
+ 2.36
+
+ 2.4.4
- 2.12.7
- 2.12.7
+ 2.13.2
+ 2.13.2.2
+
+
+ 2.1.1
4.5.13
@@ -137,7 +142,6 @@
1.4.10
2.0.6.1
5.2.0
- 2.2.21
2.9.0
3.2.4
3.10.6.Final
@@ -795,8 +799,8 @@
javax.ws.rs
- jsr311-api
- 1.1.1
+ javax.ws.rs-api
+ ${javax.ws.rs-api.version}
org.eclipse.jetty
@@ -882,44 +886,99 @@
43.0
- com.sun.jersey
- jersey-core
- ${jersey.version}
-
-
- org.osgi
- org.osgi.core
-
-
+ org.glassfish.jersey.core
+ jersey-common
+ ${jersey2.version}
+
+
+ org.glassfish.jersey.core
+ jersey-server
+ ${jersey2.version}
- com.sun.jersey
- jersey-servlet
- ${jersey.version}
+ org.glassfish.jersey.core
+ jersey-client
+ ${jersey2.version}
- com.github.pjfanning
- jersey-json
- 1.20
+ org.glassfish.jersey.containers
+ jersey-container-servlet-core
+ ${jersey2.version}
+
+
+ org.glassfish.jersey.inject
+ jersey-hk2
+ ${jersey2.version}
+
+
+ org.glassfish.jersey.media
+ jersey-media-json-jackson
+ ${jersey2.version}
+
+
+ org.glassfish.jersey.media
+ jersey-media-json-jettison
+ ${jersey2.version}
+
+
+ org.glassfish.jersey.test-framework
+ jersey-test-framework-core
+ ${jersey2.version}
- com.fasterxml.jackson.core
- jackson-core
-
-
- com.fasterxml.jackson.core
- jackson-databind
+ com.google.inject
+ guice
+
+
+
+ org.glassfish.jersey.test-framework.providers
+ jersey-test-framework-provider-grizzly2
+ ${jersey2.version}
+
- com.fasterxml.jackson.jaxrs
- jackson-jaxrs-json-provider
+ com.google.inject
+ guice
- com.sun.jersey
- jersey-server
- ${jersey.version}
+ org.glassfish.hk2
+ guice-bridge
+ 2.6.1
+
+
+ jakarta.annotation
+ jakarta.annotation-api
+ 1.3.5
+
+
+ net.jodah
+ failsafe
+ 2.4.4
+
+
+ org.javassist
+ javassist
+ 3.29.0-GA
+
+
+ org.glassfish.grizzly
+ grizzly-http-servlet
+ ${grizzly.version}
+ test
+
+
+ org.glassfish.grizzly
+ grizzly-http
+ ${grizzly.version}
+ test
+
+
+ org.glassfish.grizzly
+ grizzly-http-server
+ ${grizzly.version}
+ test
@@ -940,37 +999,6 @@
${guice.version}
-
- com.sun.jersey.contribs
- jersey-guice
- ${jersey.version}
-
-
-
- com.sun.jersey.jersey-test-framework
- jersey-test-framework-core
- ${jersey.version}
- test
-
-
- javax.servlet
- javax.servlet-api
-
-
-
-
- com.sun.jersey.jersey-test-framework
- jersey-test-framework-grizzly2
- ${jersey.version}
-
-
- javax.servlet
- javax.servlet-api
-
-
-
-
-
io.netty
netty
@@ -1506,27 +1534,6 @@
-
- com.sun.jersey
- jersey-client
- ${jersey.version}
-
-
-
- org.glassfish.grizzly
- grizzly-http-servlet
- ${grizzly.version}
-
-
- org.glassfish.grizzly
- grizzly-http
- ${grizzly.version}
-
-
- org.glassfish.grizzly
- grizzly-http-server
- ${grizzly.version}
-
${leveldbjni.group}
@@ -1868,6 +1875,10 @@
org.osgi
org.osgi.core
+
+ javax.ws.rs
+ jsr311-api
+
diff --git a/hadoop-tools/hadoop-azure/pom.xml b/hadoop-tools/hadoop-azure/pom.xml
index 40aeec07026cc..ebb38237e4084 100644
--- a/hadoop-tools/hadoop-azure/pom.xml
+++ b/hadoop-tools/hadoop-azure/pom.xml
@@ -301,7 +301,7 @@
javax.ws.rs
- jsr311-api
+ javax.ws.rs-api
test
diff --git a/hadoop-tools/hadoop-resourceestimator/pom.xml b/hadoop-tools/hadoop-resourceestimator/pom.xml
index 89e248f9a7efe..c46d7f22f6b56 100644
--- a/hadoop-tools/hadoop-resourceestimator/pom.xml
+++ b/hadoop-tools/hadoop-resourceestimator/pom.xml
@@ -65,37 +65,10 @@
javax.inject
1
-
- com.sun.jersey.jersey-test-framework
- jersey-test-framework-grizzly2
- test
-
javax.servlet
javax.servlet-api
-
- com.sun.jersey
- jersey-server
-
-
- com.github.pjfanning
- jersey-json
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
- com.fasterxml.jackson.jaxrs
- jackson-jaxrs-json-provider
-
-
-
junit
junit
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
index 61747c2cd8028..6e7c27a23ea85 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
@@ -115,6 +115,10 @@
com.fasterxml.jackson.core
jackson-annotations
+
+ javax.ws.rs
+ javax.ws.rs-api
+
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 21b3172a59f22..e49083f43fcd0 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
@@ -77,7 +77,6 @@
org.glassfish.jersey.media
jersey-media-json-jackson
- 2.12
test
@@ -91,25 +90,6 @@
-
- com.github.pjfanning
- jersey-json
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
- com.fasterxml.jackson.jaxrs
- jackson-jaxrs-json-provider
-
-
-
-
org.apache.solr
solr-solrj
@@ -261,6 +241,11 @@
jackson-jaxrs-base
${jackson2.version}
+
+
+ javax.ws.rs
+ javax.ws.rs-api
+
${artifact.name}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/pom.xml
index d1cd362c7d65d..7e468bc75684e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/pom.xml
@@ -166,6 +166,10 @@
+
+ javax.ws.rs
+ javax.ws.rs-api
+
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDSTimelineV10.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDSTimelineV10.java
index 15dc1cb04ee4a..cd5db0eab9f6e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDSTimelineV10.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDSTimelineV10.java
@@ -30,6 +30,7 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
+import net.jodah.failsafe.RetryPolicy;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
@@ -521,10 +522,10 @@ public void testDSTimelineClientWithConnectionRefuse() throws Exception {
TimelineClientImpl client = new TimelineClientImpl() {
@Override
protected TimelineWriter createTimelineWriter(Configuration conf,
- UserGroupInformation authUgi, com.sun.jersey.api.client.Client client,
- URI resURI) throws IOException {
+ UserGroupInformation authUgi, javax.ws.rs.client.Client client,
+ URI resURI, RetryPolicy