MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / Node

Class Node

java/src/org/openqa/selenium/grid/node/Node.java:124–321  ·  view source on GitHub ↗

A place where individual webdriver sessions are running. Those sessions may be in-memory, or only reachable via localhost and a network. Or they could be something else entirely. This class responds to the following URLs: Verb <

Source from the content-addressed store, hash-verified

122 * </table>
123 */
124public abstract class Node implements HasReadyState, Routable {
125
126 private static final Logger LOG = Logger.getLogger(Node.class.getName());
127 private static final BuildInfo INFO = new BuildInfo();
128 private static final Map<String, String> OS_INFO = loadOsInfo();
129 protected final Tracer tracer;
130 private final NodeId id;
131 private final URI uri;
132 private final Duration sessionTimeout;
133 private final Route routes;
134 protected final AtomicBoolean draining = new AtomicBoolean(false);
135 protected final AtomicBoolean registered = new AtomicBoolean(false);
136
137 protected Node(
138 Tracer tracer, NodeId id, URI uri, Secret registrationSecret, Duration sessionTimeout) {
139 this.tracer = Require.nonNull("Tracer", tracer);
140 this.id = Require.nonNull("Node id", id);
141 this.uri = Require.nonNull("URI", uri);
142 this.sessionTimeout = Require.positive("Session timeout", sessionTimeout);
143 Require.nonNull("Registration secret", registrationSecret);
144
145 RequiresSecretFilter requiresSecret = new RequiresSecretFilter(registrationSecret);
146
147 Set<CustomLocator> customLocators =
148 StreamSupport.stream(ServiceLoader.load(CustomLocator.class).spliterator(), false)
149 .collect(Collectors.toSet());
150
151 if (!customLocators.isEmpty()) {
152 String names =
153 customLocators.stream()
154 .map(CustomLocator::getLocatorName)
155 .collect(Collectors.joining(", "));
156 LOG.info("Binding additional locator mechanisms: " + names);
157 }
158
159 Json json = new Json();
160 routes =
161 combine(
162 // "getSessionId" is aggressive about finding session ids, so this needs to be the last
163 // route that is checked.
164 matching(req -> getSessionId(req.getUri()).map(SessionId::new).isPresent())
165 .to(() -> new ForwardWebDriverCommand(this))
166 .with(spanDecorator("node.forward_command")),
167 new CustomLocatorHandler(this, registrationSecret, customLocators),
168 post("/session/{sessionId}/se/file")
169 .to(params -> new UploadFile(this, sessionIdFrom(params)))
170 .with(spanDecorator("node.upload_file")),
171 get("/session/{sessionId}/se/files")
172 .to(params -> new DownloadFile(this, sessionIdFrom(params)))
173 .with(spanDecorator("node.download_file")),
174 get("/session/{sessionId}/se/files/{fileName}")
175 .to(params -> new DownloadFile(this, sessionIdFrom(params)))
176 .with(spanDecorator("node.download_file")),
177 post("/session/{sessionId}/se/files")
178 .to(params -> new DownloadFile(this, sessionIdFrom(params)))
179 .with(spanDecorator("node.download_file")),
180 delete("/session/{sessionId}/se/files")
181 .to(params -> new DownloadFile(this, sessionIdFrom(params)))

Callers

nothing calls this directly

Calls 3

loadOsInfoMethod · 0.95
getLoggerMethod · 0.80
getNameMethod · 0.65

Tested by

no test coverage detected