org.objectweb.proactive.core.group
Class ProxyForGroup

java.lang.Object
  |
  +--org.objectweb.proactive.core.body.proxy.AbstractProxy
        |
        +--org.objectweb.proactive.core.group.ProxyForGroup
All Implemented Interfaces:
java.util.Collection, Group, Proxy, java.io.Serializable
Direct Known Subclasses:
TopologyGroup

public class ProxyForGroup
extends AbstractProxy
implements Proxy, Group, java.io.Serializable

See Also:
Serialized Form

Field Summary
protected  java.lang.String className
          The name of the Class : all members of the group are "className" assignable
protected  boolean dispatching
          Flag to deternime the semantic of communication (broadcast or dispatching)
protected static org.apache.log4j.Logger logger
          The logger for the Class
protected  java.util.Vector memberList
          The list of member : it contains exclusively StubObjects connected to Proxies
protected  StubObject stub
          The stub of the typed group
protected  boolean uniqueSerialization
          Flag to deternime the semantic of communication (unique serialization of parameters or not)
protected  int waited
          Number of awaited methodcall on the group's member.
 
Constructor Summary
ProxyForGroup()
           
ProxyForGroup(ConstructorCall c, java.lang.Object[] p)
           
ProxyForGroup(java.lang.String nameOfClass)
           
ProxyForGroup(java.lang.String nameOfClass, java.lang.Integer size)
           
 
Method Summary
 boolean add(java.lang.Object o)
          If o is a reified object and if it is "assignableFrom" the class of the group, add it into the group
- if o is a group merge it into the group
- if o is not a reified object nor a group : do nothing
 boolean addAll(java.util.Collection c)
          Adds all of the elements in the specified Collection to this Group.
 void addMerge(java.lang.Object oGroup)
          Add all member of the group ogroup into the Group.
protected  void addToListOfResult(java.util.Vector memberListOfResultGroup, java.lang.Object result, int index)
          Add the results (Future) into the typed group result at the correct poisition.
 boolean allArrived()
          Checks if all the members of the Group are arrived.
 boolean allAwaited()
          Checks if all the members of the Group are awaited.
protected  java.lang.Object asynchronousCallOnGroup(MethodCall mc)
          Creates and initializes (and returns) the group of result, then launch threads for asynchronous call of each member.
 void barrier()
          Strongly synchronizes all the members of the group
 void clear()
          Removes all of the elements from this group.
 boolean contains(java.lang.Object o)
          This method returns true if and only if this group contains at least one element e such that o.equals(e)
 boolean containsAll(java.util.Collection c)
          Checks if this Group contains all of the elements in the specified collection.
protected  void createMemberWithMultithread(java.lang.String className, java.lang.Object[][] params, java.lang.String[] nodeList)
          Builds the members using the threads (of the threadpool).
 Group difference(Group g)
          Creates a new group with all members that belong to the group or to the group g, but not to both.
 void display()
          To debug, display the size of the Group and all its members with there position
 boolean equals(java.lang.Object o)
          Compares the specified object with this group for equality.
 Group exclude(Group g)
          Creates a new group with the members that belong to the group, but not to the group g.
 java.lang.Object get(int i)
          Returns the i-th member of the group.
 ExceptionList getExceptionList()
          Returns an ExceptionList containing all the throwables (exceptions and errors) occured when this group was built
 java.lang.Object getGroupByType()
          Returns an Object (a typed group Object) representing the Group
 java.lang.Class getType()
          Returns the ("higher") Class of group's member.
 java.lang.String getTypeName()
          Returns the full name of ("higher") Class of group's member
 int hashCode()
          Returns the hash code value for this Group.
 int indexOf(java.lang.Object obj)
          Returns the index of the first occurence of the specified Object obj.
 Group intersection(Group g)
          Creates a new group with all members that belong to the group and to the group g.
protected  boolean isDispatchingOn()
          Checks the semantic of communication of the Group.
 boolean isEmpty()
          Check if the group is empty.
 java.util.Iterator iterator()
          Returns an Iterator of the member in the Group.
 java.util.ListIterator listIterator()
          Returns a list iterator of the members in this Group (in proper sequence).
protected  void oneWayCallOnGroup(MethodCall mc)
          Launchs the threads for OneWay call of each member of the Group.
 void purgeExceptionAndNull()
          Removes all exceptions and null references contained in the Group.
 Group range(int begin, int end)
          Creates a new group with the members of the group begining at the index begin and ending at the index end.
 java.lang.Object reify(MethodCall mc)
          The proxy's method : implements the semantic of communication.
 void remove(int index)
          Removes the element at the specified position.
 boolean remove(java.lang.Object o)
          Removes a single instance of the specified element from this Group, if it is present.
 boolean removeAll(java.util.Collection c)
          Removes all this Group's elements that are also contained in the specified collection.
 boolean retainAll(java.util.Collection c)
          Retains only the elements in this Group that are contained in the specified collection.
