From 9130af3f74a7923fff3f80360ba043ab2c6558a9 Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Wed, 18 Jan 2017 18:11:33 +0900 Subject: [PATCH] HADOOP-13955. Replace deprecated HttpServer2 and SSLFactory constants. Contributed by John Zhuge. --- .../org/apache/hadoop/http/HttpServer2.java | 4 +--- .../security/ssl/FileBasedKeyStoresFactory.java | 2 +- .../apache/hadoop/security/ssl/SSLFactory.java | 17 +++-------------- .../org/apache/hadoop/http/TestHttpServer.java | 2 +- .../apache/hadoop/http/TestSSLHttpServer.java | 2 +- .../server/datanode/web/DatanodeHttpServer.java | 2 +- 6 files changed, 8 insertions(+), 21 deletions(-) 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 6e215923319..06f493b1e63 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 @@ -131,8 +131,6 @@ public final class HttpServer2 implements FilterContainer { static final String FILTER_INITIALIZER_PROPERTY = "hadoop.http.filter.initializers"; - @Deprecated - public static final String HTTP_MAX_THREADS = HTTP_MAX_THREADS_KEY; // The ServletContext attribute where the daemon Configuration // gets stored. @@ -507,7 +505,7 @@ public final class HttpServer2 implements FilterContainer { Preconditions.checkNotNull(webAppContext); - int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1); + int maxThreads = conf.getInt(HTTP_MAX_THREADS_KEY, -1); // If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the // default value (currently 250). diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/FileBasedKeyStoresFactory.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/FileBasedKeyStoresFactory.java index a01d11ab9ca..af8e32c46c4 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/FileBasedKeyStoresFactory.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/FileBasedKeyStoresFactory.java @@ -136,7 +136,7 @@ public class FileBasedKeyStoresFactory implements KeyStoresFactory { boolean requireClientCert = conf.getBoolean(SSLFactory.SSL_REQUIRE_CLIENT_CERT_KEY, - SSLFactory.DEFAULT_SSL_REQUIRE_CLIENT_CERT); + SSLFactory.SSL_REQUIRE_CLIENT_CERT_DEFAULT); // certificate store String keystoreType = diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/SSLFactory.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/SSLFactory.java index cda26a56c5e..d72f9bed437 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/SSLFactory.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/SSLFactory.java @@ -100,22 +100,11 @@ public class SSLFactory implements ConnectionConfigurator { public static final String SSL_SERVER_EXCLUDE_CIPHER_LIST = "ssl.server.exclude.cipher.list"; - @Deprecated - public static final boolean DEFAULT_SSL_REQUIRE_CLIENT_CERT = - SSL_REQUIRE_CLIENT_CERT_DEFAULT; - public static final String SSLCERTIFICATE = IBM_JAVA?"ibmX509":"SunX509"; public static final String KEYSTORES_FACTORY_CLASS_KEY = "hadoop.ssl.keystores.factory.class"; - @Deprecated - public static final String SSL_ENABLED_PROTOCOLS = - SSL_ENABLED_PROTOCOLS_KEY; - @Deprecated - public static final String DEFAULT_SSL_ENABLED_PROTOCOLS = - SSL_ENABLED_PROTOCOLS_DEFAULT; - private Configuration conf; private Mode mode; private boolean requireClientCert; @@ -140,7 +129,7 @@ public class SSLFactory implements ConnectionConfigurator { } this.mode = mode; requireClientCert = conf.getBoolean(SSL_REQUIRE_CLIENT_CERT_KEY, - DEFAULT_SSL_REQUIRE_CLIENT_CERT); + SSL_REQUIRE_CLIENT_CERT_DEFAULT); Configuration sslConf = readSSLConfiguration(mode); Class klass @@ -148,8 +137,8 @@ public class SSLFactory implements ConnectionConfigurator { FileBasedKeyStoresFactory.class, KeyStoresFactory.class); keystoresFactory = ReflectionUtils.newInstance(klass, sslConf); - enabledProtocols = conf.getStrings(SSL_ENABLED_PROTOCOLS, - DEFAULT_SSL_ENABLED_PROTOCOLS); + enabledProtocols = conf.getStrings(SSL_ENABLED_PROTOCOLS_KEY, + SSL_ENABLED_PROTOCOLS_DEFAULT); String excludeCiphersConf = sslConf.get(SSL_SERVER_EXCLUDE_CIPHER_LIST, ""); if (excludeCiphersConf.isEmpty()) { diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java index bac3fbbb5e3..6b87cd8ea39 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java @@ -145,7 +145,7 @@ public class TestHttpServer extends HttpServerFunctionalTest { @BeforeClass public static void setup() throws Exception { Configuration conf = new Configuration(); - conf.setInt(HttpServer2.HTTP_MAX_THREADS, 10); + conf.setInt(HttpServer2.HTTP_MAX_THREADS_KEY, 10); server = createTestServer(conf); server.addServlet("echo", "/echo", EchoServlet.class); server.addServlet("echomap", "/echomap", EchoMapServlet.class); diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestSSLHttpServer.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestSSLHttpServer.java index 49d73d65e13..6eea70975f3 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestSSLHttpServer.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestSSLHttpServer.java @@ -82,7 +82,7 @@ public class TestSSLHttpServer extends HttpServerFunctionalTest { @BeforeClass public static void setup() throws Exception { conf = new Configuration(); - conf.setInt(HttpServer2.HTTP_MAX_THREADS, 10); + conf.setInt(HttpServer2.HTTP_MAX_THREADS_KEY, 10); File base = new File(BASEDIR); FileUtil.fullyDelete(base); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/web/DatanodeHttpServer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/web/DatanodeHttpServer.java index 07b779b491d..74e0916b27e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/web/DatanodeHttpServer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/web/DatanodeHttpServer.java @@ -96,7 +96,7 @@ public class DatanodeHttpServer implements Closeable { this.conf = conf; Configuration confForInfoServer = new Configuration(conf); - confForInfoServer.setInt(HttpServer2.HTTP_MAX_THREADS, 10); + confForInfoServer.setInt(HttpServer2.HTTP_MAX_THREADS_KEY, 10); HttpServer2.Builder builder = new HttpServer2.Builder() .setName("datanode") .setConf(confForInfoServer)