Skip to content

Commit

Permalink
Refactoring grid node registration procedure to make server start/sto…
Browse files Browse the repository at this point in the history
…p methods as simple as possible.
  • Loading branch information
barancev committed Oct 14, 2015
1 parent 587ccc6 commit c7f393c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.common.exception.GridConfigurationException;
import org.openqa.grid.common.exception.GridException;
import org.openqa.grid.web.servlet.ResourceServlet;
import org.openqa.grid.web.utils.ExtraServletUtil;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.internal.HttpClientFactory;
Expand Down Expand Up @@ -62,25 +60,6 @@ public class SelfRegisteringRemote {
public SelfRegisteringRemote(RegistrationRequest config) {
this.nodeConfig = config;
this.httpClientFactory = new HttpClientFactory();
}

public URL getRemoteURL() {
String host = (String) nodeConfig.getConfiguration().get(RegistrationRequest.HOST);
String port = (String) nodeConfig.getConfiguration().get(RegistrationRequest.PORT);
String url = "http://" + host + ":" + port;

try {
return new URL(url);
} catch (MalformedURLException e) {
throw new GridConfigurationException("error building the node url " + e.getMessage(), e);
}
}

private SeleniumServer server;

public void startRemoteServer() throws Exception {

System.setProperty("org.openqa.jetty.http.HttpRequest.maxFormContentSize", "0");

nodeConfig.validate();

Expand All @@ -99,14 +78,24 @@ public void startRemoteServer() throws Exception {
"error getting the parameters from the hub. The node may end up with wrong timeouts." + e
.getMessage());
}
}

server = new SeleniumServer(nodeConfig.getConfiguration());
public URL getRemoteURL() {
String host = (String) nodeConfig.getConfiguration().get(RegistrationRequest.HOST);
String port = (String) nodeConfig.getConfiguration().get(RegistrationRequest.PORT);
String url = "http://" + host + ":" + port;

String servletsStr = (String) nodeConfig.getConfiguration().get(RegistrationRequest.SERVLETS);
if (servletsStr != null) {
server.registerExtraServlets(Arrays.asList(servletsStr.split(",")));
try {
return new URL(url);
} catch (MalformedURLException e) {
throw new GridConfigurationException("error building the node url " + e.getMessage(), e);
}
}

private SeleniumServer server;

public void startRemoteServer() throws Exception {
server = new SeleniumServer(nodeConfig.getConfiguration());
server.boot();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -247,6 +248,10 @@ public SeleniumServer() throws Exception {

public SeleniumServer(Map<String, Object> configurationAsMap) throws Exception {
this(slowResourceProperty(), mapToRemoteControlConfiguration(configurationAsMap));
String servletsStr = (String) configurationAsMap.get("servlets");
if (servletsStr != null) {
registerExtraServlets(Arrays.asList(servletsStr.split(",")));
}
}

private static RemoteControlConfiguration mapToRemoteControlConfiguration(Map<String, Object> configurationAsMap) {
Expand Down Expand Up @@ -283,6 +288,7 @@ public SeleniumServer(boolean slowResources, RemoteControlConfiguration configur
this.configuration = configuration;
debugMode = configuration.isDebugMode();
jettyThreads = configuration.getJettyThreads();
System.setProperty("org.openqa.jetty.http.HttpRequest.maxFormContentSize", "0");
LOGGER = configureLogging(configuration.getLoggingOptions(), debugMode);
logStartupInfo();
sanitizeProxyConfiguration();
Expand Down

0 comments on commit c7f393c

Please sign in to comment.