Skip to content

Commit 5e47c6a

Browse files
committed
[grid] Catch exception in local distributor that was preventing nodes being added
1 parent 62867fd commit 5e47c6a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

java/server/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import java.util.concurrent.locks.ReadWriteLock;
6565
import java.util.concurrent.locks.ReentrantReadWriteLock;
6666
import java.util.function.Supplier;
67+
import java.util.logging.Level;
6768
import java.util.logging.Logger;
6869
import java.util.stream.Collectors;
6970
import java.util.stream.Stream;
@@ -274,6 +275,8 @@ boolean allBucketsSameSize(Map<String, Set<Host>> hostBuckets) {
274275
private void refresh(NodeStatus status) {
275276
Objects.requireNonNull(status);
276277

278+
LOG.fine("Refreshing: " + status.getUri());
279+
277280
// Iterate over the available nodes to find a match.
278281
Lock writeLock = lock.writeLock();
279282
writeLock.lock();
@@ -282,12 +285,13 @@ private void refresh(NodeStatus status) {
282285
.filter(host -> host.getId().equals(status.getNodeId()))
283286
.findFirst();
284287

285-
286288
if (existing.isPresent()) {
287289
// Modify the state
290+
LOG.fine("Modifying existing state");
288291
existing.get().update(status);
289292
} else {
290293
// No match made. Add a new host.
294+
LOG.info("Creating a new remote node for " + status.getUri());
291295
Node node = new RemoteNode(
292296
tracer,
293297
clientFactory,
@@ -316,7 +320,10 @@ private LocalDistributor add(Node node, NodeStatus status) {
316320

317321
Host host = new Host(bus, node);
318322
host.update(status);
323+
324+
LOG.fine("Adding host: " + host.asSummary());
319325
hosts.add(host);
326+
320327
LOG.info(String.format("Added node %s.", node.getId()));
321328
host.runHealthCheck();
322329

@@ -325,6 +332,8 @@ private LocalDistributor add(Node node, NodeStatus status) {
325332
nodeRunnables.add(runnable);
326333
allChecks.put(node.getId(), nodeRunnables);
327334
hostChecker.submit(runnable, Duration.ofMinutes(5), Duration.ofSeconds(30));
335+
} catch (Throwable t) {
336+
LOG.log(Level.WARNING, "Unable to process host", t);
328337
} finally {
329338
writeLock.unlock();
330339
}

0 commit comments

Comments
 (0)