com.iphrase.runtime
Class ConnectorFactory
java.lang.Object
|
+--com.iphrase.runtime.ConnectorFactory
- public class ConnectorFactory
- extends java.lang.Object
A ConnectorFactory instance is used to create Connector
objects.
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ConnectorFactory
public ConnectorFactory()
newInstance
public static ConnectorFactory newInstance()
throws ConfigurationError
- Obtain a singleton instance of a ConnectorFactory.
- Returns:
ConnectorFactory
singleton instance, never null- Throws:
com.iphrase.exception.ConfigurationError
-
getConnector
public Connector getConnector(java.util.List servers,
float timeoutSeconds,
float retrySeconds)
throws ArgumentError
- Create and return a properly-constructed
Connector
.
- Parameters:
servers
- List of server host[:port] strings that will answer queries.
Queries are round-robined across these servers. If any server becomes
unreachable or unresponsive it is temporarily removed from the list
and retried after retryTimeoutSeconds (failover).timeoutSeconds
- Wait for a response from an
iPhrase server no more than this many seconds.retrySeconds
- Wait this many seconds before
retrying a "dead" iPhrase server.- Returns:
- new
Connector
- Throws:
com.iphrase.exception.ArgumentError
-
getConnectorSingleton
public Connector getConnectorSingleton(java.util.List servers,
float timeoutSeconds,
float retrySeconds)
throws ArgumentError
- Create and return a properly-constructed
Connector
singleton.
If getConnectorSingleton has already been called, and hence a connector
singleton already exists, then this call will compare all arguments with
the existing singleton. If all corresponding arguments are identical,
the existing singleton will be returned. Else, a new singleton will be
created and returned.
Note that, the advantage of using a singleton is that an application
which uses more than one server for load distribution can count on the
singleton instance to preserve the state of the most recently-used server.
An application which uses different servers for different requests should
not use a singleton connector, to avoid concurrent request conflicts.
- Parameters:
servers
- List of server host[:port] strings that will answer queries.
Queries are round-robined across these servers. If any server becomes
unreachable or unresponsive it is temporarily removed from the list
and retried after retryTimeoutSeconds (failover).timeoutSeconds
- Wait for a response from an
iPhrase server no more than this many seconds.retrySeconds
- Wait this many seconds before
retrying a "dead" iPhrase server.- Returns:
- existing singleton
Connector
if all corresponding arguments
are the same, otherwise a new singleton Connector
- Throws:
com.iphrase.exception.ArgumentError
-