Skip to content

Commit

Permalink
[grid] Deleting deprecated code related to legacy (v1 and v2) grid im…
Browse files Browse the repository at this point in the history
…plementations
  • Loading branch information
barancev committed Apr 8, 2019
1 parent da15b87 commit 675066a
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 186 deletions.
8 changes: 0 additions & 8 deletions java/server/src/org/openqa/grid/common/SeleniumProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,4 @@ public String getPathConsideringCapabilitiesMap(Map<String, Object> capabilities
public String getPath() {
return path;
}

/**
* @deprecated use {@link SeleniumProtocol#Selenium#equals(Object)}
*/
@Deprecated
public boolean isSelenium() {
return Selenium.equals(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,6 @@ public static GridHubConfiguration loadFromJSON(JsonInput jsonInput) {
}
}

/**
* Merge this configuration with the specified {@link GridNodeConfiguration}
* @param other
*
* @deprecated There is no use case to merge a node configuration to a hub configuration
*/
@Deprecated
public void merge(GridNodeConfiguration other) {
super.merge(other);
}

/**
* Merge this configuration with the specified {@link GridHubConfiguration}
* @param other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ private static NodeJsonConfiguration getDefaultConfigFromJson() {
*/
public String remoteHost;

// used to read a Selenium 2.x nodeConfig.json file and throw a friendly exception
@Deprecated
private Object configuration;

/*
* config parameters which serialize and deserialize to/from json
*/
Expand Down
5 changes: 0 additions & 5 deletions java/server/src/org/openqa/grid/web/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.openqa.grid.shared.Stoppable;
import org.openqa.grid.web.servlet.DisplayHelpServlet;
import org.openqa.grid.web.servlet.DriverServlet;
import org.openqa.grid.web.servlet.Grid1HeartbeatServlet;
import org.openqa.grid.web.servlet.HubStatusServlet;
import org.openqa.grid.web.servlet.HubW3CStatusServlet;
import org.openqa.grid.web.servlet.LifecycleServlet;
Expand Down Expand Up @@ -160,10 +159,6 @@ private void addDefaultServlets(ServletContextHandler handler) {
if (!config.isWithOutServlet(LifecycleServlet.class)) {
handler.addServlet(LifecycleServlet.class.getName(), "/lifecycle-manager/*");
}

if (!config.isWithOutServlet(Grid1HeartbeatServlet.class)) {
handler.addServlet(Grid1HeartbeatServlet.class.getName(), "/heartbeat");
}
}

private void initServer() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,18 @@

import static org.openqa.selenium.json.Json.MAP_TYPE;

import com.google.common.collect.Lists;
import com.google.common.io.CharStreams;

import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.common.exception.GridConfigurationException;
import org.openqa.grid.internal.BaseRemoteProxy;
import org.openqa.grid.internal.GridRegistry;
import org.openqa.grid.internal.RemoteProxy;
import org.openqa.grid.internal.utils.configuration.GridNodeConfiguration;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.json.Json;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collection;
import java.util.Map;
import java.util.logging.Logger;

Expand Down Expand Up @@ -87,18 +83,7 @@ protected void process(HttpServletRequest request, HttpServletResponse response)
throw new GridConfigurationException("No configuration received for proxy.");
}

final RegistrationRequest registrationRequest;
if (isV2RegistrationRequestJson(json)) {
// Se2 compatible request
@SuppressWarnings("unchecked") GridNodeConfiguration nodeConfiguration =
mapV2Configuration((Map<String, Object>) json.get("configuration"));
registrationRequest = new RegistrationRequest(nodeConfiguration);
// get the "capabilities" and "id" from the v2 json request
considerV2Json(registrationRequest.getConfiguration(), json);
} else {
// Se3 compatible request.
registrationRequest = RegistrationRequest.fromJson(json);
}
final RegistrationRequest registrationRequest = RegistrationRequest.fromJson(json);

final RemoteProxy proxy = BaseRemoteProxy.getNewInstance(registrationRequest, getRegistry());

Expand All @@ -111,76 +96,6 @@ protected void process(HttpServletRequest request, HttpServletResponse response)
}).start();
}

/**
* @deprecated because V3 node configuration data structure is internally different than V2.
* That said V2 nodes do need to be able to register with a V3 hub.
*/
@Deprecated
private GridNodeConfiguration mapV2Configuration(Map<String, Object> json) {
// servlets should result in a parse error since the type changed from String to
// List<String> with V3. So, we need to save it off and then parse normally.
Object servlets = json.get("servlets");
// V3 beta versions send a V2 RegistrationRequest which specifies servlets as a List<String>
// When this is the case, we don't need to remove it for parsing.
if (servlets instanceof String) {
json.remove("servlets");
}

// if a JsonSyntaxException happens here, so be it. We won't be able to map the request
// to a grid node configuration anyhow.
// It's entirely possible that there's a less elegant way of doing thing, but I'm not sure what
// it is.
// TODO: Don't be this horrible
GridNodeConfiguration pendingConfiguration =
GridNodeConfiguration.loadFromJSON(JSON.toJson(json));

// add the servlets that were saved off
if (servlets instanceof String &&
(pendingConfiguration.servlets == null || pendingConfiguration.servlets.isEmpty())) {
pendingConfiguration.servlets = Lists.newArrayList(servlets.toString().split(","));
}

return pendingConfiguration;
}

/**
* @deprecated because V3 does not have separate "capabilities": { } object in the serialized json
* representation of the RegistrationRequest. That said V2 nodes do need to be able to register
* with a V3 hub.
*/
@Deprecated
private boolean isV2RegistrationRequestJson(Map<String, Object> json) {
return json.containsKey("capabilities") && json.containsKey("configuration");
}

/**
* @deprecated because V3 does not have separate "capabilities": { } object and "id": "value"
* in the serialized json representation of the RegistrationRequest. That said V2 nodes do need
* to be able to register with a V3 hub.
*/
@Deprecated
private void considerV2Json(GridNodeConfiguration configuration, Map<String, Object> json) {
// Backwards compatible with Selenium 2.x remotes which might send a
// registration request with the json field "id". 3.x remotes will include the "id" with the
// "configuration" object. The presence of { "id": "value" } should always override
// { "configuration": { "id": "value" } }
if (json.get("id") instanceof String) {
configuration.id = json.get("id").toString();
}

// Backwards compatible with Selenium 2.x remotes which send a registration request with the
// json object "capabilities". 3.x remotes will include the "capabilities" object with the
// "configuration" object. The presence of { "capabilities": [ {...}, {...} ] } should always
// override { "configuration": { "capabilities": [ {...}, {...} ] } }
if (json.get("capabilities") instanceof Collection) {
configuration.capabilities.clear();
@SuppressWarnings("unchecked") Collection<Map<String, Object>> capabilities =
(Collection<Map<String, Object>>) json.get("capabilities");
capabilities.stream().map(MutableCapabilities::new).forEach(configuration.capabilities::add);
configuration.fixUpCapabilities();
}
}

protected void reply(HttpServletResponse response, String content) throws IOException {
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
Expand Down

0 comments on commit 675066a

Please sign in to comment.