osl.nameservice.simple
Class DefaultNameService

java.lang.Object
  |
  +--osl.nameservice.simple.DefaultNameService

public class DefaultNameService
extends java.lang.Object
implements NameService, TransportClient

This class defines the "default" implementation of the NameService interface. The default implementation correponds to the original implementation of the nameservice in the ActorManager defined in version 1.0b of the foundry. If you are planning on supporting fault-tolerant foundry nodes, or if you expect actors to migrate quite often (e.g. after every message processed) then this is not a terribly great nameservice to use. However, this nameservice SHOULD be useful for most common actor programs.

Version:
$Revision: 1.8 $ ($Date: 1999/12/29 03:16:21 $)
See Also:
Name, NameService, RequestHandler, DefaultName

Constructor Summary
DefaultNameService()
          The default constructor.
 
Method Summary
 void nsAddAddress(PhysicalAddress addr)
          Add a new address for authoritative bindings.
 void nsClear(Name naum)
          Instructs the nameservice to clear non-authoritative about the given name.
 Name nsGenerateName()
          Request a fresh name from the name service.
 void nsInitialize(Scheduler S)
          This function is required by the interface but will always return a runtime error.
 void nsInitialize(Scheduler S, TransportLayer T)
          Initialize this nameservice instance.
 boolean nsLocal(Name namu, PhysicalAddress localBind)
          Requests the nameservice to determine whether or not the given name is bound locally to the given physical address.
 PhysicalAddress nsLookup(Name namu)
          Requests the nameservice to resolve the binding of the given name.
 void nsRegister(Name namu, PhysicalAddress addr)
          Bind the given name to the given physical address.
 void nsRemove(Name namu, PhysicalAddress addr)
          Remove a binding between a name and a physical address.
 void transportException(TransportInstance target, TransportMessage msg, TransportException error)
          Called if the transport layer encounters an exception while attempting to send a previously queued message.
 void transportReceive(TransportInstance target, TransportMessage msg)
          Called by our transport layer when a new message has been received for this nameservice instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultNameService

public DefaultNameService()
The default constructor.
Method Detail

nsInitialize

public void nsInitialize(Scheduler S)
This function is required by the interface but will always return a runtime error.
Specified by:
nsInitialize in interface NameService
Parameters:
S - A reference to the scheduler which should be used to schedule nameservice threads.

nsInitialize

public void nsInitialize(Scheduler S,
                         TransportLayer T)
Initialize this nameservice instance.
Parameters:
S - A reference to the scheduler which should be used to schedule nameservice threads.
T - A reference to the transport layer which should be used for interactions between nameservice instances.

nsAddAddress

public void nsAddAddress(PhysicalAddress addr)
Add a new address for authoritative bindings. This is just a stub in the simple implementation.
Specified by:
nsAddAddress in interface NameService
Parameters:
addr - A PhysicalAddress which may be used for authoritative bindings.

nsGenerateName

public Name nsGenerateName()
Request a fresh name from the name service. The name is guaranteed to be unique relative to all currently running instances of the same type of nameservice.
Specified by:
nsGenerateName in interface NameService
Returns:
A fresh Name instance.

nsRegister

public void nsRegister(Name namu,
                       PhysicalAddress addr)
                throws MalformedNameException,
                       NoSuchAddressException
Bind the given name to the given physical address. This registration constitutes authoritative information. That is, the registration is stored permanently rather than in a local cache. Note that a name may have multiple bindings.
Specified by:
nsRegister in interface NameService
Parameters:
namu - The Name instance to bind.
addr - The PhysicalAddress which the name argument should be bound to. Henceforth, this addr will be a valid target for any messages sent to namu.
Throws:
MalformedNameException - Thrown if the given name argument is an illegal name representation. This may occur if a name from another nameservice is used or if a client attempts to spoof an illegal name.
NoSuchAddressException - Thrown if this nameservice instance does not maintain authoritative bindings for addr.

nsRemove

public void nsRemove(Name namu,
                     PhysicalAddress addr)
              throws MalformedNameException,
                     NameNotFoundException,
                     NoSuchAddressException
Remove a binding between a name and a physical address. Bindings may only be removed for names which are bound in authoritative tables. That is, a name may only be unbound if it was previously bound by the same instance of the nameservice.
Specified by:
nsRemove in interface NameService
Parameters:
namu - The Name to unbind.
addr - The PhysicalAddress which should no longer be associated with this name.
Throws:
MalformedNameException - Thrown if the given name argument is an illegal name representation. This may occur if a name from another nameservice is used or if a client attempts to spoof an illegal name.
NameNotFoundException - Thrown if the given name was never bound by this instance of the nameservice.
NoSuchAddressException - Thrown if this nameservice instance does not maintain authoritative bindings for addr.

nsLookup

public PhysicalAddress nsLookup(Name namu)
                         throws MalformedNameException,
                                NameNotFoundException,
                                NoBindingException
Requests the nameservice to resolve the binding of the given name.
Specified by:
nsLookup in interface NameService
Parameters:
namu - The Name instance to be resolved.
Throws:
MalformedNameException - Thrown if the given name argument is an illegal name representation. This may occur if a name from another nameservice is used or if a client attempts to spoof an illegal name.
NameNotFoundException - Thrown if no binding exists for the given name.
NoBindingException - Thrown if the given name currently has no associated PhysicalAddress binding.

nsLocal

public boolean nsLocal(Name namu,
                       PhysicalAddress localBind)
                throws MalformedNameException,
                       NoSuchAddressException
Requests the nameservice to determine whether or not the given name is bound locally to the given physical address. This amounts to determining whether or not the binding namu->localBind is part of the authoritative information for this nameservice instance.
Specified by:
nsLocal in interface NameService
Parameters:
namu - The Name to be looked up.
localBind - The PhysicalAddress which should be verified as a local binding of the given name.
Throws:
MalformedNameException - Thrown if the given name argument is an illegal name representation. This may occur if a name from another nameservice is used or if a client attempts to spoof an illegal name.
NoSuchAddressException - Thrown if this nameservice instance does not maintain authoritative bindings for addr.

nsClear

public void nsClear(Name naum)
             throws MalformedNameException
Instructs the nameservice to clear non-authoritative about the given name. Typically, this means clearing any cache entries associated with the given name. Note that no action is taken if namu refers to an authoritative entry.
Specified by:
nsClear in interface NameService
Parameters:
namu - The Name for which non-authoritative information should be cleared.
Throws:
MalformedNameException - Thrown if the given name argument is an illegal name representation. This may occur if a name from another nameservice is used or if a client attempts to spoof an illegal name.

transportReceive

public void transportReceive(TransportInstance target,
                             TransportMessage msg)
Called by our transport layer when a new message has been received for this nameservice instance.
Specified by:
transportReceive in interface TransportClient
Parameters:
target - The TransportInstance reference that this message is targeted for. By assumption, the client is the owner of this instance.
msg - The TransportMessage that was received for this connection.

transportException

public void transportException(TransportInstance target,
                               TransportMessage msg,
                               TransportException error)
Called if the transport layer encounters an exception while attempting to send a previously queued message. If a client holds several connections it is their responsibility to demultiplex incoming messages as appropriate. The target field may be used to determine which connection this message is associated with.
Specified by:
transportException in interface TransportClient
Parameters:
target - The TransportInstance reference that the original message was sent from. By assumption, the client is the owner of this instance.
msg - The original TransportMessage that was queued to be sent to the remote host.
error - The TransportException which encapsulates the error encountered during transmission.