How to use NodeRejectedEvent class of org.openqa.selenium.grid.data package

Best Selenium code snippet using org.openqa.selenium.grid.data.NodeRejectedEvent

Source:GridModel.java Github

copy

Full Screen

...20import org.openqa.selenium.grid.data.Availability;21import org.openqa.selenium.grid.data.NodeDrainComplete;22import org.openqa.selenium.grid.data.NodeDrainStarted;23import org.openqa.selenium.grid.data.NodeId;24import org.openqa.selenium.grid.data.NodeRejectedEvent;25import org.openqa.selenium.grid.data.NodeRemovedEvent;26import org.openqa.selenium.grid.data.NodeStatus;27import org.openqa.selenium.grid.data.NodeStatusEvent;28import org.openqa.selenium.grid.data.Session;29import org.openqa.selenium.grid.data.SessionClosedEvent;30import org.openqa.selenium.grid.data.Slot;31import org.openqa.selenium.grid.data.SlotId;32import org.openqa.selenium.grid.security.Secret;33import org.openqa.selenium.internal.Require;34import org.openqa.selenium.remote.SessionId;35import java.time.Instant;36import java.util.HashSet;37import java.util.Iterator;38import java.util.Map;39import java.util.Objects;40import java.util.Optional;41import java.util.Set;42import java.util.concurrent.ConcurrentHashMap;43import java.util.concurrent.locks.Lock;44import java.util.concurrent.locks.ReadWriteLock;45import java.util.concurrent.locks.ReentrantReadWriteLock;46import java.util.logging.Logger;47import static org.openqa.selenium.grid.data.Availability.DOWN;48import static org.openqa.selenium.grid.data.Availability.DRAINING;49import static org.openqa.selenium.grid.data.Availability.UP;50public class GridModel {51 private static final Logger LOG = Logger.getLogger(GridModel.class.getName());52 private static final SessionId RESERVED = new SessionId("reserved");53 private final ReadWriteLock lock = new ReentrantReadWriteLock(/* fair */ true);54 private final Map<Availability, Set<NodeStatus>> nodes = new ConcurrentHashMap<>();55 private final EventBus events;56 public GridModel(EventBus events, Secret registrationSecret) {57 this.events = Require.nonNull("Event bus", events);58 events.addListener(NodeDrainStarted.listener(nodeId -> setAvailability(nodeId, DRAINING)));59 events.addListener(NodeDrainComplete.listener(this::remove));60 events.addListener(NodeRemovedEvent.listener(this::remove));61 events.addListener(NodeStatusEvent.listener(status -> refresh(registrationSecret, status)));62 events.addListener(SessionClosedEvent.listener(this::release));63 }64 public GridModel add(NodeStatus node) {65 Require.nonNull("Node", node);66 Lock writeLock = lock.writeLock();67 writeLock.lock();68 try {69 // If we've already added the node, remove it.70 for (Set<NodeStatus> nodes : nodes.values()) {71 Iterator<NodeStatus> iterator = nodes.iterator();72 while (iterator.hasNext()) {73 NodeStatus next = iterator.next();74 // If the ID is the same, we're re-adding a node. If the URI is the same a node probably restarted75 if (next.getId().equals(node.getId()) || next.getUri().equals(node.getUri())) {76 LOG.info(String.format("Re-adding node with id %s and URI %s.", node.getId(), node.getUri()));77 iterator.remove();78 }79 }80 }81 // Nodes are initially added in the "down" state until something changes their availability82 nodes(DOWN).add(node);83 } finally {84 writeLock.unlock();85 }86 return this;87 }88 public GridModel refresh(Secret registrationSecret, NodeStatus status) {89 Require.nonNull("Node status", status);90 Secret statusSecret = status.getRegistrationSecret() == null ? null : new Secret(status.getRegistrationSecret());91 if (!Objects.equals(registrationSecret, statusSecret)) {92 LOG.severe(String.format("Node at %s failed to send correct registration secret. Node NOT refreshed.", status.getUri()));93 events.fire(new NodeRejectedEvent(status.getUri()));94 return this;95 }96 Lock writeLock = lock.writeLock();97 writeLock.lock();98 try {99 AvailabilityAndNode availabilityAndNode = findNode(status.getId());100 if (availabilityAndNode == null) {101 return this;102 }103 // if the node was marked as "down", keep it down until a healthcheck passes:104 // just because the node can hit the event bus doesn't mean it's reachable105 if (DOWN.equals(availabilityAndNode.availability)) {106 nodes(DOWN).remove(availabilityAndNode.status);107 nodes(DOWN).add(status);...

Full Screen

Full Screen

Source:LocalDistributor.java Github

copy

Full Screen

...28import org.openqa.selenium.grid.data.DistributorStatus;29import org.openqa.selenium.grid.data.NodeAddedEvent;30import org.openqa.selenium.grid.data.NodeDrainComplete;31import org.openqa.selenium.grid.data.NodeId;32import org.openqa.selenium.grid.data.NodeRejectedEvent;33import org.openqa.selenium.grid.data.NodeRemovedEvent;34import org.openqa.selenium.grid.data.NodeStatus;35import org.openqa.selenium.grid.data.NodeStatusEvent;36import org.openqa.selenium.grid.data.Slot;37import org.openqa.selenium.grid.data.SlotId;38import org.openqa.selenium.grid.distributor.Distributor;39import org.openqa.selenium.grid.distributor.selector.DefaultSlotSelector;40import org.openqa.selenium.grid.log.LoggingOptions;41import org.openqa.selenium.grid.node.HealthCheck;42import org.openqa.selenium.grid.node.Node;43import org.openqa.selenium.grid.node.remote.RemoteNode;44import org.openqa.selenium.grid.security.Secret;45import org.openqa.selenium.grid.server.BaseServerOptions;46import org.openqa.selenium.grid.server.EventBusOptions;47import org.openqa.selenium.grid.server.NetworkOptions;48import org.openqa.selenium.grid.sessionmap.SessionMap;49import org.openqa.selenium.grid.sessionmap.config.SessionMapOptions;50import org.openqa.selenium.internal.Require;51import org.openqa.selenium.remote.http.HttpClient;52import org.openqa.selenium.remote.tracing.Tracer;53import org.openqa.selenium.status.HasReadyState;54import java.time.Duration;55import java.util.ArrayList;56import java.util.HashMap;57import java.util.List;58import java.util.Map;59import java.util.Objects;60import java.util.Optional;61import java.util.Set;62import java.util.concurrent.locks.Lock;63import java.util.concurrent.locks.ReadWriteLock;64import java.util.concurrent.locks.ReentrantReadWriteLock;65import java.util.function.Supplier;66import java.util.logging.Level;67import java.util.logging.Logger;68import static com.google.common.collect.ImmutableSet.toImmutableSet;69import static org.openqa.selenium.grid.data.Availability.DOWN;70import static org.openqa.selenium.grid.data.Availability.DRAINING;71public class LocalDistributor extends Distributor {72 private static final Logger LOG = Logger.getLogger(LocalDistributor.class.getName());73 private final Tracer tracer;74 private final EventBus bus;75 private final HttpClient.Factory clientFactory;76 private final SessionMap sessions;77 private final Regularly hostChecker = new Regularly("distributor host checker");78 private final Map<NodeId, Runnable> allChecks = new HashMap<>();79 private final ReadWriteLock lock = new ReentrantReadWriteLock(/* fair */ true);80 private final GridModel model;81 private final Map<NodeId, Node> nodes;82 public LocalDistributor(83 Tracer tracer,84 EventBus bus,85 HttpClient.Factory clientFactory,86 SessionMap sessions,87 Secret registrationSecret) {88 super(tracer, clientFactory, new DefaultSlotSelector(), sessions, registrationSecret);89 this.tracer = Require.nonNull("Tracer", tracer);90 this.bus = Require.nonNull("Event bus", bus);91 this.clientFactory = Require.nonNull("HTTP client factory", clientFactory);92 this.sessions = Require.nonNull("Session map", sessions);93 this.model = new GridModel(bus, registrationSecret);94 this.nodes = new HashMap<>();95 bus.addListener(NodeStatusEvent.listener(status -> register(registrationSecret, status)));96 bus.addListener(NodeStatusEvent.listener(status -> model.refresh(registrationSecret, status)));97 bus.addListener(NodeDrainComplete.listener(this::remove));98 }99 public static Distributor create(Config config) {100 Tracer tracer = new LoggingOptions(config).getTracer();101 EventBus bus = new EventBusOptions(config).getEventBus();102 HttpClient.Factory clientFactory = new NetworkOptions(config).getHttpClientFactory(tracer);103 SessionMap sessions = new SessionMapOptions(config).getSessionMap();104 BaseServerOptions serverOptions = new BaseServerOptions(config);105 return new LocalDistributor(tracer, bus, clientFactory, sessions, serverOptions.getRegistrationSecret());106 }107 @Override108 public boolean isReady() {109 try {110 return ImmutableSet.of(bus, sessions).parallelStream()111 .map(HasReadyState::isReady)112 .reduce(true, Boolean::logicalAnd);113 } catch (RuntimeException e) {114 return false;115 }116 }117 private void register(Secret registrationSecret, NodeStatus status) {118 Require.nonNull("Node", status);119 Secret nodeSecret = status.getRegistrationSecret() == null ? null : new Secret(status.getRegistrationSecret());120 if (!Objects.equals(registrationSecret, nodeSecret)) {121 LOG.severe(String.format("Node at %s failed to send correct registration secret. Node NOT registered.", status.getUri()));122 bus.fire(new NodeRejectedEvent(status.getUri()));123 return;124 }125 Lock writeLock = lock.writeLock();126 writeLock.lock();127 try {128 if (nodes.containsKey(status.getId())) {129 return;130 }131 Set<Capabilities> capabilities = status.getSlots().stream()132 .map(Slot::getStereotype)133 .map(ImmutableCapabilities::copyOf)134 .collect(toImmutableSet());135 // A new node! Add this as a remote node, since we've not called add136 RemoteNode remoteNode = new RemoteNode(...

Full Screen

Full Screen

Source:NodeRejectedEvent.java Github

copy

Full Screen

...17package org.openqa.selenium.grid.data;18import org.openqa.selenium.events.Event;19import org.openqa.selenium.events.EventName;20import java.net.URI;21public class NodeRejectedEvent extends Event {22 public static final EventName NODE_REJECTED = new EventName("node-rejected");23 public NodeRejectedEvent(URI uri) {24 super(NODE_REJECTED, uri);25 }26}...

Full Screen

Full Screen

NodeRejectedEvent

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.grid.data.NodeRejectedEvent;2import org.openqa.selenium.grid.data.SessionRejectedEvent;3import org.openqa.selenium.grid.data.SessionRequest;4import org.openqa.selenium.grid.data.SessionRequestEvent;5import org.openqa.selenium.grid.data.SessionRequestListener;6import org.openqa.selenium.grid.data.SessionRequestQueue;7import org.openqa.selenium.grid.data.SessionRequestQueueEvent;8import org.openqa.selenium.grid.data.SessionRequestQueueListener;9import org.openqa.selenium.grid.data.SessionRequestQueueState;10import org.openqa.selenium.grid.data.SessionRequestQueueStatus;11import org.openqa.selenium.grid.data.SessionRequestState;12import org.openqa.selenium.grid.data.SessionRequestStatus;13import org.openqa.selenium.grid.data.SessionStartedEvent;14import org.openqa.selenium.grid.data.SessionTerminatedEvent;15import org.openqa.selenium.grid.data.SessionTimeouts;16import org.openqa.selenium.grid.data.SessionUri;17import org.openqa.selenium.grid.data.Slot;18import org.openqa.selenium.grid.data.SlotId;19import org.openqa.selenium.grid.data.SlotMatch;20import org.openqa.selenium

Full Screen

Full Screen

NodeRejectedEvent

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.grid.data.NodeRejectedEvent;2import org.openqa.selenium.grid.data.SessionRequest;3import org.openqa.selenium.grid.data.SessionStartedEvent;4import org.openqa.selenium.grid.data.SessionTerminatedEvent;5import org.openqa.selenium.grid.data.Session;6import org.openqa.selenium.grid.data.SessionId;7import org.openqa.selenium.grid.data.SessionInfo;8import org.openqa.selenium.grid.data.SessionRequest;9import org.openqa.selenium.grid.data.SessionRequestEvent;10import org.openqa.selenium.grid.data.SessionRequestEvent.State;11import org.openqa.selenium.grid.data.SessionRequestEvent.State.DENIED;12import org.openqa.selenium.grid.data.SessionRequestEvent.State.EXPIRED;13import org.openqa.selenium.grid.data.SessionRequestEvent.State.FAILED;14import org.openqa.selenium.grid.data.SessionRequestEvent.State.FULFILLED;15import org.openqa.selenium.grid.data.SessionRequestEvent.State.PENDING;16import org.openqa.selenium.grid.data.SessionRequestEvent.State.REJECTED;17import org.openqa.selenium.grid.data.SessionRequestEvent.State.TIMEOUT;18import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNASSIGNED;19import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNFULFILLED;20import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNRECOGNIZED;21import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNKNOWN;22import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNSUPPORTED;23import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNTERMINATED;24import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNTRUSTED;25import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNUSED;26import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNUSABLE;27import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNAVAILABLE;28import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNREACHABLE;29import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNRESPONSIVE;30import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNAVAILABLE;31import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNREACHABLE;32import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNRESPONSIVE;33import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNAVAILABLE;34import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNREACHABLE;35import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNRESPONSIVE;36import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNAVAILABLE;37import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNREACHABLE;38import org.openqa.selenium.grid.data.SessionRequestEvent.State.UNRESPONSIVE;39import org.openqa.selenium.grid.data

Full Screen

Full Screen

NodeRejectedEvent

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.grid.data.NodeRejectedEvent;2NodeRejectedEvent nodeRejectedEvent = new NodeRejectedEvent("node-id");3System.out.println(nodeRejectedEvent.getNodeId());4import org.openqa.selenium.grid.node.NodeRejectedEvent;5NodeRejectedEvent nodeRejectedEvent = new NodeRejectedEvent("node-id");6System.out.println(nodeRejectedEvent.getNodeId());7import org.openqa.selenium.grid.distributor.model.NodeRejectedEvent;8NodeRejectedEvent nodeRejectedEvent = new NodeRejectedEvent("node-id");9System.out.println(nodeRejectedEvent.getNodeId());10import org.openqa.selenium.grid.router.model.NodeRejectedEvent;11NodeRejectedEvent nodeRejectedEvent = new NodeRejectedEvent("node-id");12System.out.println(nodeRejectedEvent.getNodeId());13import org.openqa.selenium.grid.sessionmap.model.NodeRejectedEvent;14NodeRejectedEvent nodeRejectedEvent = new NodeRejectedEvent("node-id");15System.out.println(nodeRejectedEvent.getNodeId());16import org.openqa.selenium.grid.sessionqueue.model.NodeRejectedEvent;17NodeRejectedEvent nodeRejectedEvent = new NodeRejectedEvent("node-id");18System.out.println(nodeRejectedEvent.getNodeId());19import org.openqa.selenium.grid.testing.model.NodeRejectedEvent;20NodeRejectedEvent nodeRejectedEvent = new NodeRejectedEvent("node-id");21System.out.println(nodeRejectedEvent.getNodeId());22import org.openqa.selenium.grid.web.model.NodeRejectedEvent;23NodeRejectedEvent nodeRejectedEvent = new NodeRejectedEvent("node-id");24System.out.println(nodeRejectedEvent.getNodeId());25import org.openqa.selenium.grid.config.model.NodeRejectedEvent;26NodeRejectedEvent nodeRejectedEvent = new NodeRejectedEvent("node-id");27System.out.println(nodeRejectedEvent.getNodeId());28import org.openqa.selenium.grid.config.model.NodeRejectedEvent;29NodeRejectedEvent nodeRejectedEvent = new NodeRejectedEvent("node-id");30System.out.println(nodeRejectedEvent.getNodeId());

Full Screen

Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Run Selenium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful