nenok
Class Services

java.lang.Object
  extended by nenok.Services

public class Services
extends Object

This utility class deals with Nenok services. It provides static methods to start, localize & terminate Nenok Processors. Furthermore, localization of Registry services is an important task of this class, which is implemented as multicast localization. To assert best possible lookup times a static JINI LookupCache is used.

Version:
1.2
Author:
Marc Pouly

Constructor Summary
Services()
           
 
Method Summary
static boolean destroyAllProcessors()
          Destroy all processors that were started from this class.
static boolean destroyProcessor(Processor proc)
          Destroys a given processor.
static boolean destroyProcessor(net.jini.id.Uuid pid)
          Destroys a given processor.
static Processor findProcessor(Locator locator)
          Finds the processor that hosts the valuation referenced by the given locator.
static Processor findProcessor(net.jini.id.Uuid pid)
          Finds the processor with the given ID, running of the given host.
static Registry findRegistry()
          Finds an arbitrary registry service via multicast.
static Registry findRegistry(String... urls)
          Finds an arbitrary registry service via unicast.
static Processor startLocalProcessor()
          Starts a new local processor thread.
static Processor startProcessor()
          Deprecated. Use startRemoteProcessor() instead.
static Processor startRemoteProcessor()
          Starts a new remote processor instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Services

public Services()
Method Detail

findProcessor

public static Processor findProcessor(Locator locator)
Finds the processor that hosts the valuation referenced by the given locator.

Parameters:
locator - The locator whose processor is to localize.
Returns:
The referenced processor or null, if locatozation failed.

findProcessor

public static Processor findProcessor(net.jini.id.Uuid pid)
Finds the processor with the given ID, running of the given host.

Parameters:
pid - The processor identifier.
Returns:
The referenced processor or null, if locatozation failed.

startProcessor

public static Processor startProcessor()
                                throws UnknownHostException
Deprecated. Use startRemoteProcessor() instead.

Starts a new remote processor instance.

Returns:
The proxy of the created processor.
Throws:
UnknownHostException - Exception thrown when the machine's host name cannot be localized.

startRemoteProcessor

public static Processor startRemoteProcessor()
                                      throws UnknownHostException
Starts a new remote processor instance.

Returns:
The proxy of the created processor.
Throws:
UnknownHostException - Exception thrown when the machine's host name cannot be localized.

startLocalProcessor

public static Processor startLocalProcessor()
Starts a new local processor thread.

Returns:
The reference to the created processor running in a new thread.

destroyProcessor

public static boolean destroyProcessor(net.jini.id.Uuid pid)
Destroys a given processor. This method unexports the processor service and cancels all leases. The service disappears when the leases expire.

Parameters:
pid - The identifier of the processor to destroy.
Returns:
true, if the processor has been destroyed successfully.

destroyProcessor

public static boolean destroyProcessor(Processor proc)
Destroys a given processor. This method unexports the processor service and cancels all leases. The service disappears when the leases expire.

Parameters:
proc - The processor to destroy.
Returns:
true, if the processor has been destroyed successfully.

destroyAllProcessors

public static boolean destroyAllProcessors()
Destroy all processors that were started from this class.

Returns:
true, if all processors have been destroyed successfully.

findRegistry

public static Registry findRegistry()
Finds an arbitrary registry service via multicast.

Returns:
A registry service or null, if localization failed.

findRegistry

public static Registry findRegistry(String... urls)
                             throws MalformedURLException,
                                    UnknownHostException
Finds an arbitrary registry service via unicast. Thereby, only registry services running on the given URLs are returned.

Parameters:
urls - URLs for unicast localization beyond subnets.
Returns:
A registry service or null, if localization failed.
Throws:
MalformedURLException - Invalide URL argument.
UnknownHostException - URL not resolvable.