public class DefaultRemoteProxy extends BaseRemoteProxy implements TimeoutListener, SelfHealingProxy, CommandListener, TestSessionListener
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_DOWN_POLLING_LIMIT |
static int |
DEFAULT_POLLING_INTERVAL |
static int |
DEFAULT_UNREGISTER_DELAY |
private boolean |
down |
private int |
downPollingLimit |
private java.util.List<RemoteException> |
errors |
private static java.util.logging.Logger |
LOG |
private boolean |
poll |
private int |
pollingInterval |
private java.lang.Thread |
pollingThread |
private HtmlRenderer |
renderer |
private int |
unregisterDelay |
config, remoteHost| Constructor and Description |
|---|
DefaultRemoteProxy(RegistrationRequest request,
Registry registry) |
| Modifier and Type | Method and Description |
|---|---|
void |
addNewEvent(RemoteException event)
Allow to record when something important about the remote state is detected.
|
void |
afterCommand(TestSession session,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Executed just before the forwards returns.
|
void |
afterSession(TestSession session)
Will be run after the last command is forwarded, but before the proxy slot is released.
|
void |
beforeCommand(TestSession session,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Executed before the hub forwards the request.
|
void |
beforeRelease(TestSession session)
Gives a chance to clean the resources on the remote when the session has timed out.
|
void |
beforeSession(TestSession session)
The client shouldn't have to care where firefox is installed as long as the correct version is
launched, however with webdriver the binary location is specified in the desiredCapability,
making it the responsibility of the person running the test.
|
HtmlRenderer |
getHtmlRender()
Returns the object responsible for rendering any information about the proxy in a Web application.
|
TestSession |
getNewSession(java.util.Map<java.lang.String,java.lang.Object> requestedCapability)
overwrites the session allocation to discard the proxy that are down.
|
boolean |
isAlive() |
boolean |
isDown() |
void |
onEvent(java.util.List<RemoteException> events,
RemoteException lastInserted)
Allow to process the list of all the events that were detected on this Remote so far.
|
void |
startPolling()
start/restart the polling for the remote proxy.
|
void |
stopPolling()
put the polling on hold.
|
void |
teardown()
If the RemoteProxy implementation also implements TimeoutListener, then this method
will stop the thread used to monitor timeouts.
|
compareTo, equals, forceSlotCleanerRun, getCapabilityHelper, getConfig, getHttpClientFactory, getId, getLastSessionStart, getMaxNumberOfConcurrentTestSessions, getNewInstance, getOriginalRegistrationRequest, getRegistry, getRemoteHost, getResourceUsageInPercent, getStatus, getTestSlots, getTimeOut, getTotalUsed, hasCapability, hashCode, isBusy, setupTimeoutListener, toStringprivate static final java.util.logging.Logger LOG
public static final int DEFAULT_POLLING_INTERVAL
public static final int DEFAULT_UNREGISTER_DELAY
public static final int DEFAULT_DOWN_POLLING_LIMIT
private volatile int pollingInterval
private volatile int unregisterDelay
private volatile int downPollingLimit
private final HtmlRenderer renderer
private volatile boolean down
private volatile boolean poll
private java.util.List<RemoteException> errors
private java.lang.Thread pollingThread
public DefaultRemoteProxy(RegistrationRequest request, Registry registry)
public void beforeRelease(TestSession session)
TimeoutListenerIs executed before the session is released to the hub. If an exception is thrown, the slot that was associated with the session is considered corrupted and won't be released for future use.
You can check session.getInternalKey before timing out. internalkey==null usually means the initial POST /session hasn't been completed yet.For instance if you use web driver, that means the browser is in the process of being started. During that state, you can't really clean the resources properly.
beforeRelease in interface TimeoutListenersession - sessionpublic void afterCommand(TestSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
CommandListenerThrowing an exception will result in an error for the client.
afterCommand in interface CommandListenersession - sessionrequest - requestresponse - responsepublic void beforeCommand(TestSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
CommandListenerThrowing an exception will prevent the forward to the remote.
beforeCommand in interface CommandListenersession - sessionrequest - requestresponse - responsepublic HtmlRenderer getHtmlRender()
RemoteProxygetHtmlRender in interface RemoteProxygetHtmlRender in class BaseRemoteProxypublic boolean isAlive()
public void startPolling()
SelfHealingProxystartPolling in interface SelfHealingProxypublic void stopPolling()
SelfHealingProxystopPolling in interface SelfHealingProxypublic void addNewEvent(RemoteException event)
SelfHealingProxyaddNewEvent in interface SelfHealingProxyevent - RemoteException event to be called when something happenspublic void onEvent(java.util.List<RemoteException> events, RemoteException lastInserted)
SelfHealingProxyonEvent in interface SelfHealingProxyevents - list of RemoteExceptions occurredlastInserted - last event that occurredpublic TestSession getNewSession(java.util.Map<java.lang.String,java.lang.Object> requestedCapability)
getNewSession in interface RemoteProxygetNewSession in class BaseRemoteProxyrequestedCapability - the type of test the client is interested in performing.null otherwisepublic boolean isDown()
public void beforeSession(TestSession session)
For instance if a node registers: {"browserName":"firefox","version":"7.0","firefox_binary":"/home/ff7"} and later on a client requests {"browserName":"firefox","version":"7.0"} , the hub will automatically append the correct binary path to the desiredCapability before it's forwarded to the server. That way the version / install location mapping is done only once at the node level.
beforeSession in interface TestSessionListenersession - sessionif the setup applies to all the tests.public void afterSession(TestSession session)
TestSessionListenerIf the test crashes before a session is provided by the remote, session.externalKey will be null.
WARNING : after session should NOT throw exception. If an exception is thrown, the resources will NOT be released, as it could mean the remote is now corrupted.
afterSession in interface TestSessionListenersession - sessionpublic void teardown()
RemoteProxyteardown in interface RemoteProxyteardown in class BaseRemoteProxy