Skip to content

Commit

Permalink
KristianRosenvold: Upgraded grid Hub to Jetty 7.6.1
Browse files Browse the repository at this point in the history
The repackaged jetty is also published to maven central.

Todo: Upgrade server as well and get rid of the inline Jetty sources.

r15959
  • Loading branch information
krosenvold committed Feb 23, 2012
1 parent 020c291 commit 6414c28
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 35 deletions.
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<classpathentry kind="lib" path="third_party/java/easymock/easymockclassextension-2.4.jar"/>
<classpathentry kind="lib" path="third_party/java/htmlunit/htmlunit-core-js-2.9.jar"/>
<classpathentry kind="lib" path="third_party/java/bcprov/bcprov-jdk15-135.jar"/>
<classpathentry kind="lib" path="third_party/java/jetty/jetty-repacked-7.6.1.jar" sourcepath="third_party/java/jetty/jetty-repacked-7.6.1-sources.jar"/>
<classpathentry kind="lib" path="third_party/java/htmlunit/htmlunit-2.9.jar"/>
<classpathentry kind="lib" path="third_party/java/easymock/easymock-2.4.jar"/>
<classpathentry kind="lib" path="third_party/java/apache-httpclient/httpclient-4.1.2.jar" sourcepath="third_party/java/apache-httpclient/httpclient-4.1.2-sources.jar"/>
Expand Down
6 changes: 6 additions & 0 deletions java/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v2.20.0 (In progress)
=======
Grid:
* The HUB is now upgraded to run with Jetty 7.6.1


v2.19.0
=======

Expand Down
4 changes: 2 additions & 2 deletions java/server/src/org/openqa/grid/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ java_library(name = "grid",
],
deps = [
"//java/client/src/org/openqa/selenium:webdriver-api",
"//java/server/src/org/openqa/jetty",
"//java/server/src/org/openqa/grid/common",
"//third_party/java/apache-httpclient",
"//third_party/java/jcip-annotations",
"//third_party/java/yaml"
"//third_party/java/yaml",
"//third_party/java/jetty:jetty761"
])

59 changes: 31 additions & 28 deletions java/server/src/org/openqa/grid/web/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

import javax.servlet.Servlet;

import com.google.common.collect.Maps;

import org.openqa.grid.internal.Registry;
import org.openqa.grid.internal.utils.GridHubConfiguration;
import org.openqa.grid.web.servlet.ConsoleServlet;
Expand All @@ -40,19 +42,16 @@
import org.openqa.grid.web.servlet.ResourceServlet;
import org.openqa.grid.web.servlet.TestSessionStatusServlet;
import org.openqa.grid.web.utils.ExtraServletUtil;
import org.openqa.jetty.http.SocketListener;
import org.openqa.jetty.jetty.Server;
import org.openqa.jetty.jetty.servlet.WebApplicationContext;
import org.seleniumhq.jetty7.server.Server;
import org.seleniumhq.jetty7.server.bio.SocketConnector;
import org.seleniumhq.jetty7.servlet.ServletContextHandler;
import org.openqa.selenium.net.NetworkUtils;
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.log.TerseFormatter;

import com.google.common.collect.Maps;

