org.openqa.grid.internal
Interface RemoteProxy

All Superinterfaces:
Comparable<RemoteProxy>
All Known Implementing Classes:
BaseRemoteProxy, DefaultRemoteProxy, SeleniumRemoteProxy, WebDriverRemoteProxy

public interface RemoteProxy
extends Comparable<RemoteProxy>

Proxy to a remote server executing the tests.

The proxy keeps a state of what is happening on the remote server and knows if a new test can be run on the remote server. There are several reasons why a test could not be run on the specified remote server, for instance: if the RemoteProxy decides the remote server has reached the maximum number of concurrent sessions, or if the client has requested DesiredCapabilities we don't support e.g. asking for Chrome when we only support Firefox.


Method Summary
 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.
 Map<String,Object> 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.
 String getId()
          Returns the unique id for the node.
 int getMaxNumberOfConcurrentTestSessions()
          Returns the maximum number of concurrent tests that can run on this node.
 TestSession getNewSession(Map<String,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.
 Registry getRegistry()
          Retrieves the handle to the registry this remote proxy is registered with.
 URL getRemoteHost()
          Get the host the node is on.
 float getResourceUsageInPercent()
          Return how much resources are currently used on the proxy.
 org.json.JSONObject getStatus()
          Renders the status of the node as JSON.
 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(Map<String,Object> requestedCapability)
          Checks if the node has the capability requested.
 boolean isBusy()
          Indicates whether the node has any test slots in use.
 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.
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getTestSlots

List<TestSlot> getTestSlots()
Each test running on the node will occupy a test slot. A test slot can either be in use (have a session) or be available for scheduling (no associated session). This method allows retrieving the total state of the node, both test slots in use and those unused.

Returns:
the test slots.

getRegistry

Registry getRegistry()
Retrieves the handle to the registry this remote proxy is registered with.

Returns:
the registry.

getCapabilityHelper

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.

Returns:
the capability matcher.

setupTimeoutListener

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.


getId

String getId()
Returns the unique id for the node. The ID should not change throughout the life of the node.

Returns:
the unique node id.

teardown

void teardown()
If the RemoteProxy implementation also implements TimeoutListener, then this method will stop the thread used to monitor timeouts.


getConfig

Map<String,Object> getConfig()
Returns the configuration the node was initialized with.

Returns:
the node configuration.

getOriginalRegistrationRequest

RegistrationRequest getOriginalRegistrationRequest()
Returns the request sent from the node to the hub to register the proxy.

Returns:
the original node registration request.

getMaxNumberOfConcurrentTestSessions

int getMaxNumberOfConcurrentTestSessions()
Returns the maximum number of concurrent tests that can run on this node. NB: this number can be less than the number of test slots because a test slot only indicates what type of test session can be run on the remote. I.e., a node may allow N different types of tests, but only allow M tests to run at once, for M <= N.

Returns:

getRemoteHost

URL getRemoteHost()
Get the host the node is on. This is different from the URL used to communicate with the driver. For a local node that support both RC and WebDriver protocols, remoteHost=http://localhost:5555, but the underlying server will respond on urls http://localhost:5555/wd/hub (proxy.host + slot.path, where slot is a WebDriver slot) and http://localhost:5555/selenium-server/driver (proxy.host + slot.path, where slot is an RC slot).

Returns:
the host the node is running on.

getNewSession

TestSession getNewSession(Map<String,Object> requestedCapability)
Creates and returns a new test session if the current node has the resources and is ready to run the test.

Parameters:
requestedCapability - the type of test the client is interested in performing.
Returns:
a new TestSession if possible, null otherwise

getTotalUsed

int getTotalUsed()
Returns the total number of test slots used on this node.

Returns:
the total number of test slots in use.

getHtmlRender

HtmlRenderer getHtmlRender()
Returns the object responsible for rendering any information about the proxy in a Web application.

Returns:
the renderer.

getTimeOut

int getTimeOut()
Indicates how long a node should wait for a seemingly non-responsive test session before deciding it has timed out.

Returns:
the timeout in milliseconds.

getHttpClientFactory

org.openqa.selenium.remote.internal.HttpClientFactory getHttpClientFactory()
Retrieves the global factory for creating HTTP clients.

Returns:
The thread-safe HTTP client factory.

getStatus

org.json.JSONObject getStatus()
                              throws GridException
Renders the status of the node as JSON. Useful for APIs.

Returns:
the node status.
Throws:
GridException - if the node is down.

hasCapability

boolean hasCapability(Map<String,Object> requestedCapability)
Checks if the node has the capability requested.

The definition of "has" is defined by 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.

Parameters:
requestedCapability - the type of test the client is interested in performing.
Returns:
true if present

isBusy

boolean isBusy()
Indicates whether the node has any test slots in use. The node may still be able to accept more work even if it is busy.

Returns:
true if the node has any test slots in use.

getResourceUsageInPercent

float getResourceUsageInPercent()
Return how much resources are currently used on the proxy. Default implementation is runningTests / maxTests on the proxy. For a proxy with more knowledge about its resources, a finer implementation can also take into account CPU usage, RAM usage etc.

Returns:
the percentage of the available resource used. Can be greater than 100 if the grid is under heavy load.


Copyright © 2012. All Rights Reserved.