tango.net.cluster.NetworkRegistry

License:

BSD style: see license.txt

Version:

Apr 2004: Initial release Dec 2006: Outback version Apr 2007: Delegate revision

Author:

Kris
class NetworkRegistry #
Bare framework for registering and creating serializable objects. Such objects are intended to be transported across a local network and re-instantiated at some destination node.
Each IMessage exposes the means to write, or freeze, its content. An IPickleFactory provides the means to create a new instance of itself populated with thawed data. Frozen objects are uniquely identified by a guid exposed via the interface. Responsibility of maintaining uniqueness across said identifiers lies in the hands of the developer.
static this() #
this(typeof(registry) registry = null) #
IMessage lookup(char[] guid) [synchronized, final] #
Synchronized Factory lookup of the guid
void enroll(IMessage target) [synchronized, final] #
Add the provided Factory to the registry. Note that one cannot change a registration once it is placed. Neither can one remove registered item. This is done to avoid issues when trying to synchronize servers across a farm, which may still have live instances of "old" objects waiting to be passed around the cluster. New versions of an object should be given a distinct guid from the prior version; appending an incremental number may well be sufficient for your needs.
void freeze(IWriter output, IMessage target) [final] #
Serialize an Object. Objects are written in Network-order, and are prefixed by the guid exposed via the IMessage interface. This guid is used to identify the appropriate factory when reconstructing the instance.
IMessage thaw(IReader input, IMessage host = null) [final] #
Create a new instance of a registered class from the content made available via the given reader. The factory is located using the provided guid, which must match an enrolled factory.
Note that only the factory lookup is synchronized, and not the instance construction itself. This is intentional, and limits how long the calling thread is stalled
NetworkRegistry dup() [final] #
Duplicate the registry
void error(char[] msg, char[] guid) [private, static] #