CTL
Class Group

java.lang.Object
  extended by CTL.Group
All Implemented Interfaces:
java.lang.Runnable

public class Group
extends java.lang.Object
implements java.lang.Runnable

Process group (currently, only groups with 2 members are supported)


Field Summary
private  Env env
          Environment of this group member
protected  GroupInfo[] grp
          Array of GroupInfos for all members
private  int members
          Number of hosts in this group
private  int myID
          Logical ID of the process running on localhost
private  long objID
          ObjectID
private  boolean terminated
          Whether the group is terminated
 
Constructor Summary
Group(Env myEnv)
          Empty constructor
Group(java.lang.String[] args)
           
Group(java.lang.String host, int port, int myID, int members, int link, Env myEnv)
           
Group(java.lang.String host, int port, int myID, int members, int link, int myPort, Env myEnv)
           
 
Method Summary
 GroupInfo groupInfo(int id)
          Retrieve group information of a certain member
protected  void HS_recv()
          Receive a handshake
protected  void HS_send()
          Send a handshake
 int members()
          Retrieve number of group members
 int myID()
          Retrieve local Logical ID
 GroupInfo myInfo()
          Retrieve group information of the local member
 void printInfo()
          Print information about the group
 void readVersion(Communicator comm)
          Read version string
protected  void recv()
          Spawns a connection handler as long as the group is active
static void recvException(java.lang.String msg)
          Receive an exception
 void recvTermination(PeerID pid, java.lang.String msg)
          Receive a termination request
 void run()
          Start the communication thread
 boolean running()
          Check if this group is active
 void terminate()
          Terminate the group
 java.lang.String toString()
          Retrieve a string representation of this object
private  void updateGroup(int myID, int members)
          Update group information
 void writeVersion(Communicator comm)
          Write version string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myID

private int myID
Logical ID of the process running on localhost


members

private int members
Number of hosts in this group


objID

private long objID
ObjectID


grp

protected GroupInfo[] grp
Array of GroupInfos for all members


terminated

private boolean terminated
Whether the group is terminated


env

private Env env
Environment of this group member

Constructor Detail

Group

public Group(Env myEnv)
Empty constructor


Group

public Group(java.lang.String host,
             int port,
             int myID,
             int members,
             int link,
             int myPort,
             Env myEnv)
      throws java.io.IOException,
             CTLException
Throws:
java.io.IOException
CTLException

Group

public Group(java.lang.String host,
             int port,
             int myID,
             int members,
             int link,
             Env myEnv)
      throws java.io.IOException,
             java.lang.ClassNotFoundException,
             java.lang.IllegalAccessException,
             java.lang.InstantiationException,
             java.lang.reflect.InvocationTargetException,
             CTLException
Throws:
java.io.IOException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.reflect.InvocationTargetException
CTLException

Group

public Group(java.lang.String[] args)
      throws java.io.IOException,
             CTLException,
             java.lang.IllegalAccessException,
             java.lang.reflect.InvocationTargetException,
             java.lang.ClassNotFoundException,
             java.lang.InstantiationException
Throws:
java.io.IOException
CTLException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.ClassNotFoundException
java.lang.InstantiationException
Method Detail

recvTermination

public void recvTermination(PeerID pid,
                            java.lang.String msg)
Receive a termination request

Parameters:
pid - PeerID of the terminating process
msg - Reason for termination

recvException

public static void recvException(java.lang.String msg)
Receive an exception

Parameters:
msg - Reason for the exception

updateGroup

private void updateGroup(int myID,
                         int members)
Update group information

Parameters:
myID - Logical ID
members - Number of group members

printInfo

public void printInfo()
Print information about the group


readVersion

public void readVersion(Communicator comm)
                 throws java.io.IOException,
                        CTLException
Read version string

Parameters:
comm - Communicator
Throws:
java.io.IOException
CTLException

writeVersion

public void writeVersion(Communicator comm)
                  throws java.io.IOException
Write version string

Parameters:
comm - Communicator
Throws:
java.io.IOException

run

public void run()
Start the communication thread

Specified by:
run in interface java.lang.Runnable

recv

protected void recv()
Spawns a connection handler as long as the group is active


HS_recv

protected void HS_recv()
                throws java.io.IOException,
                       java.lang.ClassNotFoundException,
                       java.lang.InstantiationException,
                       java.lang.reflect.InvocationTargetException,
                       java.lang.IllegalAccessException,
                       CTLException
Receive a handshake

Throws:
java.io.IOException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
CTLException

HS_send

protected void HS_send()
                throws java.io.IOException,
                       java.lang.IllegalAccessException,
                       java.lang.reflect.InvocationTargetException,
                       java.lang.ClassNotFoundException,
                       java.lang.InstantiationException,
                       CTLException
Send a handshake

Throws:
java.io.IOException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.ClassNotFoundException
java.lang.InstantiationException
CTLException

running

public boolean running()
Check if this group is active

Returns:
True if active, false otherwise

terminate

public void terminate()
Terminate the group


myID

public int myID()
Retrieve local Logical ID

Returns:
Logical ID

members

public int members()
Retrieve number of group members

Returns:
Number of members

toString

public java.lang.String toString()
Retrieve a string representation of this object

Overrides:
toString in class java.lang.Object
Returns:
String

groupInfo

public GroupInfo groupInfo(int id)
Retrieve group information of a certain member


myInfo

public GroupInfo myInfo()
Retrieve group information of the local member