public class BaseRemoteProxy extends java.lang.Object implements RemoteProxy
Modifier and Type | Class and Description |
---|---|
(package private) class |
BaseRemoteProxy.CleanUpThread |
Modifier and Type | Field and Description |
---|---|
private BaseRemoteProxy.CleanUpThread |
cleanUpThread |
protected GridNodeConfiguration |
config |
private java.lang.String |
id |
private static java.util.logging.Logger |
log |
private Registry |
registry |
protected java.net.URL |
remoteHost |
private HtmlRenderer |
renderer |
private RegistrationRequest |
request |
private boolean |
stop |
private java.util.List<TestSlot> |
testSlots |
Constructor and Description |
---|
BaseRemoteProxy(RegistrationRequest request,
Registry registry)
Create the proxy from the info sent by the remote.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(RemoteProxy o) |
boolean |
equals(java.lang.Object obj) |
private com.google.gson.JsonObject |
extractObject(org.apache.http.HttpResponse resp) |
void |
forceSlotCleanerRun()
Internal use only
|
CapabilityMatcher |
getCapabilityHelper()
Returns the capability matcher that will be used to by the remote proxy
to determine whether its test slots can run a requested test session.
|
GridNodeConfiguration |
getConfig()
Returns the configuration the node was initialized with.
|
HtmlRenderer |
getHtmlRender()
Returns the object responsible for rendering any information about the proxy in a Web application.
|
org.openqa.selenium.remote.internal.HttpClientFactory |
getHttpClientFactory()
Retrieves the global factory for creating HTTP clients.
|
java.lang.String |
getId()
Returns the unique id for the node.
|
long |
getLastSessionStart() |
int |
getMaxNumberOfConcurrentTestSessions()
Returns the maximum number of concurrent tests that can run on this node.
|
static <T extends RemoteProxy> |
getNewInstance(RegistrationRequest request,
Registry registry)
Takes a registration request and return the RemoteProxy associated to it.
|
TestSession |
getNewSession(java.util.Map<java.lang.String,java.lang.Object> requestedCapability)
Creates and returns a new test session if the current node has the resources and is ready to run the test.
|
RegistrationRequest |
getOriginalRegistrationRequest()
Returns the request sent from the node to the hub to register the proxy.
|
private java.lang.String |
getPath(org.openqa.selenium.remote.DesiredCapabilities capability) |
private SeleniumProtocol |
getProtocol(org.openqa.selenium.remote.DesiredCapabilities capability) |
Registry |
getRegistry()
Retrieves the handle to the registry this remote proxy is registered with.
|
java.net.URL |
getRemoteHost()
Get the host the node is on.
|
float |
getResourceUsageInPercent()
Return how much resources are currently used on the proxy.
|
com.google.gson.JsonObject |
getStatus()
Renders the status of the node as JSON.
|
java.util.List<TestSlot> |
getTestSlots()
Each test running on the node will occupy a test slot.
|
int |
getTimeOut()
Indicates how long a node should wait for a seemingly non-responsive test session before deciding it has timed out.
|
int |
getTotalUsed()
Returns the total number of test slots used on this node.
|
boolean |
hasCapability(java.util.Map<java.lang.String,java.lang.Object> requestedCapability)
Checks if the node has the capability requested.
|
int |
hashCode() |
boolean |
isBusy()
Indicates whether the node has any test slots in use.
|
private java.util.Map<java.lang.String,java.lang.Object> |
mergeConfig(java.util.Map<java.lang.String,java.lang.Object> configuration1,
java.util.Map<java.lang.String,java.lang.Object> configuration2)
merge the param from config 1 and 2.
|
void |
setupTimeoutListener()
If the RemoteProxy implementation also implements TimeoutListener, then this method
will start up the thread used to monitor timeouts and handle cleanup of timed out resources.
|
void |
teardown()
If the RemoteProxy implementation also implements TimeoutListener, then this method
will stop the thread used to monitor timeouts.
|
java.lang.String |
toString() |
private final RegistrationRequest request
private static final java.util.logging.Logger log
protected volatile java.net.URL remoteHost
protected final GridNodeConfiguration config
private final java.util.List<TestSlot> testSlots
private final Registry registry
private final java.lang.String id
private volatile boolean stop
private BaseRemoteProxy.CleanUpThread cleanUpThread
private final HtmlRenderer renderer
public BaseRemoteProxy(RegistrationRequest request, Registry registry)
If maxSession is not specified, default to 1 = max number of tests running at a given time will be 1.
For each capability, maxInstances is defaulted to 1 if not specified = max number of test of each capability running at a time will be 1. maxInstances for firefox can be > 1. IE won't support it.
request
- The requestregistry
- The registry to usepublic java.util.List<TestSlot> getTestSlots()
RemoteProxy
getTestSlots
in interface RemoteProxy
public Registry getRegistry()
RemoteProxy
getRegistry
in interface RemoteProxy
public CapabilityMatcher getCapabilityHelper()
RemoteProxy
getCapabilityHelper
in interface RemoteProxy
private SeleniumProtocol getProtocol(org.openqa.selenium.remote.DesiredCapabilities capability)
private java.lang.String getPath(org.openqa.selenium.remote.DesiredCapabilities capability)
public void setupTimeoutListener()
RemoteProxy
setupTimeoutListener
in interface RemoteProxy
private java.util.Map<java.lang.String,java.lang.Object> mergeConfig(java.util.Map<java.lang.String,java.lang.Object> configuration1, java.util.Map<java.lang.String,java.lang.Object> configuration2)
configuration1
- The first configuration to merge (recessive)configuration2
- The second configuration to merge (dominant)public java.lang.String getId()
RemoteProxy
getId
in interface RemoteProxy
public void teardown()
RemoteProxy
teardown
in interface RemoteProxy
public void forceSlotCleanerRun()
public GridNodeConfiguration getConfig()
RemoteProxy
getConfig
in interface RemoteProxy
public RegistrationRequest getOriginalRegistrationRequest()
RemoteProxy
getOriginalRegistrationRequest
in interface RemoteProxy
public int getMaxNumberOfConcurrentTestSessions()
RemoteProxy
getMaxNumberOfConcurrentTestSessions
in interface RemoteProxy
public java.net.URL getRemoteHost()
RemoteProxy
getRemoteHost
in interface RemoteProxy
public TestSession getNewSession(java.util.Map<java.lang.String,java.lang.Object> requestedCapability)
RemoteProxy
getNewSession
in interface RemoteProxy
requestedCapability
- the type of test the client is interested in performing.null
otherwisepublic int getTotalUsed()
RemoteProxy
getTotalUsed
in interface RemoteProxy
public boolean hasCapability(java.util.Map<java.lang.String,java.lang.Object> requestedCapability)
RemoteProxy
CapabilityMatcher.matches(Map, Map)
hasCapability = true
doesn't mean the test cast start just now, only that the proxy will be
able to run a test requiring that capability at some point.hasCapability
in interface RemoteProxy
requestedCapability
- the type of test the client is interested in performing.true
if presentpublic boolean isBusy()
RemoteProxy
isBusy
in interface RemoteProxy
true
if the node has any test slots in use.public static <T extends RemoteProxy> T getNewInstance(RegistrationRequest request, Registry registry)
T
- RemoteProxy subclassrequest
- The requestregistry
- The registry to usepublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int compareTo(RemoteProxy o)
compareTo
in interface java.lang.Comparable<RemoteProxy>
public java.lang.String toString()
toString
in class java.lang.Object
public HtmlRenderer getHtmlRender()
RemoteProxy
getHtmlRender
in interface RemoteProxy
public int getTimeOut()
RemoteProxy
getTimeOut
in interface RemoteProxy
public org.openqa.selenium.remote.internal.HttpClientFactory getHttpClientFactory()
RemoteProxy
getHttpClientFactory
in interface RemoteProxy
public com.google.gson.JsonObject getStatus() throws GridException
RemoteProxy
getStatus
in interface RemoteProxy
GridException
- If the node if down or doesn't recognize the /wd/hub/status request.private com.google.gson.JsonObject extractObject(org.apache.http.HttpResponse resp) throws java.io.IOException
java.io.IOException
public float getResourceUsageInPercent()
RemoteProxy
getResourceUsageInPercent
in interface RemoteProxy
public long getLastSessionStart()
getLastSessionStart
in interface RemoteProxy