Updated Branches: refs/heads/trunk 9c59a3097 -> 20eed3fdc
FLUME-2200. HTTP Source should use "port" param for both SSL & cleartext (Hari Shreedharan via Mike Percy) Project: http://git-wip-us.apache.org/repos/asf/flume/repo Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/20eed3fd Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/20eed3fd Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/20eed3fd Branch: refs/heads/trunk Commit: 20eed3fdcbee57b84504ec0e1adada46950c4f90 Parents: 9c59a30 Author: Mike Percy <[email protected]> Authored: Tue Oct 8 14:00:31 2013 -0700 Committer: Mike Percy <[email protected]> Committed: Tue Oct 8 14:00:31 2013 -0700 ---------------------------------------------------------------------- .../apache/flume/source/http/HTTPSource.java | 30 ++++++++------------ .../http/HTTPSourceConfigurationConstants.java | 1 - .../flume/source/http/TestHTTPSource.java | 3 +- flume-ng-doc/sphinx/FlumeUserGuide.rst | 1 - 4 files changed, 14 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flume/blob/20eed3fd/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSource.java ---------------------------------------------------------------------- diff --git a/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSource.java b/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSource.java index 84ee33b..de79e8b 100644 --- a/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSource.java +++ b/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSource.java @@ -38,7 +38,6 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -90,7 +89,6 @@ public class HTTPSource extends AbstractSource implements private SourceCounter sourceCounter; // SSL configuration variable - private volatile Integer sslPort; private volatile String keyStorePath; private volatile String keyStorePassword; private volatile Boolean sslEnabled; @@ -108,11 +106,8 @@ public class HTTPSource extends AbstractSource implements Preconditions.checkState(host != null && !host.isEmpty(), "HTTPSource hostname specified is empty"); - // verify port only if its not ssl - if(!sslEnabled) { - Preconditions.checkNotNull(port, "HTTPSource requires a port number to be" - + " specified"); - } + Preconditions.checkNotNull(port, "HTTPSource requires a port number to be" + + " specified"); String handlerClassName = context.getString( HTTPSourceConfigurationConstants.CONFIG_HANDLER, @@ -120,8 +115,6 @@ public class HTTPSource extends AbstractSource implements if(sslEnabled) { LOG.debug("SSL configuration enabled"); - sslPort = context.getInteger(HTTPSourceConfigurationConstants.SSL_PORT); - Preconditions.checkArgument(sslPort != null && sslPort > 0, "SSL Port cannot be null or less than 0" ); keyStorePath = context.getString(HTTPSourceConfigurationConstants.SSL_KEYSTORE); Preconditions.checkArgument(keyStorePath != null && !keyStorePath.isEmpty(), "Keystore is required for SSL Conifguration" ); @@ -129,6 +122,8 @@ public class HTTPSource extends AbstractSource implements Preconditions.checkArgument(keyStorePassword != null, "Keystore password is required for SSL Configuration"); } + + @SuppressWarnings("unchecked") Class<? extends HTTPSourceHandler> clazz = (Class<? extends HTTPSourceHandler>) @@ -163,7 +158,7 @@ public class HTTPSource extends AbstractSource implements + " specified"); } - @Override + @Override public void start() { Preconditions.checkState(srv == null, "Running HTTP Server found in source: " + getName() @@ -175,24 +170,23 @@ public class HTTPSource extends AbstractSource implements Connector[] connectors = new Connector[1]; - if(sslEnabled) { + if (sslEnabled) { SslSocketConnector sslSocketConnector = new SslSocketConnector(); sslSocketConnector.setKeystore(keyStorePath); sslSocketConnector.setKeyPassword(keyStorePassword); - sslSocketConnector.setPort(sslPort); connectors[0] = sslSocketConnector; } else { - SocketConnector connector = new SocketConnector(); - connector.setPort(port); - connector.setHost(host); - connectors[0] = connector; + SocketConnector connector = new SocketConnector(); + connectors[0] = connector; } + connectors[0].setHost(host); + connectors[0].setPort(port); srv.setConnectors(connectors); try { org.mortbay.jetty.servlet.Context root = - new org.mortbay.jetty.servlet.Context( - srv, "/", org.mortbay.jetty.servlet.Context.SESSIONS); + new org.mortbay.jetty.servlet.Context( + srv, "/", org.mortbay.jetty.servlet.Context.SESSIONS); root.addServlet(new ServletHolder(new FlumeHTTPServlet()), "/"); srv.start(); Preconditions.checkArgument(srv.getHandler().equals(root)); http://git-wip-us.apache.org/repos/asf/flume/blob/20eed3fd/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSourceConfigurationConstants.java ---------------------------------------------------------------------- diff --git a/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSourceConfigurationConstants.java b/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSourceConfigurationConstants.java index 205aeab..ed52827 100644 --- a/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSourceConfigurationConstants.java +++ b/flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSourceConfigurationConstants.java @@ -34,7 +34,6 @@ public class HTTPSourceConfigurationConstants { public static final String DEFAULT_HANDLER = "org.apache.flume.source.http.JSONHandler"; - public static final String SSL_PORT = "sslPort"; public static final String SSL_KEYSTORE = "keystore"; public static final String SSL_KEYSTORE_PASSWORD = "keystorePassword"; public static final String SSL_ENABLED = "enableSSL"; http://git-wip-us.apache.org/repos/asf/flume/blob/20eed3fd/flume-ng-core/src/test/java/org/apache/flume/source/http/TestHTTPSource.java ---------------------------------------------------------------------- diff --git a/flume-ng-core/src/test/java/org/apache/flume/source/http/TestHTTPSource.java b/flume-ng-core/src/test/java/org/apache/flume/source/http/TestHTTPSource.java index 9e14648..ab8ec09 100644 --- a/flume-ng-core/src/test/java/org/apache/flume/source/http/TestHTTPSource.java +++ b/flume-ng-core/src/test/java/org/apache/flume/source/http/TestHTTPSource.java @@ -112,7 +112,8 @@ public class TestHTTPSource { Context sslContext = new Context(); sslContext.put(HTTPSourceConfigurationConstants.SSL_ENABLED, "true"); sslPort = findFreePort(); - sslContext.put(HTTPSourceConfigurationConstants.SSL_PORT, String.valueOf(sslPort)); + sslContext.put(HTTPSourceConfigurationConstants.CONFIG_PORT, + String.valueOf(sslPort)); sslContext.put(HTTPSourceConfigurationConstants.SSL_KEYSTORE_PASSWORD, "password"); sslContext.put(HTTPSourceConfigurationConstants.SSL_KEYSTORE, "src/test/resources/jettykeystore"); http://git-wip-us.apache.org/repos/asf/flume/blob/20eed3fd/flume-ng-doc/sphinx/FlumeUserGuide.rst ---------------------------------------------------------------------- diff --git a/flume-ng-doc/sphinx/FlumeUserGuide.rst b/flume-ng-doc/sphinx/FlumeUserGuide.rst index dc8d05d..4892dfc 100644 --- a/flume-ng-doc/sphinx/FlumeUserGuide.rst +++ b/flume-ng-doc/sphinx/FlumeUserGuide.rst @@ -1287,7 +1287,6 @@ selector.* Depends on the sel interceptors -- Space-separated list of interceptors interceptors.* enableSSL false Set the property true, to enable SSL -sslPort The port to be used for SSL keystore Location of the keystore includng keystore file name keystorePassword Keystore password ==================================================================================================================================
