/** * @see GridRegistry#clearNewSessionRequests() */ public void clearNewSessionRequests() { newSessionQueue.clearNewSessionRequests(); seleniumTestSessionsWaiting.set(0); }
/** * @see GridRegistry#getDesiredCapabilities() */ public Iterable<DesiredCapabilities> getDesiredCapabilities() { return newSessionQueue.getDesiredCapabilities(); }
/** * @see GridRegistry#getNewSessionRequestCount() */ public int getNewSessionRequestCount() { // may race return newSessionQueue.getNewSessionRequestCount(); }
/** * Creates a new {@link GridRegistry} and starts it. * * @param hub the {@link Hub} to associate this registry with * @param proxySet the {@link ProxySet} to manage proxies with */ public ZaleniumRegistry(Hub hub, ProxySet proxySet) { super(hub); this.newSessionQueue = new NewSessionRequestQueue(); proxies = proxySet; this.matcherThread.setUncaughtExceptionHandler(new UncaughtExceptionHandler()); }
/** * @see GridRegistry#removeNewSessionRequest(RequestHandler) */ public boolean removeNewSessionRequest(RequestHandler request) { boolean wasRemoved = newSessionQueue.removeNewSessionRequest(request); if (wasRemoved) { seleniumTestSessionsWaiting.dec(); } return wasRemoved; }
/** * @see GridRegistry#stop() */ public void stop() { stop = true; matcherThread.interrupt(); newSessionQueue.stop(); proxies.teardown(); }
/** * @see GridRegistry#addNewSessionRequest(RequestHandler) */ public void addNewSessionRequest(RequestHandler handler) { try { lock.lock(); Map<String, Object> requestedCapabilities = handler.getRequest().getDesiredCapabilities(); proxies.verifyAbilityToHandleDesiredCapabilities(requestedCapabilities); requestedCapabilities.forEach((k, v) -> MDC.put(k,v.toString())); LOG.info("Adding sessionRequest for " + requestedCapabilities.toString()); newSessionQueue.add(handler); seleniumTestSessionsWaiting.inc(); fireMatcherStateChanged(); } finally { MDC.clear(); lock.unlock(); } }
/** * iterates the list of incoming session request to find a potential match in the list of proxies. * If something changes in the registry, the matcher iteration is stopped to account for that * change. */ private void assignRequestToProxy() { while (!stop) { try { testSessionAvailable.await(5, TimeUnit.SECONDS); newSessionQueue.processQueue(this::takeRequestHandler, getHub().getConfiguration().prioritizer); // Just make sure we delete anything that is logged on this thread from memory LoggingManager.perSessionLogHandler().clearThreadTempLogs(); } catch (InterruptedException e) { LOG.info("Shutting down registry."); } catch (Throwable t) { LOG.error("Unhandled exception in Matcher thread.", t); } } }
public ZaleniumRegistry(Hub hub) { super(hub); this.newSessionQueue = new NewSessionRequestQueue(); long minContainers = ZaleniumConfiguration.getDesiredContainersOnStartup(); long maxContainers = ZaleniumConfiguration.getMaxDockerSeleniumContainers(); long timeToWaitToStart = ZaleniumConfiguration.getTimeToWaitToStart(); boolean waitForAvailableNodes = ZaleniumConfiguration.isWaitForAvailableNodes(); int maxTimesToProcessRequest = ZaleniumConfiguration.getMaxTimesToProcessRequest(); int checkContainersInterval = ZaleniumConfiguration.getCheckContainersInterval(); DockeredSeleniumStarter starter = new DockeredSeleniumStarter(); AutoStartProxySet autoStart = new AutoStartProxySet(false, minContainers, maxContainers, timeToWaitToStart, waitForAvailableNodes, starter, Clock.systemDefaultZone(), maxTimesToProcessRequest, checkContainersInterval); proxies = autoStart; this.matcherThread.setUncaughtExceptionHandler(new UncaughtExceptionHandler()); new TestSessionCollectorExports(proxies).register(); new ContainerStatusCollectorExports(autoStart.getStartedContainers()).register(); }