/** * @see GridRegistry#getSession(ExternalSessionKey) */ public TestSession getSession(ExternalSessionKey externalKey) { return activeTestSessions.findSessionByExternalKey(externalKey); }
/** * @see GridRegistry#getExistingSession(ExternalSessionKey) */ public TestSession getExistingSession(ExternalSessionKey externalKey) { return activeTestSessions.getExistingSession(externalKey); }
/** * @see GridRegistry#getActiveSessions() */ public Set<TestSession> getActiveSessions() { return activeTestSessions.unmodifiableSet(); }
private void release(String internalKey, SessionTerminationReason reason) { if (internalKey == null) { return; } final TestSession session = activeTestSessions.findSessionByInternalKey(internalKey); if (session != null) { release(session, reason); return; } LOG.warn("Tried to release session with internal key {} but couldn't find it.", internalKey); }
/** * mark the session as finished for the registry. The resources that were associated to it are now * free to be reserved by other tests * * @param session The session * @param reason the reason for the release */ private void release(TestSession session, SessionTerminationReason reason) { try { lock.lock(); boolean removed = activeTestSessions.remove(session, reason); if (removed) { fireMatcherStateChanged(); } } finally { lock.unlock(); } }
private boolean takeRequestHandler(RequestHandler handler) { final TestSession session = proxies.getNewSession(handler.getRequest().getDesiredCapabilities()); final boolean sessionCreated = session != null; if (sessionCreated) { String remoteName = session.getSlot().getProxy().getId(); long timeToAssignProxy = System.currentTimeMillis() - handler.getRequest().getCreationTime(); LOG.info("Test session with internal key {} assigned to remote ({}) after {} seconds ({} ms).", session.getInternalKey(), remoteName, timeToAssignProxy / 1000, timeToAssignProxy); seleniumTestSessionStartLatency.observe(timeToAssignProxy / Collector.MILLISECONDS_PER_SECOND); seleniumTestSessionsWaiting.dec(); activeTestSessions.add(session); handler.bindSession(session); } return sessionCreated; }