protected  void set(int index, java.lang.Object o)
          Sets an object to the specified position in the Group
protected  void setDispatchingOff()
          Allows the Group to broadcast parameters.
protected  void setDispatchingOn()
          Allows the Group to dispatch parameters.
 void setRatioNemberToThread(int i)
          Modifies the number of members served by one thread
 void setSPMDGroup(java.lang.Object spmdGroup)
          Communicates the SPMD Group to members
protected  void setUniqueSerializationOff()
          Removes the ability of the Group to make an unique serialization of parameters..
protected  void setUniqueSerializationOn()
          Allows the Group to make an unique serialization of parameters.
 int size()
          Returns the number of member in this Group.
 java.lang.Object[] toArray()
          Returns an array containing all of the elements in this Group in the correct order.
 java.lang.Object[] toArray(java.lang.Object[] a)
          Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
 Group union(Group g)
          Creates a new group with all members of the group and all the members of the group g
 void waitAll()
          Waits that all the members are arrived.
 java.lang.Object waitAndGetOne()
          Waits that at least one member is arrived and returns it.
 java.lang.Object waitAndGetTheNth(int n)
          Waits that the member at the specified rank is arrived and returns it.
 void waitN(int n)
          Waits that at least n members are arrived.
 void waitOne()
          Waits that at least one member is arrived.
 int waitOneAndGetIndex()
          Waits that at least one member is arrived and returns its index.
 void waitTheNth(int n)
          Waits that the member at the specified rank is arrived.
 
Methods inherited from class org.objectweb.proactive.core.body.proxy.AbstractProxy
isAsynchronousCall, isOneWayCall
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.apache.log4j.Logger logger
The logger for the Class


className

protected java.lang.String className
The name of the Class : all members of the group are "className" assignable


memberList

protected java.util.Vector memberList
The list of member : it contains exclusively StubObjects connected to Proxies


waited

protected int waited
Number of awaited methodcall on the group's member. The Semantic is : we wait all call are done before continuing


dispatching

protected boolean dispatching
Flag to deternime the semantic of communication (broadcast or dispatching)


uniqueSerialization

protected boolean uniqueSerialization
Flag to deternime the semantic of communication (unique serialization of parameters or not)


stub

protected StubObject stub
The stub of the typed group

Constructor Detail

ProxyForGroup

public ProxyForGroup(java.lang.String nameOfClass)
              throws ConstructionOfReifiedObjectFailedException

ProxyForGroup

public ProxyForGroup(java.lang.String nameOfClass,
                     java.lang.Integer size)
              throws ConstructionOfReifiedObjectFailedException

ProxyForGroup

public ProxyForGroup()
              throws ConstructionOfReifiedObjectFailedException

ProxyForGroup

public ProxyForGroup(ConstructorCall c,
                     java.lang.Object[] p)
              throws ConstructionOfReifiedObjectFailedException
Method Detail

setDispatchingOn

protected void setDispatchingOn()
Allows the Group to dispatch parameters.


setDispatchingOff

protected void setDispatchingOff()
Allows the Group to broadcast parameters.


setUniqueSerializationOn

protected void setUniqueSerializationOn()
Allows the Group to make an unique serialization of parameters.


setUniqueSerializationOff

protected void setUniqueSerializationOff()
Removes the ability of the Group to make an unique serialization of parameters..


isDispatchingOn

protected boolean isDispatchingOn()
Checks the semantic of communication of the Group.

Returns:
true if the "scatter option" is enabled.

reify

public java.lang.Object reify(MethodCall mc)
                       throws java.lang.reflect.InvocationTargetException
The proxy's method : implements the semantic of communication. This method invokes the method call mc on each members of the Group.

Specified by:
reify in interface Proxy
Parameters:
mc - The MethodCall object corresponding to the method
Returns:
the result of the call : the result of a method call on a typed group is a typed group.
Throws:
java.lang.reflect.InvocationTargetException - if a problem occurs when invoking the method on the members of the Group

asynchronousCallOnGroup

protected java.lang.Object asynchronousCallOnGroup(MethodCall mc)
Creates and initializes (and returns) the group of result, then launch threads for asynchronous call of each member.

Returns:
the result of the call.

addToListOfResult

protected void addToListOfResult(java.util.Vector memberListOfResultGroup,
                                 java.lang.Object result,
                                 int index)
