ibis.gmi
Class Group

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

public final class Group
extends Object
implements GroupProtocol

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


Field Summary
 
Fields inherited from interface ibis.gmi.GroupProtocol
BARRIER, BARRIER_FAILED, BARRIER_OK, COMBINE, COMBINE_RESULT, COMBINED_FAILED, COMBINED_OK, CREATE_FAILED, CREATE_GROUP, CREATE_MULTICAST_PORT, CREATE_MULTICAST_PORT_REPLY, 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
 
Method Summary
static void create(String nm, Class<?> type, int size)
          Creates a group.
static void exit()
          Exits from a group and cleans up resources.
static GroupMethod findMethod(GroupInterface i, String desc)
          Looks up the method described by descr in the group interface i.
static void join(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(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(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(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(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 ibis.ipl.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
 

Method Detail

create

public static void create(String nm,
                          Class<?> type,
                          int size)
                   throws 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:
RuntimeException - when the group already exists or in case of a communication error.

join

public static void join(String nm,
                        GroupMember o,
                        int rank,
                        long timeout)
                 throws 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:
RuntimeException - when the group is not found, the group is already full, or something else goes wrong.

join

public static void join(String nm,
                        GroupMember o)
                 throws 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:
RuntimeException - when the group is not found, the group is already full, or something else goes wrong.

join

public static void join(String nm,
                        GroupMember o,
                        int rank)
                 throws 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:
RuntimeException - when the group is not found, the group is already full, or something else goes wrong.

lookup

public static GroupInterface lookup(String nm)
                             throws 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:
RuntimeException - some network error has occurred

lookup

public static GroupInterface lookup(String nm,
                                    long timeout)
                             throws 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:
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 ibis.ipl.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,
                                     String desc)
                              throws 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:
NoSuchMethodException - is thrown when the method is not found.


The Ibis project