uka.patch
Class PartitionedObjectSpace

java.lang.Object
  extended byuka.util.IDConstants
      extended byuka.util.IDMap
          extended byuka.util.WeakIDMap
              extended byuka.patch.PartitionedObjectSpace
All Implemented Interfaces:
ObjectSpace, Printable, java.io.Serializable

public class PartitionedObjectSpace
extends WeakIDMap
implements ObjectSpace

See Also:
Serialized Form

Nested Class Summary
 class PartitionedObjectSpace.Distribution
           
(package private)  class PartitionedObjectSpace.SubSpace
           
 
Nested classes inherited from class uka.util.WeakIDMap
 
Field Summary
(package private)  PartitionedObjectSpace.Distribution distribution
          Stores the (specified and actual) distribution of all objects that have a local copy in the replica of this object space.
(package private)  DistributionJournal distributionJournal
          A journal of application specified object distributions.
(package private)  Distributor distributor
          An application provided distributor object that decides about the distribution of objects newly added to this partitioned object space.
(package private)  int localRank
          The local rank.
(package private)  IntOpenHashSet newIDs
           
(package private)  IntOpenHashSet newlySharedIDs
           
(package private)  IntOpenHashSet newlyUnsharedIDs
           
(package private)  ReadOnlyJournal readOnlyJournal
           
(package private)  int size
          The number of nodes.
(package private)  PartitionedObjectSpace.SubSpace[] subSpaces
           
 
Fields inherited from class uka.util.WeakIDMap
 
Fields inherited from class uka.util.IDMap
idToObject, INVALID_INDEX, space
 
Fields inherited from class uka.util.IDConstants
FIRST_NEW_ID, FIRST_VALID_ID, INVALID_ID, UNUSED_ID
 
Constructor Summary
PartitionedObjectSpace(java.lang.Object root, int size, int localRank, Distributor distributor)
           
 
Method Summary
 void appendTo(ToString s)
          This method should append the contents of each instance variable of the current object to the given ToString object.
 void checkConsistency(java.util.logging.Logger log)
           
 void distributeTo(java.lang.Object obj, boolean[] ranks)
           
 void distributeTo(java.lang.Object obj, int[] ranks)
           
 IntIterator getActiveRanks()
           
 int getID(java.lang.Object obj)
          Returns the identifier for a given object.
 IntIterator getSharedIDs()
           
 int getSize()
           
 SharedObjectSpace getSubSpace(int rank)
           
 void includeID(int id)
          Make the object that corresponds to the given identifier part of this object space.
private  void initTransient(int size)
           
 boolean isAccepted(int id)
          Decides whether an object reference should be blocked during transmission through a MarshalStream/UnmarshalStream pair.
 boolean isAccepted(int id, int rank)
           
 boolean isAtHome(int id, int rank)
           
 boolean isIncluded(int id)
          Decides whether the obect that corresponds to the given identifier is part of this object space.
 boolean isReadOnly(java.lang.Object obj)
           
 boolean isShared(int id)
           
 void readDistributionUpdate(PatchReader reader)
           
private  void readObject(java.io.ObjectInputStream in)
           
private  void resetNewIDs()
           
private  void restoreAfterUnmarshal()
           
 void setLocalRank(int localRank)
           
 void setObject(int id, java.lang.Object obj)
          Assigns the given object to an application provided identifier and includes the given object to this object space.
 void setReadOnly(java.lang.Object obj, boolean value)
           
 boolean testReadOnly(java.lang.Object obj)
           
 java.lang.String toString()
           
 void writeDistributionUpdate(PatchWriter[] writers)
           
 
Methods inherited from class uka.util.WeakIDMap
get, getIDForRef, getIndexForID, getObjects, getObjects, pollID, restoreBeforeReadObject, set, waitForID, waitForID
 
Methods inherited from class uka.util.IDMap
clear, dump, findID, getHash, getIndexForHash, getObject, getUsedIDs, isUsed, rawFindID, remove, resetObject
 
Methods inherited from class uka.util.IDConstants
isNew, isValid, normalizeID, toggleNew
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface uka.transport.ObjectSpace
clear, findID, getObject, getUsedIDs, isUsed, remove, resetObject
 

Field Detail

size

int size
The number of nodes.


localRank

transient int localRank
The local rank.


distributor

Distributor distributor
An application provided distributor object that decides about the distribution of objects newly added to this partitioned object space.


distribution

PartitionedObjectSpace.Distribution distribution
Stores the (specified and actual) distribution of all objects that have a local copy in the replica of this object space.


distributionJournal