Add the results (Future) into the typed group result at the correct poisition.


oneWayCallOnGroup

protected void oneWayCallOnGroup(MethodCall mc)
Launchs the threads for OneWay call of each member of the Group.


add

public boolean add(java.lang.Object o)
If o is a reified object and if it is "assignableFrom" the class of the group, add it into the group
- if o is a group merge it into the group
- if o is not a reified object nor a group : do nothing

Specified by:
add in interface java.util.Collection
Parameters:
o - - element whose presence in this group is to be ensured
Returns:
true if this collection changed as a result of the call

addAll

public boolean addAll(java.util.Collection c)
Adds all of the elements in the specified Collection to this Group.

Specified by:
addAll in interface java.util.Collection
Returns:
true if this collection changed as a result of the call.

clear

public void clear()
Removes all of the elements from this group. This group will be empty after this method returns.

Specified by:
clear in interface java.util.Collection

contains

public boolean contains(java.lang.Object o)
This method returns true if and only if this group contains at least one element e such that o.equals(e)

Specified by:
contains in interface java.util.Collection
Returns:
true if this collection contains the specified element.

containsAll

public boolean containsAll(java.util.Collection c)
Checks if this Group contains all of the elements in the specified collection.

Specified by:
containsAll in interface java.util.Collection
Returns:
true if this Group contains all of the elements in the specified collection

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this group for equality.

Specified by:
equals in interface java.util.Collection
Overrides:
equals in class java.lang.Object
Returns:
true if o is the same Group as this.

hashCode

public int hashCode()
Returns the hash code value for this Group.

Specified by:
hashCode in interface java.util.Collection
Overrides:
hashCode in class java.lang.Object
Returns:
the hash code value for this Group.

isEmpty

public boolean isEmpty()
Check if the group is empty.

Specified by:
isEmpty in interface java.util.Collection
Returns:
true if this collection contains no elements.

iterator

public java.util.Iterator iterator()
Returns an Iterator of the member in the Group.

Specified by:
iterator in interface java.util.Collection
Returns:
an Iterator of the member in the Group.

remove

public boolean remove(java.lang.Object o)
Removes a single instance of the specified element from this Group, if it is present. It removes the first occurence e where o.equals(e) returns true.

Specified by:
remove in interface java.util.Collection
Returns:
true> if the Group contained the specified element.

removeAll

public boolean removeAll(java.util.Collection c)
Removes all this Group's elements that are also contained in the specified collection. After this call returns, this collection will contain no elements in common with the specified collection.

Specified by:
removeAll in interface java.util.Collection
Returns:
true if this Group changed as a result of the call

retainAll

public boolean retainAll(java.util.Collection c)
Retains only the elements in this Group that are contained in the specified collection. It removes from this Group all of its elements that are not contained in the specified collection.

Specified by:
retainAll in interface java.util.Collection
Returns:
true if this Group changed as a result of the call.

size

public int size()
Returns the number of member in this Group.

Specified by:
size in interface java.util.Collection
Returns:
the number of member in this Group.

toArray

public java.lang.Object[] toArray()
Returns an array containing all of the elements in this Group in the correct order.

Specified by:
toArray in interface java.util.Collection
Returns:
an array containing all of the elements in this Group in the correct order.

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.

Specified by:
toArray in interface java.util.Collection
Returns:
an array containing the elements of this collection.

addMerge

public void addMerge(java.lang.Object oGroup)
Add all member of the group ogroup into the Group. ogroup can be :
- a typed group
- a Group
- a standard Object
but it have to be (or to extend) the Class of the Group.

Specified by:
addMerge in interface Group

indexOf

public int indexOf(java.lang.Object obj)
Returns the index of the first occurence of the specified Object obj.

Specified by:
indexOf in interface Group
Returns:
the rank of obj in the Group. -1 if the list does not contain this object.

listIterator

public java.util.ListIterator listIterator()
Returns a list iterator of the members in this Group (in proper sequence).

Specified by:
listIterator in interface Group
Returns:
a list iterator of the members in this Group.

remove

public void remove(int index)
Removes the element at the specified position.

Specified by:
remove in interface Group

get

public java.lang.Object get(int i)
Returns the i-th member of the group.

Specified by:
get in interface Group
Returns:
the member of the Group at the specified rank.

getType

public java.lang.Class getType()
                        throws java.lang.ClassNotFoundException
Returns the ("higher") Class of group's member.

Specified by:
getType in interface Group
Returns:
the Class that all Group's members are (or extend).
Throws:
java.lang.ClassNotFoundException - if the class name of the Group is not known.

getTypeName

