ibis.gmi
Class Group

java.lang.Object
  extended byibis.gmi.Group
All Implemented Interfaces:
GroupProtocol

public final class Group
extends java.lang.Object
implements GroupProtocol

The Group class takes care of the startup, and has methods to create, join, lookup, and exit a group.


Field Summary
static org.apache.log4j.Logger logger
           
 
Fields inherited from interface ibis.gmi.GroupProtocol
BARRIER, BARRIER_FAILED, BARRIER_OK, COMBINE, COMBINE_RESULT, COMBINED_FAILED, COMBINED_OK, CREATE_FAILED, CREATE_GROUP, CREATE_OK, DEFINE_COMBINED, FIND_GROUP, GROUP_NOT_READY, GROUP_OK, GROUP_UNKNOWN, INVOCATION, INVOCATION_BINCOMBINE, INVOCATION_FLATCOMBINE, INVOCATION_REPLY, JOIN_FULL, JOIN_GROUP, JOIN_ILLEGAL_RANK, JOIN_OK, JOIN_RANK_TAKEN, JOIN_TIMEOUT, JOIN_UNKNOWN, JOIN_WRONG_TYPE, REGISTRY, REGISTRY_REPLY, RESULT_BOOLEAN, RESULT_BYTE, RESULT_CHAR, RESULT_DOUBLE, RESULT_EXCEPTION, RESULT_FLOAT, RESULT_INT, RESULT_LONG, RESULT_OBJECT, RESULT_SHORT, RESULT_VOID
 
Constructor Summary
Group()
           
 
Method Summary
static void create(java.lang.String nm, java.lang.Class type, int size)
          Creates a group.
static void exit()
          Exits from a group and cleans up resources.
static GroupMethod findMethod(GroupInterface i, java.lang.String desc)
          Looks up the method described by descr in the group interface i.
static SendPort getMulticastSendport(java.lang.String ID, int[] hosts)
          Gets a multicast send port using an identification to see if we already have such a send port.
static void join(java.lang.String nm, GroupMember o)
          Joins the group with this name, by communicating with the group registry, and blocks until the group is ready.
static void join(java.lang.String nm, GroupMember o, int rank)
          Joins the group with this name, by communicating with the group registry, and blocks until the group is ready.
static void join(java.lang.String nm, GroupMember o, int rank, long timeout)
          Joins the group with this name, by communicating with the group registry, and blocks until the group is ready.
static GroupInterface lookup(java.lang.String nm)
          Looks up the group with this name, if necessary by communicating with the group registry, and possibly waiting until the group is ready.
static GroupInterface lookup(java.lang.String nm, long timeout)
          Looks up the group with this name, if necessary by communicating with the group registry, and possibly waiting until the group is ready.
static int rank()
          Returns the node identification of the invoker.
static int size()
          Returns the total number of nodes in this run.
static SendPort unicast(int mem)
          Returns the sendport for the specified group member.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static org.apache.log4j.Logger logger
Constructor Detail

Group

public Group()
Method Detail

getMulticastSendport

public static SendPort getMulticastSendport(java.lang.String ID,
                                            int[] hosts)
Gets a multicast send port using an identification to see if we already have such a send port. If not, a new one is created.

Parameters:
ID - identification of the send port
hosts - the target hosts of the multicast
Returns:
the multicast send port.

create

public static void create(java.lang.String nm,
                          java.lang.Class type,
                          int size)
                   throws java.lang.RuntimeException
Creates a group.

Parameters:
nm - the name of the group to be created
type - the group interface that this group will provide
size - the number of group members that this group will have
Throws:
java.lang.RuntimeException - when the group already exists or in case of a communication error.

join

public static void join(java.lang.String nm,
                        GroupMember o,
                        int rank,
                        long timeout)
                 throws java.lang.RuntimeException
Joins the group with this name, by communicating with the group registry, and blocks until the group is ready.

Parameters:
nm - the name of the group we are joining
o - the member that is joining the group
rank - the rank that the member wishes to have in the group
timeout - the maximum time the operation may block (in milliseconds). Join will block indefinitely if timeout is 0 or smaller.
Throws:
java.lang.RuntimeException - when the group is not found, the group is already full, or something else goes wrong.

join

public static void join(java.lang.String nm,
                        GroupMember o)
                 throws java.lang.RuntimeException
Joins the group with this name, by communicating with the group registry, and blocks until the group is ready.

Parameters:
nm - the name of the group we are joining
o - the member that is joining the group
Throws:
java.lang.RuntimeException - when the group is not found, the group is already full, or something else goes wrong.

join

public static void join(java.lang.String nm,
                        GroupMember o,
                        int rank)
                 throws java.lang.RuntimeException
Joins the group with this name, by communicating with the group registry, and blocks until the group is ready.

Parameters:
nm - the name of the group we are joining
o - the member that is joining the group
rank - the rank that the member wishes to have in the group
Throws:
java.lang.RuntimeException - when the group is not found, the group is already full, or something else goes wrong.

lookup

public static GroupInterface lookup(java.lang.String nm)
                             throws java.lang.RuntimeException
Looks up the group with this name, if necessary by communicating with the group registry, and possibly waiting until the group is ready.

Parameters:
nm - the name of the group we are looking for
Returns:
the group interface we were looking for
Throws:
java.lang.RuntimeException - some network error has occurred

lookup

public static GroupInterface lookup(java.lang.String nm,
                                    long timeout)
                             throws java.lang.RuntimeException
Looks up the group with this name, if necessary by communicating with the group registry, and possibly waiting until the group is ready.

Parameters:
nm - the name of the group we are looking for
timeout - maximum time the operation may block, in milliseconds. (0 indicates that the lookup returns immediately, negative value indicates no timeout)
Returns:
the group interface we were looking for
Throws:
java.lang.RuntimeException - when the group is not found, or something else goes wrong.

rank

public static int rank()
Returns the node identification of the invoker.

Returns:
node identification.

size

public static int size()
Returns the total number of nodes in this run.

Returns:
total number of nodes.

unicast

public static SendPort unicast(int mem)
Returns the sendport for the specified group member.

Parameters:
mem - the group member.
Returns:
the sendport for the specified group member.

exit

public static void exit()
Exits from a group and cleans up resources. This method must be called by all members of the group, making it a sort of combined invocation.


findMethod

public static GroupMethod findMethod(GroupInterface i,
                                     java.lang.String desc)
                              throws java.lang.NoSuchMethodException
Looks up the method described by descr in the group interface i. If found, its GroupMethod is returned.

Parameters:
i - the group interface in which to look
desc - the method descriptor, as a string. Example format: "int lookmeup(int[],int)"
Returns:
The GroupMethod object of the method.
Throws:
java.lang.NoSuchMethodException - is thrown when the method is not found.


The Ibis project