ibis.ipl
Interface Registry


public interface Registry

A Registry provides methods for storing and retrieving ReceivePortIdentifiers or IbisIdentifiers with arbitrary names.


Method Summary
 void bind(java.lang.String name, ReceivePortIdentifier port)
          Binds the specified name to the specified identifier.
 void dead(IbisIdentifier ibis)
          Notifies that an Ibis instance must be assumed to be dead.
 IbisIdentifier elect(java.lang.String election)
          Elects a single candidate from a number of candidates calling this method with a specified election name.
 IbisIdentifier getElectionResult(java.lang.String election)
          Gets the result of an election, without being a candidate.
 java.lang.String[] listNames(java.lang.String regex)
          Returns an array of strings representing names that have a receiveport identifier bound to it and match the given regular expression.
 ReceivePortIdentifier[] listReceivePorts(IbisIdentifier ident)
          Returns the list of receiveport identifiers that are registered with this registry, and have the specified ibis as their controlling ibis.
 IbisIdentifier lookupIbis(java.lang.String name)
          Locates the IbisIdentifier that has been bound to the specified name.
 IbisIdentifier lookupIbis(java.lang.String name, long timeout)
          Locates the IbisIdentifier that has been bound to the specified name.
 ReceivePortIdentifier lookupReceivePort(java.lang.String name)
          Locates the ReceivePortIdentifier that has been bound to the specified name.
 ReceivePortIdentifier lookupReceivePort(java.lang.String name, long timeout)
          Locates the ReceivePortIdentifier that has been bound to the specified name.
 void maybeDead(IbisIdentifier ibis)
          Notifies that an Ibis instance is suspected to be dead.
 void rebind(java.lang.String name, ReceivePortIdentifier port)
          Rebinds the specified name to the specified identifier.
 void unbind(java.lang.String name)
          Removes any binding for the specified name.
 

Method Detail

lookupReceivePort

public ReceivePortIdentifier lookupReceivePort(java.lang.String name)
                                        throws java.io.IOException
Locates the ReceivePortIdentifier that has been bound to the specified name. The method blocks until a receiveport with the specified name is found.

Parameters:
name - name of the receiveport.
Returns:
the identifier.
Throws:
java.io.IOException - is thrown in case of trouble.

lookupReceivePort

public ReceivePortIdentifier lookupReceivePort(java.lang.String name,
                                               long timeout)
                                        throws java.io.IOException
Locates the ReceivePortIdentifier that has been bound to the specified name. The method blocks until a receiveport with the specified name is found, or the timeout expires. If timeout is 0, the method behaves as if no timeout was given.

Parameters:
name - name of the receiveport.
timeout - the timeout, in milliseconds.
Returns:
the identifier.
Throws:
ConnectionTimedOutException - is thrown when the timeout expires.
java.io.IOException - is thrown in case of trouble.

lookupIbis

public IbisIdentifier lookupIbis(java.lang.String name)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
Locates the IbisIdentifier that has been bound to the specified name. The method blocks until an Ibis with the specified name is found.

Parameters:
name - name of the ibis.
Returns:
the identifier
Throws:
java.lang.ClassNotFoundException - is thrown if an IbisIdentifier is returned whose class is locally unknown.
java.io.IOException - is thrown in case of trouble.

lookupIbis

public IbisIdentifier lookupIbis(java.lang.String name,
                                 long timeout)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
Locates the IbisIdentifier that has been bound to the specified name. The method blocks until an Ibis with the specified name is found, or the timeout expires. If timeout is 0, the method behaves as if no timeout was given.

Parameters:
name - name of the ibis.
timeout - the timeout, in milliseconds.
Returns:
the identifier
Throws:
java.lang.ClassNotFoundException - is thrown if an IbisIdentifier is returned whose class is locally unknown.
ConnectionTimedOutException - is thrown when the timeout expires.
java.io.IOException - is thrown in case of trouble.

listReceivePorts

public ReceivePortIdentifier[] listReceivePorts(IbisIdentifier ident)
                                         throws java.io.IOException,
                                                java.lang.ClassNotFoundException
Returns the list of receiveport identifiers that are registered with this registry, and have the specified ibis as their controlling ibis.

Throws:
java.lang.ClassNotFoundException - is thrown if an any receiveport identifier is returned whose class is locally unknown.
java.io.IOException - is thrown in case of trouble.

elect

public IbisIdentifier elect(java.lang.String election)
                     throws java.io.IOException,
                            java.lang.ClassNotFoundException
Elects a single candidate from a number of candidates calling this method with a specified election name. Note that this has nothing to do with a real election: it is not like "most votes count". It is more like: "the first one in gets it". When it is detected the winner of the election has left or has died a new winner will automatically be elected and returned on the next call of this function.

Parameters:
election - the name of this election.
Returns:
the Ibis identifier of the elected Ibis instance.
Throws:
java.lang.ClassNotFoundException - is thrown if an Ibis identifier is returned whose class is locally unknown.
java.io.IOException - is thrown in case of trouble.

getElectionResult

public IbisIdentifier getElectionResult(java.lang.String election)
                                 throws java.io.IOException,
                                        java.lang.ClassNotFoundException
Gets the result of an election, without being a candidate.

Parameters:
election - the name of this election.
Returns:
the Ibis identifier of the elected Ibis instance.
Throws:
java.lang.ClassNotFoundException - is thrown if an Ibis identifier is returned whose class is locally unknown.
java.io.IOException - is thrown in case of trouble.

bind

public void bind(java.lang.String name,
                 ReceivePortIdentifier port)
          throws java.io.IOException
Binds the specified name to the specified identifier. If the name already is bound, an exception is thrown.

Parameters:
name - the name to which a port is being bound.
port - the receiveport identifier to which a binding is made.
Throws:
BindingException - is thrown when the specified name is already bound.
java.io.IOException - is thrown in case of trouble.

rebind

public void rebind(java.lang.String name,
                   ReceivePortIdentifier port)
            throws java.io.IOException
Rebinds the specified name to the specified identifier. If the name already is bound, the old binding is discarded.

Parameters:
name - the name to which a port is being bound.
port - the receiveport identifier to which a binding is made.
Throws:
java.io.IOException - is thrown in case of trouble.

unbind

public void unbind(java.lang.String name)
            throws java.io.IOException
Removes any binding for the specified name.

Parameters:
name - the name for which any binding is to be removed.
Throws:
BindingException - is thrown when the specified name was not bound
java.io.IOException - is thrown in case of trouble.

listNames

public java.lang.String[] listNames(java.lang.String regex)
                             throws java.io.IOException
Returns an array of strings representing names that have a receiveport identifier bound to it and match the given regular expression.

Parameters:
regex - the regular expression to match with.
Throws:
java.io.IOException - is thrown in case of trouble.

maybeDead

public void maybeDead(IbisIdentifier ibis)
               throws java.io.IOException
Notifies that an Ibis instance is suspected to be dead.

Parameters:
ibis - the Ibis identifier of the Ibis instance suspected to be dead.
Throws:
java.io.IOException - is thrown in case of trouble.

dead

public void dead(IbisIdentifier ibis)
          throws java.io.IOException
Notifies that an Ibis instance must be assumed to be dead.

Parameters:
ibis - the Ibis identifier of the Ibis instance that must be assumed to be dead.
Throws:
java.io.IOException - is thrown in case of trouble.


The Ibis project