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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
import static org.apache.hadoop.hdds.ratis.RatisHelper.HDDS_DATANODE_RATIS_PREFIX_KEY;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_CONTAINER_COPY_WORKDIR;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -39,13 +46,6 @@
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdds.HddsConfigKeys;
import org.apache.hadoop.hdds.annotation.InterfaceAudience;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
16 changes: 11 additions & 5 deletions hadoop-hdds/framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,17 @@
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
</dependency>
<dependency>
<!-- Retained for the javax->jakarta servlet bridge and the hadoop-auth
based filters that still extend javax.servlet base classes. -->
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
Expand Down Expand Up @@ -228,15 +234,15 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<artifactId>jetty-util</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-webapp</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@

import static org.apache.hadoop.hdds.conf.OzoneConfiguration.getConfigurationResourceFiles;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.lang3.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

package org.apache.hadoop.hdds.server.http;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.ee10.servlet.DefaultServlet;

/**
* General servlet which is admin-authorized.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_SERVER_HTTPS_TRUSTSTORE_PASSWORD_KEY;

import com.google.common.annotations.VisibleForTesting;
import jakarta.servlet.http.HttpServlet;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.URI;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;
import javax.servlet.http.HttpServlet;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdds.HddsConfigKeys;
Expand All @@ -57,7 +58,7 @@
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authorize.AccessControlList;
import org.apache.hadoop.security.ssl.SSLFactory;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.ee10.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -69,8 +70,6 @@ public abstract class BaseHttpServer implements AutoCloseable {
private static final Logger LOG =
LoggerFactory.getLogger(BaseHttpServer.class);
static final String PROMETHEUS_SINK = "PROMETHEUS_SINK";
private static final String JETTY_BASETMPDIR =
"org.eclipse.jetty.webapp.basetempdir";
public static final String SERVER_DIR = "/webserver";

private HttpServer2 httpServer;
Expand All @@ -85,6 +84,7 @@ public abstract class BaseHttpServer implements AutoCloseable {
private PrometheusMetricsSink prometheusMetricsSink;

private boolean prometheusSupport;
private String jettyBaseTmpDir;

public BaseHttpServer(MutableConfigurationSource conf, String name)
throws IOException {
Expand Down Expand Up @@ -140,6 +140,8 @@ public BaseHttpServer(MutableConfigurationSource conf, String name)
builder.withoutDefaultApps();
}

builder.allowAmbiguousUri(shouldAllowAmbiguousUri());

httpServer = builder.build();

// TODO move these to HttpServer2.addDefaultApps
Expand Down Expand Up @@ -190,15 +192,20 @@ public BaseHttpServer(MutableConfigurationSource conf, String name)
baseDir = getOzoneMetaDirPath(conf) + SERVER_DIR;
}
createDir(baseDir);
httpServer.getWebAppContext().setAttribute(JETTY_BASETMPDIR, baseDir);
WebAppContext webAppContext = httpServer.getWebAppContext();
webAppContext.setTempDirectory(new File(baseDir));
// Jetty 12 deletes a non-persistent temp directory on stop. baseDir lives
// under the Ozone metadata directory, so keep it persistent to avoid
// deleting operator data.
webAppContext.setTempDirectoryPersistent(true);
jettyBaseTmpDir = baseDir;
LOG.info("HTTP server of {} uses base directory {}", name, baseDir);
}
}

@VisibleForTesting
public String getJettyBaseTmpDir() {
return httpServer.getWebAppContext().getAttribute(JETTY_BASETMPDIR)
.toString();
return jettyBaseTmpDir;
}

/**
Expand Down Expand Up @@ -496,4 +503,13 @@ protected boolean shouldAddDefaultApps() {
return true;
}

/**
* Override to accept ambiguous URIs (e.g. empty path segments from "//").
* Needed by the S3 Gateway, whose object keys can contain such sequences
* that Jetty 12 rejects with 400 by default.
*/
protected boolean shouldAllowAmbiguousUri() {
return false;
}

}
Loading