|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.talend.esb.servicelocator.client.internal.ServiceLocatorImpl
public class ServiceLocatorImpl
This is the entry point for clients of the Service Locator. To access the
Service Locator clients have to first connect to the
Service Locator to get a session assigned. Once the connection is established
the client will periodically send heart beats to the server to keep the
session alive.
The Service Locator provides the following operations.
| Nested Class Summary | |
|---|---|
class |
ServiceLocatorImpl.WatcherImpl
|
| Nested classes/interfaces inherited from interface org.talend.esb.servicelocator.client.ServiceLocator |
|---|
ServiceLocator.PostConnectAction |
| Field Summary | |
|---|---|
static ServiceLocator.PostConnectAction |
DO_NOTHING_ACTION
|
static byte[] |
EMPTY_CONTENT
|
static String |
LIVE
|
static NodePath |
LOCATOR_ROOT_PATH
|
| Constructor Summary | |
|---|---|
ServiceLocatorImpl()
|
|
| Method Summary | |
|---|---|
void |
connect()
Establish a connection to the Service Locator. |
protected org.apache.zookeeper.ZooKeeper |
createZooKeeper(CountDownLatch connectionLatch)
|
void |
disconnect()
Disconnects from a Service Locator server. |
SLEndpoint |
getEndpoint(QName serviceName,
String endpoint)
|
List<String> |
getEndpointNames(QName serviceName)
For the given service return all endpoints that currently registered at the Service Locator Service. |
List<SLEndpoint> |
getEndpoints(QName serviceName)
|
List<QName> |
getServices()
Return all services for which endpoints are registered at the Service Locator Service. |
List<String> |
lookup(QName serviceName)
For the given service return all endpoints that currently registered at the Service Locator Service. |
List<String> |
lookup(QName serviceName,
SLPropertiesMatcher matcher)
|
void |
register(EndpointProvider epProvider)
|
void |
register(QName serviceName,
String endpoint)
For a given service register the endpoint of a concrete provider of this service. |
void |
register(QName serviceName,
String endpoint,
SLProperties properties)
|
void |
removeEndpoint(QName serviceName,
String endpoint)
|
void |
setConnectionTimeout(int timeout)
Specify the time this client waits for a connection to
get established. |
void |
setLocatorEndpoints(String endpoints)
Specify the endpoints of all the instances belonging to the service locator ensemble this object might potentially be talking to when connecting. |
void |
setPostConnectAction(ServiceLocator.PostConnectAction postConnectAction)
|
void |
setSessionTimeout(int timeout)
Specify the time out of the session established at the server. |
void |
unregister(EndpointProvider epProvider)
|
void |
unregister(QName serviceName,
String endpoint)
For a given service unregister a previously registered endpoint. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final NodePath LOCATOR_ROOT_PATH
public static final String LIVE
public static final byte[] EMPTY_CONTENT
public static final ServiceLocator.PostConnectAction DO_NOTHING_ACTION
| Constructor Detail |
|---|
public ServiceLocatorImpl()
| Method Detail |
|---|
public void connect()
throws InterruptedException,
ServiceLocatorException
ServiceLocator.PostConnectAction is run. If the session
to the server expires because the server could not be reached within the
specified time, a reconnect is
automatically executed as soon as the server can be reached again.
Because after a session time out all registered endpoints are removed it
is important to specify a ServiceLocator.PostConnectAction that re-registers all
endpoints.
connect in interface ServiceLocatorInterruptedException - the current Thread was interrupted when waiting
for a successful connection to the ServiceLocator
ServiceLocatorException - the connect operation failed
public void disconnect()
throws InterruptedException,
ServiceLocatorException
connect again.
disconnect in interface ServiceLocatorInterruptedException - the current Thread was interrupted when waiting
for the disconnect to happen
ServiceLocatorException
public void register(QName serviceName,
String endpoint)
throws ServiceLocatorException,
InterruptedException
session timeout parameter the endpoint is
removed from the Service Locator. To ensure that all available endpoints
are re-registered when the client reconnects after a session expired a
ServiceLocator.PostConnectAction should be
set that registers all
endpoints.
register in interface ServiceLocatorserviceName - the name of the service the endpoint is registered for, must
not be nullendpoint - the endpoint to register, must not be null
ServiceLocatorException - the server returned an error
InterruptedException - the current Thread was interrupted when waiting
for a response of the ServiceLocator
public void register(QName serviceName,
String endpoint,
SLProperties properties)
throws ServiceLocatorException,
InterruptedException
register in interface ServiceLocatorServiceLocatorException
InterruptedException
public void register(EndpointProvider epProvider)
throws ServiceLocatorException,
InterruptedException
register in interface ServiceLocatorServiceLocatorException
InterruptedException
public void unregister(EndpointProvider epProvider)
throws ServiceLocatorException,
InterruptedException
unregister in interface ServiceLocatorServiceLocatorException
InterruptedException
public void unregister(QName serviceName,
String endpoint)
throws ServiceLocatorException,
InterruptedException
unregister in interface ServiceLocatorserviceName - the name of the service the endpoint is unregistered for, must
not be nullendpoint - the endpoint to unregister, must not be null
ServiceLocatorException - the server returned an error
InterruptedException - the current Thread was interrupted when waiting
for a response of the ServiceLocator
public void removeEndpoint(QName serviceName,
String endpoint)
throws ServiceLocatorException,
InterruptedException
removeEndpoint in interface ServiceLocatorServiceLocatorException
InterruptedException
public List<QName> getServices()
throws InterruptedException,
ServiceLocatorException
getServices in interface ServiceLocatorInterruptedException - the current Thread was interrupted when waiting
for a response of the ServiceLocator
ServiceLocatorException - the server returned an error
public List<SLEndpoint> getEndpoints(QName serviceName)
throws ServiceLocatorException,
InterruptedException
getEndpoints in interface ServiceLocatorServiceLocatorException
InterruptedException
public SLEndpoint getEndpoint(QName serviceName,
String endpoint)
throws ServiceLocatorException,
InterruptedException
getEndpoint in interface ServiceLocatorServiceLocatorException
InterruptedException
public List<String> getEndpointNames(QName serviceName)
throws ServiceLocatorException,
InterruptedException
getEndpointNames in interface ServiceLocatorserviceName - the name of the service for which to get the endpoints, must
not be null
ServiceLocatorException - the server returned an error
InterruptedException - the current Thread was interrupted when waiting
for a response of the ServiceLocator
public List<String> lookup(QName serviceName)
throws ServiceLocatorException,
InterruptedException
lookup in interface ServiceLocatorserviceName - the name of the service for which to get the endpoints, must
not be null
ServiceLocatorException - the server returned an error
InterruptedException - the current Thread was interrupted when waiting
for a response of the ServiceLocator
public List<String> lookup(QName serviceName,
SLPropertiesMatcher matcher)
throws ServiceLocatorException,
InterruptedException
lookup in interface ServiceLocatorServiceLocatorException
InterruptedExceptionpublic void setLocatorEndpoints(String endpoints)
connecting. The object will one by one pick an
endpoint (the order is non-deterministic) to connect to the service
locator until a connection is established.
endpoints - comma separated list of endpoints,each corresponding to a
service locator instance. Each endpoint is specified as a
host:port pair. At least one endpoint must be specified. Valid
exmaples are: "127.0.0.1:2181" or
"sl1.example.com:3210, sl2.example.com:3210, sl3.example.com:3210"public void setSessionTimeout(int timeout)
sessionTimeout - timeout in milliseconds, must be greater than zero and less
than 60000.public void setConnectionTimeout(int timeout)
for a connection to
get established.
connectionTimeout - timeout in milliseconds, must be greater than zeropublic void setPostConnectAction(ServiceLocator.PostConnectAction postConnectAction)
setPostConnectAction in interface ServiceLocator
protected org.apache.zookeeper.ZooKeeper createZooKeeper(CountDownLatch connectionLatch)
throws ServiceLocatorException
ServiceLocatorException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||