transient DistributionJournal distributionJournal
A journal of application specified object distributions. The changes to the object distribution are recorded to this data structure until the corresponding objects become part of the replicated state during the next update.

See Also:
distributeTo(Object, int[])

readOnlyJournal

transient ReadOnlyJournal readOnlyJournal

subSpaces

PartitionedObjectSpace.SubSpace[] subSpaces

newIDs

transient IntOpenHashSet newIDs

newlySharedIDs

transient IntOpenHashSet newlySharedIDs

newlyUnsharedIDs

transient IntOpenHashSet newlyUnsharedIDs
Constructor Detail

PartitionedObjectSpace

public PartitionedObjectSpace(java.lang.Object root,
                              int size,
                              int localRank,
                              Distributor distributor)
Method Detail

initTransient

private void initTransient(int size)

resetNewIDs

private void resetNewIDs()

setLocalRank

public void setLocalRank(int localRank)

getSize

public int getSize()
Overrides:
getSize in class IDMap

getActiveRanks

public IntIterator getActiveRanks()

checkConsistency

public void checkConsistency(java.util.logging.Logger log)

getID

public int getID(java.lang.Object obj)
Description copied from interface: ObjectSpace
Returns the identifier for a given object. If the object was presented to the ObjectSpace the first time, the #isNew method returns true for the resulting identifier.

Specified by:
getID in interface ObjectSpace
Overrides:
getID in class IDMap

isShared

public boolean isShared(int id)
Specified by:
isShared in interface ObjectSpace
Returns:
whether the object that corresponds to the given identifier is a shared object.
See Also:
PartitionedObjectSpace.Distribution.isShared(int)

getSharedIDs

public final IntIterator getSharedIDs()

isAccepted

public boolean isAccepted(int id)
Description copied from interface: ObjectSpace
Decides whether an object reference should be blocked during transmission through a MarshalStream/UnmarshalStream pair. If a call to ObjectSpace.isAccepted(int) on the ObjectSpace of the sender-side stream returns false for an object identifier, a reference to the corresponding object is blocked (replaced with null).

Specified by:
isAccepted in interface ObjectSpace
Returns:
whether references to the corresponding object should be marshaled or blocked.

isIncluded

public boolean isIncluded(int id)
Description copied from interface: ObjectSpace
Decides whether the obect that corresponds to the given identifier is part of this object space.

Specified by:
isIncluded in interface ObjectSpace
Returns:
whether the object that corresponds to the given identifier is part of this object space.
See Also:
ObjectSpace.includeID(int)

includeID

public void includeID(int id)
Description copied from interface: ObjectSpace
Make the object that corresponds to the given identifier part of this object space. An object is part of an object space, if the ObjectSpace.isIncluded(int) method returns true for the corresponding identifier. An object can have an assigned identifier in some object space without being part of that object space.

Specified by:
includeID in interface ObjectSpace
Returns:
the identifier assigned to the object passed as parameter.

isAccepted

public boolean isAccepted(int id,
                          int rank)

distributeTo

public void distributeTo(java.lang.Object obj,
                         int[] ranks)

distributeTo

public void distributeTo(java.lang.Object obj,
                         boolean[] ranks)

setObject

public void setObject(int id,
                      java.lang.Object obj)
Description copied from interface: ObjectSpace
Assigns the given object to an application provided identifier and includes the given object to this object space.

Specified by:
setObject in interface ObjectSpace
Overrides:
setObject in class IDMap

testReadOnly

public boolean testReadOnly(java.lang.Object obj)

setReadOnly

public void setReadOnly(java.lang.Object obj,
                        boolean value)

isReadOnly

public boolean isReadOnly(java.lang.Object obj)

writeDistributionUpdate

public void writeDistributionUpdate(PatchWriter[] writers)
                             throws java.io.IOException
Throws:
java.io.IOException

readDistributionUpdate

public void readDistributionUpdate(PatchReader reader)
                            throws java.io.IOException
Throws:
java.io.IOException

isAtHome

public boolean isAtHome(int id,
                        int rank)

getSubSpace

public SharedObjectSpace getSubSpace(int rank)

restoreAfterUnmarshal

private void restoreAfterUnmarshal()
                            throws java.lang.ClassNotFoundException,
                                   java.io.IOException
Throws:
java.lang.ClassNotFoundException
java.io.IOException

readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

toString

public java.lang.String toString()

appendTo

public void appendTo(ToString s)
Description copied from interface: Printable
This method should append the contents of each instance variable of the current object to the given ToString object. The appended data should be labeled with the name of the corresponding instance variable.

Specified by:
appendTo in interface Printable
Overrides:
appendTo in class IDMap