Skip to content

Commit

Permalink
HEXDEV-758 - Upgrade Jetty version to 9.4.30.v20200611 (h2oai#4777)
Browse files Browse the repository at this point in the history
* HEXDEV-758 - Upgrade Jetty version to 9.4.30.v20200611

* Upgraded version of Jetty 8 to 8.2.0.v20160908.

* Move Jetty versions to gradle.properties

* Newline at the end of gradle.properties

* Disable Jetty 9 version in headers (checked by tests already present)

* Custom WebSockerListener factory for Jetty 9

* Use Jetty 9 LDAP config for Hadoop standalone tests

* Revert "Use Jetty 9 LDAP config for Hadoop standalone tests"

This reverts commit bd7f7dc

* Use Jetty 9 LDAP configuration for all standalone tests.

* shadow jetty9 for hdp3 builds

* use shadowed login config classes as documented

* Remove deprecated constructor of SSLContextFactory

* downgrade jetty a bit to avoid a bug

Co-authored-by: Jan Sterba <[email protected]>
  • Loading branch information
Pavel Pscheidl and honzasterba authored Jul 16, 2020
1 parent b6835f4 commit 5a1f6fc
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 30 deletions.
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ defaultHdfsDependency=hadoop-hdfs-client
# Default Hive version
defaultHiveExecVersion=1.1.0

defaultWebserverModule=h2o-jetty-8
defaultWebserverModule=h2o-jetty-9
jetty8version=8.2.0.v20160908
jetty9version=9.4.11.v20180605
1 change: 1 addition & 0 deletions h2o-hadoop-3/assemblyjar.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ shadowJar {
relocate 'org.joda.time', 'ai.h2o.org.joda.time'
exclude hadoopShadowJarExcludes
relocate 'com.google.common', 'ai.h2o.com.google.common'
relocate 'org.eclipse.jetty', 'ai.h2o.org.eclipse.jetty'
baseName = 'h2odriver'
classifier = ''
manifest {
Expand Down
1 change: 1 addition & 0 deletions h2o-hadoop-3/h2o-cdp7.0-assembly/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ shadowJar {
relocate 'org.joda.time', 'ai.h2o.org.joda.time'
exclude hadoopShadowJarExcludes
relocate 'com.google.common', 'ai.h2o.com.google.common'
relocate 'org.eclipse.jetty', 'ai.h2o.org.eclipse.jetty'
baseName = 'h2odriver'
classifier = ''
manifest {
Expand Down
2 changes: 1 addition & 1 deletion h2o-hadoop-common/tests/python/pyunit_connect_invalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def connect_invalid():
print(msg)
print("</Error Message>")

assert msg.startswith("HTTP 401") # Unauthorized
assert msg.startswith("HTTP 401") # Unauthorized

# Test without any auth
err = None
Expand Down
8 changes: 4 additions & 4 deletions h2o-jetty-8/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ description = "Brings Jetty 8 as the HTTP implementation used in H2O server-side

dependencies {
compile project(":h2o-webserver-iface")
compile 'org.eclipse.jetty:jetty-server:8.1.21.v20160908'
compile "org.eclipse.jetty:jetty-servlets:8.1.21.v20160908"
compile "org.eclipse.jetty:jetty-plus:8.1.21.v20160908"
compile "org.eclipse.jetty:jetty-websocket:8.1.21.v20160908"
compile "org.eclipse.jetty:jetty-server:${jetty8version}"
compile "org.eclipse.jetty:jetty-servlets:${jetty8version}"
compile "org.eclipse.jetty:jetty-plus:${jetty8version}"
compile "org.eclipse.jetty:jetty-websocket:${jetty8version}"
testCompile group: "junit", name: "junit", version: "4.12"
testCompile "org.mockito:mockito-core:2.23.0"
}
14 changes: 7 additions & 7 deletions h2o-jetty-9/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
dependencies {
compile project(":h2o-webserver-iface")
compile 'org.eclipse.jetty:jetty-server:9.3.20.v20170531'
compile "org.eclipse.jetty:jetty-servlets:9.3.20.v20170531"
compile 'org.eclipse.jetty:jetty-jaas:9.3.20.v20170531'
compile 'org.eclipse.jetty:jetty-proxy:9.3.20.v20170531'
compile 'org.eclipse.jetty:jetty-servlet:9.3.20.v20170531'
compile 'org.eclipse.jetty.websocket:websocket-api:9.3.20.v20170531'
compile 'org.eclipse.jetty.websocket:websocket-server:9.3.20.v20170531'
compile "org.eclipse.jetty:jetty-server:${jetty9version}"
compile "org.eclipse.jetty:jetty-servlets:${jetty9version}"
compile "org.eclipse.jetty:jetty-jaas:${jetty9version}"
compile "org.eclipse.jetty:jetty-proxy:${jetty9version}"
compile "org.eclipse.jetty:jetty-servlet:${jetty9version}"
compile "org.eclipse.jetty.websocket:websocket-api:${jetty9version}"
compile "org.eclipse.jetty.websocket:websocket-server:${jetty9version}"
testCompile group: "junit", name: "junit", version: "4.12"
testCompile "org.mockito:mockito-core:2.23.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private HttpConnectionFactory buildHttpConnectionFactory(boolean isSecured) {
final String proto = isSecured ? "https" : "http";

final HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.setSendServerVersion(true);
httpConfiguration.setSendServerVersion(false);
httpConfiguration.setRequestHeaderSize(getSysPropInt(proto + ".requestHeaderSize", 32 * 1024));
httpConfiguration.setResponseHeaderSize(getSysPropInt(proto + ".responseHeaderSize", 32 * 1024));
httpConfiguration.setOutputBufferSize(getSysPropInt(proto + ".responseBufferSize", httpConfiguration.getOutputBufferSize()));
Expand Down Expand Up @@ -154,10 +154,10 @@ HandlerWrapper authWrapper(Server jettyServer) {

final SessionHandler sessionHandler = new SessionHandler();
if (config.session_timeout > 0) {
sessionHandler.getSessionManager().setMaxInactiveInterval(config.session_timeout * 60);
sessionHandler.setMaxInactiveInterval(config.session_timeout * 60);
}
sessionHandler.setHandler(security);
jettyServer.setSessionIdManager(sessionHandler.getSessionManager().getSessionIdManager());
jettyServer.setSessionIdManager(sessionHandler.getSessionIdManager());

// Pass-through to H2O if authenticated.
jettyServer.setHandler(sessionHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketListener;
import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
import org.eclipse.jetty.websocket.servlet.*;
import water.webserver.iface.WebsocketConnection;
import water.webserver.iface.WebsocketHandler;
import water.webserver.iface.H2OWebsocketServlet;
Expand Down Expand Up @@ -68,9 +67,30 @@ public void onWebSocketError(Throwable cause) {
}

}


/**
* Please note, each Servlet has it's own instance of WebSocketServletFactory.
*
* @param factory Factory object to register socket creator with.
*/
@Override
public void configure(WebSocketServletFactory factory) {
factory.register(Jetty9WebsocketHandler.class);
factory.setCreator(new H2OWebSocketCreator());
}

/**
* Custom in-place socket creator, returning new instance of {@link Jetty9WebsocketHandler}m
* which already contains the proper {@link WebsocketServlet} implementation the request is being delegated to.
* <p>
* This is required, as default {@link WebSocketServletFactory} uses {@link org.eclipse.jetty.util.DecoratedObjectFactory}
* to instantiate {@link WebSocketListener} classes. This class is only able to instantiate static classes with 0-arg constructor,
* which inner non-static class {@link Jetty9WebsocketHandler} is NOT.
*/
public class H2OWebSocketCreator implements WebSocketCreator {

@Override
public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) {
return new Jetty9WebsocketHandler();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package water.webserver.jetty9;

import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpExchange;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.proxy.ProxyServlet;
import org.eclipse.jetty.util.ssl.SslContextFactory;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.util.ssl.SslContextFactory;


/**
Expand Down
4 changes: 2 additions & 2 deletions h2o-mapreduce-generic/src/main/java/water/ProxyStarter.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ private static InetAddress getInetAddress(String ip) {

// just for local testing
public static void main(String[] args) {
Credentials cred = new Credentials(System.getProperty("user.name"), "Heslo123");
String url = start(args, cred, "https://localhost:54321/", false);
Credentials cred = new Credentials(System.getProperty("user.name"), "water");
String url = start(args, cred, "http://localhost:54321/", false);
System.out.println("Proxy started on " + url + " " + cred.toDebugString());
}

Expand Down
4 changes: 2 additions & 2 deletions scripts/jenkins/config/ldap-jetty-8.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ldaploginmodule {
org.eclipse.jetty.plus.jaas.spi.LdapLoginModule required
ai.h2o.org.eclipse.jetty.plus.jaas.spi.LdapLoginModule required
debug="true"
useLdaps="false"
contextFactory="com.sun.jndi.ldap.LdapCtxFactory"
Expand All @@ -10,4 +10,4 @@ ldaploginmodule {
authenticationMethod="simple"
forceBindingLogin="true"
userBaseDn="ou=users,dc=0xdata,dc=loc";
};
};
2 changes: 1 addition & 1 deletion scripts/jenkins/config/ldap-jetty-9.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ldaploginmodule {
org.eclipse.jetty.jaas.spi.LdapLoginModule required
ai.h2o.org.eclipse.jetty.jaas.spi.LdapLoginModule required
debug="true"
useLdaps="false"
contextFactory="com.sun.jndi.ldap.LdapCtxFactory"
Expand Down
2 changes: 1 addition & 1 deletion scripts/jenkins/groovy/defineTestStages.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def call(final pipelineContext) {
version: distribution.version,
commandFactory: 'h2o-3/scripts/jenkins/groovy/hadoopCommands.groovy',
ldapConfigPath: ldapConfigPath,
ldapConfigPathStandalone: 'scripts/jenkins/config/ldap-jetty-8.txt'
ldapConfigPathStandalone: 'scripts/jenkins/config/ldap-jetty-9.txt'
], pythonVersion: '2.7',
customDockerArgs: [ '--privileged' ],
executionScript: 'h2o-3/scripts/jenkins/groovy/hadoopStage.groovy',
Expand Down

0 comments on commit 5a1f6fc

Please sign in to comment.