org.openqa.grid.internal
Class RemoteProxy

java.lang.Object
  extended by org.openqa.grid.internal.RemoteProxy
All Implemented Interfaces:
java.lang.Comparable<RemoteProxy>
Direct Known Subclasses:
DefaultRemoteProxy

public class RemoteProxy
extends java.lang.Object
implements java.lang.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.


Field Summary
protected  java.net.URL remoteHost
           
 
Constructor Summary
RemoteProxy(RegistrationRequest request, Registry registry)
          Create the proxy from the info sent by the remote.
 
Method Summary
 int compareTo(RemoteProxy o)
           
 boolean equals(java.lang.Object obj)
           
 CapabilityMatcher getCapabilityHelper()
           
 java.util.Map<java.lang.String,java.lang.Object> getConfig()
           
 HtmlRenderer getHtmlRender()
           
 HttpClientFactory getHttpClientFactory()
           
 java.lang.String getId()
          get the unique id for the node.
 int getMaxNumberOfConcurrentTestSessions()
          return the max number of tests that can run on this remote at a given time.
static
<T extends RemoteProxy>
T
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)
          return a new test session if the current proxy has the resources and is ready to run the test.
 RegistrationRequest getOriginalRegistrationRequest()
          return the registration request that created the proxy in the first place.
 Registry getRegistry()
           
 java.net.URL getRemoteHost()
          Get the host the node is on.
 java.util.List<TestSlot> getTestSlots()
           
 int getTimeOut()
          im millis
 int getTotalUsed()
          returns the total number of test slots used on this proxy
 int hashCode()
           
protected  boolean isBusy()
           
 void setCapabilityHelper(CapabilityMatcher capabilityHelper)
           
 void setupTimeoutListener()
           
 void teardown()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

remoteHost

protected volatile java.net.URL remoteHost
Constructor Detail

RemoteProxy

public RemoteProxy(RegistrationRequest request,
                   Registry registry)
Create the proxy from the info sent by the remote.

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.

Parameters:
request - The request
registry - The registry to use
Method Detail

getTestSlots

public java.util.List<TestSlot> getTestSlots()

getRegistry

public Registry getRegistry()

getCapabilityHelper

public CapabilityMatcher getCapabilityHelper()

setCapabilityHelper

public void setCapabilityHelper(CapabilityMatcher capabilityHelper)

setupTimeoutListener

public void setupTimeoutListener()

getId

public java.lang.String getId()
get the unique id for the node. Usually the url it listen on is a good id. If the network keeps changing and the IP of the node is updated, you need to define nodes with a different id.

Returns:
the id

teardown

public void teardown()

getConfig

public java.util.Map<java.lang.String,java.lang.Object> getConfig()

getOriginalRegistrationRequest

public RegistrationRequest getOriginalRegistrationRequest()
return the registration request that created the proxy in the first place.

Returns:
a RegistrationRequest, doh!

getMaxNumberOfConcurrentTestSessions

public int getMaxNumberOfConcurrentTestSessions()
return the max number of tests that can run on this remote at a given time.

Returns:
an int, doh!

getRemoteHost

public java.net.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 selenium1 and webdriver protocol, remoteHost=http://localhost:5555 , but the underlying server with 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 a selenium1 slot )

Returns:
the host the remote listens on.

getNewSession

public TestSession getNewSession(java.util.Map<java.lang.String,java.lang.Object> requestedCapability)
return a new test session if the current proxy has the resources and is ready to run the test.

Parameters:
requestedCapability - .
Returns:
a new TestSession if possible, null otherwise

getTotalUsed

public int getTotalUsed()
returns the total number of test slots used on this proxy

Returns:
an int

isBusy

protected boolean isBusy()
Returns:
true if the remote does something. busy = true doesn't prevent the remote from accepting more tasks.

getNewInstance

public static <T extends RemoteProxy> T getNewInstance(RegistrationRequest request,
                                                       Registry registry)
Takes a registration request and return the RemoteProxy associated to it. It can be any class extending RemoteProxy.

Parameters:
request - The request
registry - The registry to use
Returns:
a new instance built from the request.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(RemoteProxy o)
Specified by:
compareTo in interface java.lang.Comparable<RemoteProxy>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getHtmlRender

public HtmlRenderer getHtmlRender()

getTimeOut

public int getTimeOut()
im millis

Returns:
an int

getHttpClientFactory

public HttpClientFactory getHttpClientFactory()


Copyright © 2011. All Rights Reserved.