/**
* Jetty server. Main entry point for everything about the grid.
* <p/>
* Except for unit tests, this should be a singleton.
* Jetty server. Main entry point for everything about the grid. <p/> Except for unit tests, this
* should be a singleton.
*/
public class Hub {

Expand All @@ -71,7 +70,7 @@ private void addServlet(String key, Class<? extends Servlet> s) {

/**
* get the registry backing up the hub state.
*
*
* @return The registry
*/
public Registry getRegistry() {
Expand All @@ -81,8 +80,8 @@ public Registry getRegistry() {
public Hub(GridHubConfiguration config) {
String logFilename =
config.getLogFilename() == null
? RemoteControlConfiguration.getDefaultLogOutFile()
: config.getLogFilename();
? RemoteControlConfiguration.getDefaultLogOutFile()
: config.getLogFilename();
if (logFilename != null) {
try {
Handler logFile = new FileHandler(new File(logFilename).getAbsolutePath(), true);
Expand Down Expand Up @@ -122,37 +121,41 @@ public Hub(GridHubConfiguration config) {
private void initServer() {
try {
server = new Server();
SocketListener socketListener = new SocketListener();
socketListener.setMaxIdleTimeMs(60000);
SocketConnector socketListener = new SocketConnector();
socketListener.setMaxIdleTime(60000);
socketListener.setPort(port);
server.addListener(socketListener);
server.addConnector(socketListener);

ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS);
root.setContextPath("/");
server.setHandler(root);

WebApplicationContext root = server.addWebApplication("", ".");
root.setAttribute(Registry.KEY, registry);

root.addServlet("/*", DisplayHelpServlet.class.getName());
root.addServlet(DisplayHelpServlet.class.getName(), "/*");

root.addServlet("/grid/console/*", ConsoleServlet.class.getName());
root.addServlet("/grid/beta/console/*", org.openqa.grid.web.servlet.beta.ConsoleServlet.class.getName());
root.addServlet("/grid/register/*", RegistrationServlet.class.getName());
root.addServlet(ConsoleServlet.class.getName(), "/grid/console/*");
root.addServlet(org.openqa.grid.web.servlet.beta.ConsoleServlet.class.getName(),
"/grid/beta/console/*");
root.addServlet(RegistrationServlet.class.getName(), "/grid/register/*");
// TODO remove at some point. Here for backward compatibility of
// tests etc.
root.addServlet("/grid/driver/*", DriverServlet.class.getName());
root.addServlet("/wd/hub/*", DriverServlet.class.getName());
root.addServlet("/selenium-server/driver/*", DriverServlet.class.getName());
root.addServlet("/grid/resources/*", ResourceServlet.class.getName());
root.addServlet(DriverServlet.class.getName(), "/grid/driver/*");
root.addServlet(DriverServlet.class.getName(), "/wd/hub/*");
root.addServlet(DriverServlet.class.getName(), "/selenium-server/driver/*");
root.addServlet(ResourceServlet.class.getName(), "/grid/resources/*");

root.addServlet("/grid/api/proxy/*", ProxyStatusServlet.class.getName());
root.addServlet("/grid/api/testsession/*", TestSessionStatusServlet.class.getName());
root.addServlet(ProxyStatusServlet.class.getName(), "/grid/api/proxy/*");
root.addServlet(TestSessionStatusServlet.class.getName(), "/grid/api/testsession/*");

// Selenium Grid 1.0 compatibility routes for older nodes trying to
// work with the newer hub.
root.addServlet("/registration-manager/register/*", RegistrationServlet.class.getName());
root.addServlet("/heartbeat", Grid1HeartbeatServlet.class.getName());
root.addServlet(RegistrationServlet.class.getName(), "/registration-manager/register/*");
root.addServlet(Grid1HeartbeatServlet.class.getName(), "/heartbeat");

// Load any additional servlets provided by the user.
for (Map.Entry<String, Class<? extends Servlet>> entry : extraServlet.entrySet()) {
root.addServlet(entry.getKey(), entry.getValue().getName());
root.addServlet(entry.getValue().getName(), entry.getKey());
}

} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@

import org.json.JSONException;
import org.json.JSONObject;
import org.openqa.grid.internal.ExternalSessionKey;
import org.openqa.grid.common.SeleniumProtocol;
import org.openqa.grid.common.exception.GridException;
import org.openqa.grid.internal.exception.NewSessionException;
import org.openqa.grid.internal.utils.ForwardConfiguration;
import org.openqa.grid.internal.ExternalSessionKey;
import org.openqa.grid.internal.Registry;
import org.openqa.grid.internal.TestSession;
import org.openqa.jetty.jetty.servlet.ServletHttpResponse;
import org.openqa.grid.internal.exception.NewSessionException;
import org.openqa.grid.internal.utils.ForwardConfiguration;
import org.seleniumhq.jetty7.server.Response;

/**
* Handles an individual request, scope is a single request and hence a single thread.
Expand Down Expand Up @@ -123,7 +123,7 @@ public ExternalSessionKey forwardNewSessionRequestAndUpdateRegistry(TestSession

if (getResponse().containsHeader("Location")) {
String location =
((ServletHttpResponse) getResponse()).getHttpResponse().getField("Location");
((Response) getResponse()).getHeader( "Location" );
ExternalSessionKey res = ExternalSessionKey.fromWebDriverRequest( location);
if ( res!=null){
return res;
Expand Down
5 changes: 5 additions & 0 deletions maven/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
<artifactId>servlet-api-2.5</artifactId>
<version>6.1.9</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>jetty-repacked</artifactId>
<version>7.6.1</version>
</dependency>
<dependency>
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions selenium.eml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
<lib name="bcprov-jdk15-135.jar" scope="COMPILE">
<relative-module-cls project-related="jar://$PROJECT_DIR$/third_party/java/bcprov/bcprov-jdk15-135.jar!/"/>
</lib>
<lib name="jetty-repacked-7.6.1.jar" scope="COMPILE">
<srcroot url="jar://$MODULE_DIR$/third_party/java/jetty/jetty-repacked-7.6.1-sources.jar!/"/>
<relative-module-src project-related="jar://$PROJECT_DIR$/third_party/java/jetty/jetty-repacked-7.6.1-sources.jar!/"/>
<relative-module-cls project-related="jar://$PROJECT_DIR$/third_party/java/jetty/jetty-repacked-7.6.1.jar!/"/>
</lib>
<lib name="htmlunit-2.9.jar" scope="COMPILE">
<relative-module-cls project-related="jar://$PROJECT_DIR$/third_party/java/htmlunit/htmlunit-2.9.jar!/"/>
</lib>
Expand Down
7 changes: 7 additions & 0 deletions third_party/java/jetty/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ java_library(name = "lite-android",
deps = [
"jetty-lite-7.2.0-repackaged-for-android.jar"
])


java_library(name = "jetty761",
deps = [
"jetty-repacked-7.6.1.jar",
])

Binary file not shown.
Binary file added third_party/java/jetty/jetty-repacked-7.6.1.jar
Binary file not shown.

0 comments on commit 6414c28

Please sign in to comment.