Skip to content

Commit

Permalink
HDDS-11052. HttpFS fails to start when compiled for Java 17 (#6854)
Browse files Browse the repository at this point in the history
Co-authored-by: Akira Ajisaka <aajisaka@apache.org>
  • Loading branch information
adoroszlai and aajisaka authored Jul 10, 2024
1 parent 4d29b6c commit 975a8d8
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 178 deletions.
4 changes: 4 additions & 0 deletions hadoop-hdds/framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>
<dependency>
<artifactId>ratis-server</artifactId>
<groupId>org.apache.ratis</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.sun.jersey.spi.container.servlet.ServletContainer;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.server.Connector;
Expand Down Expand Up @@ -112,6 +111,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;

Expand All @@ -137,17 +138,17 @@ public final class HttpServer2 implements FilterContainer {
public static final String HTTP_SCHEME = "http";
public static final String HTTPS_SCHEME = "https";

private static final String HTTP_MAX_REQUEST_HEADER_SIZE_KEY =
public static final String HTTP_MAX_REQUEST_HEADER_SIZE_KEY =
"hadoop.http.max.request.header.size";
private static final int HTTP_MAX_REQUEST_HEADER_SIZE_DEFAULT = 65536;
private static final String HTTP_MAX_RESPONSE_HEADER_SIZE_KEY =
public static final String HTTP_MAX_RESPONSE_HEADER_SIZE_KEY =
"hadoop.http.max.response.header.size";
private static final int HTTP_MAX_RESPONSE_HEADER_SIZE_DEFAULT = 65536;

private static final String HTTP_SOCKET_BACKLOG_SIZE_KEY =
"hadoop.http.socket.backlog.size";
private static final int HTTP_SOCKET_BACKLOG_SIZE_DEFAULT = 128;
private static final String HTTP_MAX_THREADS_KEY = "hadoop.http.max.threads";
public static final String HTTP_MAX_THREADS_KEY = "hadoop.http.max.threads";
private static final String HTTP_ACCEPTOR_COUNT_KEY =
"hadoop.http.acceptor.count";
// -1 to use default behavior of setting count based on CPU core count
Expand All @@ -171,7 +172,7 @@ public final class HttpServer2 implements FilterContainer {
private static final int HTTP_IDLE_TIMEOUT_MS_DEFAULT = 60000;
private static final String HTTP_TEMP_DIR_KEY = "hadoop.http.temp.dir";

private static final String FILTER_INITIALIZER_PROPERTY
public static final String FILTER_INITIALIZER_PROPERTY
= "ozone.http.filter.initializers";

// The ServletContext attribute where the daemon Configuration
Expand Down Expand Up @@ -836,10 +837,8 @@ public void addJerseyResourcePackage(final String packageName,
final String pathSpec) {
LOG.info("addJerseyResourcePackage: packageName={}, pathSpec={}",
packageName, 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));
webAppContext.addServlet(sh, pathSpec);
}

Expand Down
6 changes: 5 additions & 1 deletion hadoop-hdds/hadoop-dependency-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
</exclusion>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.kerby</groupId>
Expand Down Expand Up @@ -167,6 +167,10 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
<version>${hadoop.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.hadoop.thirdparty</groupId>
<artifactId>hadoop-shaded-guava</artifactId>
Expand Down
3 changes: 0 additions & 3 deletions hadoop-ozone/dist/src/main/license/bin/LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,6 @@ CDDL 1.1 + GPLv2 with classpath exception
com.sun.istack:istack-commons-runtime
com.sun.jersey:jersey-client
com.sun.jersey:jersey-core
com.sun.jersey:jersey-json
com.sun.jersey:jersey-server
com.sun.jersey:jersey-servlet
javax.annotation:javax.annotation-api
javax.el:javax.el-api
javax.interceptor:javax.interceptor-api
Expand Down
2 changes: 0 additions & 2 deletions hadoop-ozone/dist/src/main/license/jar-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ share/ozone/lib/jersey-hk2.jar
share/ozone/lib/jersey-media-jaxb.jar
share/ozone/lib/jersey-media-json-jackson.jar
share/ozone/lib/jersey-server.jar
share/ozone/lib/jersey-server.jar
share/ozone/lib/jersey-servlet.jar
share/ozone/lib/jetty-client.jar
share/ozone/lib/jetty-http.jar
share/ozone/lib/jetty-io.jar
Expand Down
27 changes: 12 additions & 15 deletions hadoop-ozone/httpfsgateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
</properties>

<dependencies>
<dependency>
<groupId>org.apache.ozone</groupId>
<artifactId>hdds-server-framework</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ozone</groupId>
<artifactId>ozone-filesystem-common</artifactId>
Expand All @@ -65,21 +69,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand Down Expand Up @@ -153,6 +142,14 @@
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

package org.apache.ozone.fs.http.server;

import com.sun.jersey.api.container.ContainerException;
import org.apache.hadoop.hdds.annotation.InterfaceAudience;
import org.apache.ozone.lib.service.FileSystemAccessException;
import org.apache.ozone.lib.wsrs.ExceptionProvider;
import org.glassfish.jersey.server.ContainerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,14 @@
import org.apache.ozone.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;

/**
* HttpFS ParametersProvider.
*/
@Provider
@InterfaceAudience.Private
@SuppressWarnings("unchecked")
public class HttpFSParametersProvider extends ParametersProvider {

private static final Map<Enum, Class<Param<?>>[]> PARAMS_DEF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ enum AccessMode {
private static final Logger AUDIT_LOG
= LoggerFactory.getLogger("httpfsaudit");
private static final Logger LOG = LoggerFactory.getLogger(HttpFSServer.class);

private static final HttpFSParametersProvider PARAMETERS_PROVIDER =
new HttpFSParametersProvider();

private Parameters getParams(HttpServletRequest request) {
return PARAMETERS_PROVIDER.get(request);
}

private AccessMode accessMode = AccessMode.READWRITE;

public HttpFSServer() {
Expand Down Expand Up @@ -209,7 +217,6 @@ private void enforceRootPath(HttpFSConstants.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.
*
Expand All @@ -223,10 +230,9 @@ private void enforceRootPath(HttpFSConstants.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) {
Expand All @@ -239,7 +245,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.
*
Expand All @@ -256,7 +261,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,
UnsupportedOperationException {
Expand All @@ -267,6 +271,7 @@ public Response get(@PathParam("path") String path,
return Response.status(Response.Status.FORBIDDEN).build();
}
UserGroupInformation user = HttpUserGroupInformation.get();
final Parameters params = getParams(request);
Response response;
path = makeAbsolute(path);
MDC.put(HttpFSConstants.OP_PARAM, op.value().name());
Expand Down Expand Up @@ -669,7 +674,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.
*
Expand All @@ -684,14 +688,14 @@ 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
if (accessMode == AccessMode.READONLY) {
return Response.status(Response.Status.FORBIDDEN).build();
}
UserGroupInformation user = HttpUserGroupInformation.get();
final Parameters params = getParams(request);
Response response;
path = makeAbsolute(path);
MDC.put(HttpFSConstants.OP_PARAM, op.value().name());
Expand Down Expand Up @@ -746,7 +750,6 @@ private Response handleDelete(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.
*
* @return the request response.
*
Expand All @@ -760,9 +763,9 @@ private Response handleDelete(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);
}

/**
Expand All @@ -772,7 +775,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.
*
Expand All @@ -790,14 +792,14 @@ 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
if (accessMode == AccessMode.READONLY) {
return Response.status(Response.Status.FORBIDDEN).build();
}
UserGroupInformation user = HttpUserGroupInformation.get();
final Parameters params = getParams(request);
Response response;
path = makeAbsolute(path);
MDC.put(HttpFSConstants.OP_PARAM, op.value().name());
Expand Down Expand Up @@ -928,7 +930,6 @@ protected URI createUploadRedirectionURL(UriInfo uriInfo,
* @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.
*
* @return the request response.
*
Expand All @@ -942,9 +943,9 @@ protected URI createUploadRedirectionURL(UriInfo uriInfo,
@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);
}

/**
Expand All @@ -954,7 +955,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.
*
Expand All @@ -972,14 +972,14 @@ 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
if (accessMode == AccessMode.READONLY) {
return Response.status(Response.Status.FORBIDDEN).build();
}
UserGroupInformation user = HttpUserGroupInformation.get();
final Parameters params = getParams(request);
Response response;
path = makeAbsolute(path);
MDC.put(HttpFSConstants.OP_PARAM, op.value().name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdds.annotation.InterfaceAudience;
import org.apache.hadoop.http.HttpServer2;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.server.http.HttpServer2;
import org.apache.hadoop.hdds.utils.LegacyHadoopConfigurationSource;
import org.apache.hadoop.security.AuthenticationFilterInitializer;
import org.apache.hadoop.security.authentication.server.ProxyUserAuthenticationFilterInitializer;
import org.apache.hadoop.security.authorize.AccessControlList;
Expand Down Expand Up @@ -71,7 +73,7 @@ public class HttpFSServerWebServer {
private final HttpServer2 httpServer;
private final String scheme;

HttpFSServerWebServer(Configuration conf, Configuration sslConf) throws
HttpFSServerWebServer(OzoneConfiguration conf, Configuration sslConf) throws
Exception {
// Override configuration with deprecated environment variables.
deprecateEnv("HTTPFS_HTTP_HOSTNAME", conf, HTTP_HOSTNAME_KEY,
Expand Down Expand Up @@ -122,7 +124,7 @@ public class HttpFSServerWebServer {
httpServer = new HttpServer2.Builder()
.setName(NAME)
.setConf(conf)
.setSSLConf(sslConf)
.setSSLConf(new LegacyHadoopConfigurationSource(sslConf))
.authFilterConfigurationPrefix(HttpFSAuthenticationFilter.CONF_PREFIX)
.setACL(new AccessControlList(conf.get(HTTP_ADMINS_KEY, " ")))
.addEndpoint(endpoint)
Expand Down Expand Up @@ -177,7 +179,7 @@ public URL getUrl() {

public static void main(String[] args) throws Exception {
startupShutdownMessage(HttpFSServerWebServer.class, args, LOG);
Configuration conf = new Configuration(true);
OzoneConfiguration conf = new OzoneConfiguration();
Configuration sslConf = SSLFactory.readSSLConfiguration(conf,
SSLFactory.Mode.SERVER);
HttpFSServerWebServer webServer =
Expand Down
Loading

0 comments on commit 975a8d8

Please sign in to comment.