public java.lang.String getTypeName()
Returns the full name of ("higher") Class of group's member

Specified by:
getTypeName in interface Group
Returns:
the name of the Class that all Group's members are (or extend).

getGroupByType

public java.lang.Object getGroupByType()
Returns an Object (a typed group Object) representing the Group

Specified by:
getGroupByType in interface Group
Returns:
a typed group corresponding to the Group.

union

public Group union(Group g)
Creates a new group with all members of the group and all the members of the group g

Specified by:
union in interface Group
Parameters:
g - - a group
Returns:
a group that contain all the members of the group and g. null if the class of the group is incompatible.

intersection

public Group intersection(Group g)
Creates a new group with all members that belong to the group and to the group g.

Specified by:
intersection in interface Group
Parameters:
g - - a group
Returns:
a group that contain the common members of the group and g. null if the class of the group is incompatible.

exclude

public Group exclude(Group g)
Creates a new group with the members that belong to the group, but not to the group g.

Specified by:
exclude in interface Group
Parameters:
g - - a group
Returns:
a group that contain the members of the group without the member g. null if the class of the group is incompatible.

difference

public Group difference(Group g)
Creates a new group with all members that belong to the group or to the group g, but not to both.

Specified by:
difference in interface Group
Parameters:
g - - a group
Returns:
a group that contain the non-common members of the group and g. null if the class of the group is incompatible.

range

public Group range(int begin,
                   int end)
Creates a new group with the members of the group begining at the index begin and ending at the index end.

Specified by:
range in interface Group
Parameters:
begin - - the begining index
end - - the ending index
Returns:
a group that contain the members of the group from begin to end. null if begin > end.

barrier

public void barrier()
Strongly synchronizes all the members of the group

Specified by:
barrier in interface Group

setSPMDGroup

public void setSPMDGroup(java.lang.Object spmdGroup)
Communicates the SPMD Group to members

Parameters:
spmdGroup - - the SPMD group

display

public void display()
To debug, display the size of the Group and all its members with there position


waitAll

public void waitAll()
Waits that all the members are arrived.

Specified by:
waitAll in interface Group

waitOne

public void waitOne()
Waits that at least one member is arrived.

Specified by:
waitOne in interface Group

waitTheNth

public void waitTheNth(int n)
Waits that the member at the specified rank is arrived.

Specified by:
waitTheNth in interface Group

waitN

public void waitN(int n)
Waits that at least n members are arrived.

Specified by:
waitN in interface Group

waitAndGetOne

public java.lang.Object waitAndGetOne()
Waits that at least one member is arrived and returns it.

Specified by:
waitAndGetOne in interface Group
Returns:
a non-awaited member of the Group.

waitAndGetTheNth

public java.lang.Object waitAndGetTheNth(int n)
Waits that the member at the specified rank is arrived and returns it.

Specified by:
waitAndGetTheNth in interface Group
Returns:
the member (non-awaited) at the rank n in the Group.

waitOneAndGetIndex

public int waitOneAndGetIndex()
Waits that at least one member is arrived and returns its index.

Specified by:
waitOneAndGetIndex in interface Group
Returns:
the index of a non-awaited member of the Group.

allAwaited

public boolean allAwaited()
Checks if all the members of the Group are awaited.

Specified by:
allAwaited in interface Group
Returns:
true if all the members of the Group are awaited.

allArrived

public boolean allArrived()
Checks if all the members of the Group are arrived.

Specified by:
allArrived in interface Group
Returns:
true if all the members of the Group are arrived.

getExceptionList

public ExceptionList getExceptionList()
Returns an ExceptionList containing all the throwables (exceptions and errors) occured when this group was built

Specified by:
getExceptionList in interface Group
Returns:
an ExceptionList

purgeExceptionAndNull

public void purgeExceptionAndNull()
Removes all exceptions and null references contained in the Group. Exceptions (and null references) appears with communication/program-level/runtime errors and are stored in the Group. (After this operation the size of the Group decreases)

Specified by:
purgeExceptionAndNull in interface Group

setRatioNemberToThread

public void setRatioNemberToThread(int i)
Modifies the number of members served by one thread

Specified by:
setRatioNemberToThread in interface Group
Parameters:
i - - the new ratio

createMemberWithMultithread

protected void createMemberWithMultithread(java.lang.String className,
                                           java.lang.Object[][] params,
                                           java.lang.String[] nodeList)
Builds the members using the threads (of the threadpool).


set

protected void set(int index,
                   java.lang.Object o)
Sets an object to the specified position in the Group

Parameters:
index - - the position
o - - the object to add


Copyright © April 2004 INRIA All Rights Reserved.