All Packages  This Package  Class Hierarchy  Class Search  Index

Class edu.utah.janos.ants.ants.CodeGroup
java.lang.Object
   |
   +----edu.utah.janos.ants.ants.CodeGroup

  Summary

class  CodeGroup
     extends java.lang.Object
{
          // Fields 8
     static final int CHUNK_SIZE;
     int availChunkMask;
     boolean builtin;
     int chunkCount;
     final Vector classes;
     final TypeID groupID;
     final TypeID[] groupIDs;
     final TypeID protocolID;

          // Constructors 1
     CodeGroup(TypeID, TypeID[], TypeID, boolean);

          // Methods 6
     static int codeChunkCount(byte[]);

     final void activate(Node, boolean) throws ClassNotFoundException;
     final void add(CapsuleClass) throws Exception;
     final boolean builtin();
     final int chunkMask(int);
     public String toString();
}

A record collecting information about methods into a related group. The CodeGroup is the unit of code forwarding.

This class is only used internally in ANTS and is part of the dynamic code loading infrastructure.

The fields of CodeGroup have package access since a CodeGroup may be in many different states of completion during code loading and protocol registration.

A protocol is composed of several CodeGroups.

Author:
David Wetherall

See Also: Protocol


  Cross Reference

Returned By:
Node.lookupCodeGroup()





  Fields

· classes

Summary  |  Top
   final Vector classes

The CapsuleClasses comprising the CodeGroup. XXX make into an array?


· groupID

Summary  |  Top
   final TypeID groupID


· groupIDs

Summary  |  Top
   final TypeID[] groupIDs

groupIDs may or may not be necessary. Currently, it's only used to fill in the group ID list in a DLResponse capsule. groupIDs holds the groupID of every group in the protocol. This may be useful for checking that a group really is a member of the protocol: a group belongs to a protocol only if it is in the group ID list and the group ID list hashes to the protocol ID. We may not need this, though.

The groupIDs is fixed at instantiation time. The contents of this array should not be modified by anyone.


· protocolID

Summary  |  Top
   final TypeID protocolID

ProtocolID is computed from the Vector of GroupIDs. This is the only link from a CodeGroup up to its Protocol.

It may seem wasteful to store the ProtocolID in each CodeGroup in a Protocol, but remember, Protocol objects only exist at application nodes. Shipping the Protocol object just to give internal nodes a handle on the ProtocolID would be even more wasteful.


· chunkCount

Summary  |  Top
   int chunkCount

The number of chunks of size CHUNK_SIZE that are required to ship this CodeGroup.

There is a hard limit of 32 chunks in a CodeGroup. (Because the set of chunks in a CodeGroup a node has loaded must fit in a 32-bit mask.)

Each CapsuleClass in the CodeGroup will require a set number of chunks to transport. Sadly, chunks for distinct CapsuleClasses are not compressed together, i.e., two CapsuleClasses of CHUNK_SIZE+4 will require 4 chunks to ship.

See Also: CHUNK_SIZE, initChunkCount, availChunkMask


· availChunkMask

Summary  |  Top
   int availChunkMask

A bit vector indicating which code chunks are available on this node. Extra bits are 1 (i.e., if a CodeGroup has four chunks, and all four are loaded and available all of the bits in the availChunkMask will be set.

XXX add availChunkMask() function. XXX make this a long?!


· builtin

Summary  |  Top
   boolean builtin

Flag if this class is a builtin class.


· CHUNK_SIZE

Summary  |  Top
   static final int CHUNK_SIZE

Code to be shipped over the net is broken into chunks no bigger than this value.

XXX ideally this value should be a function of the outgoing link's MTU.

See Also: initChunkCount, codeChunkCount


  Constructors

· CodeGroup

Summary  |  Top

   CodeGroup(TypeID groupID, 
             TypeID[] groupIDs, 
             TypeID protocolID, 
             boolean builtin) 

Create a new (empty) CodeGroup with the given groupID and protocolID.

Parameter Description
groupID The group ID for this CodeGroup.



  Methods

· builtin

Summary  |  Top
   final boolean builtin() 


· chunkMask

Summary  |  Top
   final int chunkMask(int i) 

Compute a mask for chunk i. Fills in all unused chunk fields with 1. Thus the result can be read as a bit mask with 0's indicating which chunks are part of the CodeGroup except chunk i is set.

Parameter Description
i the chunk index

Returns:
a bit-vector indicating which chunks are available.


· codeChunkCount

Summary  |  Top
   static int codeChunkCount(byte[] code) 

Determine the number of chunks the given code array will be broken into.

XXX rename to chunkCountForCode()

Returns:
the number chunks the given code array will be broken into.


· activate

Summary  |  Top
   final void activate(Node node, 
                       boolean actuallyActive)  throws ClassNotFoundException


· add

Summary  |  Top
   final void add(CapsuleClass cc)  throws Exception

Add a capsule to the code group.

Throws: Exception
if the CodeGroup has too many chunks (currently the limit is 32).


· toString

Summary  |  Top
   public String toString() 
Overrides:
toString in class Object


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7