SLP-Deployments
- Introduction to the Service Location Protocol
- Deployment scenarios
- Examples
- Why LiveTribe :: SLP does not implement RFC 2614
- Frequently Asked Questions
Deployment choices provided by LiveTribe :: SLP
LiveTribe :: SLP ships the following entities:
- DirectoryAgent server, a standalone server, normally started in a separate JVM that is deployed once in a subnet host, that serves as an SLP directory agent for the subnet. It caches services exported by SLP service agents.
- ServiceAgent server, a standalone server, normally started in a separate JVM that is deployed once per host, that serves as an SLP service agent for the host. It exports services on behalf of service providers present on that host.
- ServiceAgent, an embeddable server, normally started in-VM with a service provider that can be deployed any number of times per host, that serves as an SLP service agent for a service provider. It exports services on behalf of a single service provider.
- ServiceAgent client, a client object that does not use threads nor listen on IP ports, normally used by a service provider to export its services to a ServiceAgent server deployed on the same host. It exports services on behalf of service providers and requires a ServiceAgent server deployed on the same host. It does not listen for SLP directory agents appearing or disappearing on the subnet.
- UserAgent, an embeddable server, normally started in-VM with a client application that can be deployed any number of times per host, that serves as an SLP user agent for a client application. It finds services and listens for service notifications emitted by SLP service agents.
- UserAgent client, a client object that does not use threads nor listen on IP ports, normally used by a client application to find services on the subnet. It does not listen for service notifications.
DirectoryAgent server
The DirectoryAgent server is normally started in a separate JVM on a host, to serve as an SLP directory agent for the subnet.
$ java -cp livetribe-slp-2.x.jar \
org.livetribe.slp.da.StandardDirectoryAgentServer path/to/livetribe-slp.properties
The program argument is a path to a properties file containing the DirectoryAgent server configuration that overrides the default configuration.
When a directory agent is deployed on a network, the behavior of service agents and user agents is modified as follows:
- Service agents
- forward service registrations and deregistrations to the directory agent
- do not emit notifications of service registration (though this is configurable)
- User agents
- contact the directory agent to find services, not the service agents
The presence of a directory agent reduces network traffic generated by SLP, since service registrations, service deregistrations and service lookups are done via TCP and not via multicast. The use of multicast is limited to initial discovery of directory agents, and can be avoided completely by configuring service agents and user agents with the directory agent address.
- contact the directory agent to find services, not the service agents
It is possible to configure the scopes, the attributes and the language of the DirectoryAgent server by specifying the following keys in the properties file:
# A comma separated list of scopes net.slp.useScopes = scope1,scope2 # The attributes net.slp.DAAttributes = (description=German Directory Agent) # German language net.slp.locale = de
ServiceAgent server
The ServiceAgent server is normally started in a separate JVM on a host, to serve as an SLP service agent for the host.
$ java -cp livetribe-slp-2.x.jar \
org.livetribe.slp.sa.StandardServiceAgentServer path/to/livetribe-slp.properties
The program argument is a path to a properties file containing the ServiceAgent server configuration that overrides the default configuration.
The ServiceAgent server serve as an SLP service agent for all service providers residing on a host. Service providers can make use of a ServiceAgent client (see below) to register and deregister services.
An important difference between a ServiceAgent server and a plain ServiceAgent (see below) is that a ServiceAgent server does not perform any renewal of the service registration when the lifetime of the service is about to expire. ServiceURLs have a default lifetime of 3 hours and if the service registration is not renewed within the lifetime, service agents and directory agents will cease to advertise the service even if the service is available.
It is responsibility of the service provider to renew the service registration with the ServiceAgent server by re-registering the service before the lifetime expires using a ServiceAgent client (see below).
It is possible to configure the scopes, the attributes and the language of the ServiceAgent server by specifying the following keys in the properties file:
# A comma separated list of scopes net.slp.useScopes = admin # The attributes net.slp.SAAttributes = (admin=true),(authnMechs=KERBEROS_V5,OTP) # French language net.slp.locale = fr
A ServiceAgent server can be configured with a static list of directory agent addresses; in this way, the ServiceAgent server does not use multicast to discover directory agents, but relies on the configured list specified in the configuration file:
[in the properties file] # Specify a comma separated list of IP addresses of known directory agents net.slp.DAAddresses = 192.168.0.1
ServiceAgent
The ServiceAgent is normally started in-VM with the service provider (and as such it shares the lifetime of the service provider), to serve as an SLP service agent for the service provider.
Settings settings = PropertiesSettings.from(new File("path/to/livetribe-slp.properties"));
ServiceAgent sa = SLP.newServiceAgent(settings);
sa.start();
The ServiceAgent may be configured from a properties file and must be started calling method start().
Services can be registered indifferently either before or after start(), and are automatically deregistered when stop() is called.
ServiceURL serviceURL = new ServiceURL("service:jmx:rmi:///jndi/rmi:///myservice");
ServiceInfo service = new ServiceInfo(serviceURL, "en", Scopes.DEFAULT, Attributes.NONE));
sa.register(service);
ServiceAgents, by default, perform a periodic renewal of the service registration on behalf of the service provider.
This feature can be turned off:
[in the properties file] # Turns off periodic renewal livetribe.slp.sa.service.renewal.enabled = false ---- [in the java source code] // Turns off periodic renewal Settings settings = new MapSettings(); settings.put(Keys.SA_SERVICE_RENEWAL_ENABLED_KEY, false); ServiceAgent sa = SLP.newServiceAgent(settings); sa.start();
It is possible to configure scopes, attributes, language and list of directory agents in the same way of ServiceAgent servers.
ServiceAgent client
The ServiceAgent client is the client object used by a service provider to export its services to a ServiceAgent server deployed on the same host.
The ServiceAgent client must be used by the service provider to periodically renew the service registration, and must be used by the service provider to deregister the service when the service provider does not want to advertise the service anymore.
Registering a service:
int lifetime = 60; // Lifetime is 1 minute
ServiceURL serviceURL = new ServiceURL("service:jmx:rmi:///jndi/rmi:///myservice", lifetime);
ServiceInfo service = new ServiceInfo(serviceURL, "en", Scopes.DEFAULT, Attributes.NONE));
ServiceAgentClient sac = SLP.newServiceAgentClient(null); // Use default settings
sac.register(service);
Periodically renewing the service:
Runnable renewer = new Runnable()
{
public void run()
{
sac.register(service);
}
}
ScheduledExecutorService s = Executors.newSingleThreadScheduledExecutor();
// Wait only 45 seconds to be sure to renew in time
s.scheduleAtFixedRate(renewer, 45, lifetime, TimeUnit.SECONDS);
Deregistering the service:
sac.deregister(service.getServiceURL(), service.getLanguage());
A ServiceAgent client connects to the ServiceAgent server, that is expected to be on the same host. It is possible to configure a ServiceAgent client to connect to a different address than the loopback (127.0.0.1) address:
[in the properties file] # Connects to a different address livetribe.slp.sa.client.connect.address = 192.168.0.2 ---- [in the java source code] // Connects to a different address Settings settings = new MapSettings(); settings.put(Keys.SA_CLIENT_CONNECT_ADDRESS, "192.168.0.2"); ServiceAgentClient sac = SLP.newServiceAgentClient(settings); sac.start();
UserAgent
The UserAgent is normally started in-VM with the client application, to serve as a user agent for the client application. A user agent finds services on behalf of the client application.
Settings settings = PropertiesSettings.from(new File("path/to/livetribe-slp.properties"));
UserAgent ua = SLP.newUserAgent(settings);
ua.start();
The UserAgent may be configured from a properties file and must be started calling method start().
Finding services:
// Find the JMX services available in the network
List<ServiceInfo> services =
ua.findServices(new ServiceType("service:jmx"), // JMX services...
null, // ...no matter the language...
Scopes.NONE, // ...no matter the scope...
null); // ...no matter the attributes
A UserAgent does not cache the services it finds, because services have a lifetime and caching them may result in the services to expire; the client application may mistakenly think that the services are available, when in reality the service provider is not available anymore.
However, UserAgents listen for service notifications (emitted by ServiceAgents and ServiceAgent servers when services are registered, updated or deregistered, in absence of directory agents deployed in the network) and listen for directory agent advertisements (when directory agents are deployed in the network).
It is possible to configure the list of directory agents in the same way of ServiceAgent servers.
UserAgent client
The UserAgent client is the client object used by a client application to find services in a network. Differently from UserAgent, it does not listen for service notifications or for directory agent advertisements.
Settings settings = PropertiesSettings.from(new File("path/to/livetribe-slp.properties"));
UserAgentClient uac = SLP.newUserAgentClient(settings);
Finding the services and configuring the list of directory agents is done in the same way of UserAgent.