ostore.archive
Class FragmentBucket

java.lang.Object
  |
  +--ostore.archive.FragmentBucket
All Implemented Interfaces:
Cacheable, DisseminatableBucket, QuickSerializable

public class FragmentBucket
extends Object
implements DisseminatableBucket

FragmentBucket is a class to store all or a subset of the fragments for a single OceanStore block.

Version:
$Id: FragmentBucket.java,v 1.29 2004/03/23 02:30:20 hweather Exp $
Author:
Hakim Weatherspoon

Field Summary
protected  boolean[] _ackFrags
          Array to store whether a fragment has been acknowledged after dissemination.
protected  boolean _archiveInterpretFlag
          Flag determines whether the archive should do "something" special with the decoded block i.e create data obj.
protected  long _blockType
          blockType is the type of block we are encoding or decoding.
protected  boolean _canDecode
          boolean on whether can decode.
protected  long _endTime
          startTime and endTime are timers for dissemination and recoalescing of a disseminatable bucket.
protected  Fragment[] _frags
          Array to store the fragments (its length is based on whether we are waiting to disseminate, or are recoalescing, the fragments)
protected  int _frags_free_space
          Current free space pointer into _frags
protected  int _nackCount
          Number of NACK's received.
protected  SecureHash _nextBucket
          Points to the next FragmentBucket in a chain of FragmentBuckets.
protected  NodeId _node_id
          _node_id is the NodeId of the local server where this class is running.
protected  int _numAcksRecv
          Number of ack's recv'd for disseminated fragments belonging to a particular fragmentBucket.
protected  SecureHash _refGuid
          reference to guid of top most root block (GUID which refers to this FB).
protected  long _startTime
          startTime and endTime are timers for dissemination and recoalescing of a disseminatable bucket.
protected  boolean _successfullyDecoded
          boolean on whether can decode.
static boolean COMPARE_MESSAGES
          This determines if messages are compared after having been decoded in Reconstructor...for debuggin purposes only.
 int[] enc_msg
           
 int[] old_msg
           
 
Constructor Summary
FragmentBucket(InputBuffer buffer)
          Constructs a FragmentBucket from its serialized form.
FragmentBucket(int numFrags, NodeId node_id, SecureHash node_guid)
          Constructor: initializes FragmentBucket to contain a number of fragments.
FragmentBucket(NodeId node_id, SecureHash node_guid)
          Default constructor
 
Method Summary
 void add(Disseminatable diss)
          Add a disseminatable object to this bucket.
 boolean canDecode()
          Determine if we can decode this bucket's object.
 void clear()
          clears internal data structures.
static int computeMemoryRequirement(int bSize, int numFrags, int inverseRate, int type)
          computMemoryRequirement computes the memory requirement for a single disseminatable.
 boolean getAcksRecv(int index)
          getAcksRecv return true if fragment at given index has been received; otherwise, false.
 boolean getArchiveInterpretFlag()
          returns archive interpret decoded block flag.
 long getBlockType()
          getBlockType returns the type of block that we are encoding or decoding.
 Disseminatable getDisseminatable(int index)
          Retrieve a single Disseminatable object
 long getEndTime()
          getEndTime returns the time the Bucket was destroyed(removed from table).
 Fragment getFragment(int index)
          Retrieve a single Disseminatable object
 SecureHash getGuid()
          Get GUID that is the name of the diss objects in this bucket.
 int getLength()
          Retrieve the total capacity of this bucket.
 int getNackCount()
          getNackCount returns the number of NACK's received.
 SecureHash getNextBucket()
          Get the next Bucket in this chain.
 int getNumAcksRecv()
          getNumAcksRecv returns the number of ack's recv'd
 int getNumBytes()
          Retrieve the total number of bytes stored in this bucket.
 int getNumGood()
          Retrieve the total number of disseminatables stored in this bucket.
 SecureHash getRefGuid()
          Get GUID that refers to this bucket (in some higher-level hashtable).
 long getStartTime()
          getStartTime returns the time the Bucket was created(put on table).
 void incrNackCount()
          incrNackCount increments the NACK count.
protected static boolean instanceRandomContains(NodeId node_id)
          instanceRandomContains returns true if map of instance instance variables contains node_id, false otherwise.
protected static void instanciateRandom(int seed, NodeId node_id)
          instanciateRandom creates an instance of a Random associated with NodeId and instanciated with the seed.
 void loseFragments(double fractionToKeep)
          This routine is used for debuggin;
static int OVERHEAD(int numFrags)
          overhead of a fragment bucket (in bytes).
 boolean receivedAllAcks(double percentRequired)
          ReceivedAllAcks returns true if all disseminated fragments have been ack'd otherwise returns false.
 boolean recv(Disseminatable diss)
          Receive a disseminatable object (presumably from the network) and add it to this bucket.
 void reset(NodeId node_id, SecureHash node_guid)
          resets internal data structures.
 void serialize(OutputBuffer buffer)
          Specified by ostore.util.QuickSerializable
 void setAckRecv(int index)
          Receive an acknowledgement
 void setArchiveInterpretFlag(boolean flag)
          set's archive interpret decode block flag.
 void setBlockType(long type)
          setBlockType sets the type of block that we are encoding or decoding.
 void setDecoded(boolean success)
          Set successfullyDecoded ...
 void setEndTime(long time)
          setEndTime sets the time the Bucket was destroyed(removed from table).
 void setNextBucket(SecureHash bucket)
          Set the next Bucket in this chain.
 void setRefGuid(SecureHash guid)
          Set GUID that refers to this bucket (in some higher-level hashtable).
 void setStartTime(long time)
          setStartTime sets the time the Bucket was created(put on table).
 boolean testAndSetDecoded()
          Atomically test successfullyDecoded.
 String toString()
          Specified by java.lang.Object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPARE_MESSAGES

public static boolean COMPARE_MESSAGES
This determines if messages are compared after having been decoded in Reconstructor...for debuggin purposes only.


old_msg

public int[] old_msg

enc_msg

public int[] enc_msg

_startTime

protected long _startTime
startTime and endTime are timers for dissemination and recoalescing of a disseminatable bucket.


_endTime

protected long _endTime
startTime and endTime are timers for dissemination and recoalescing of a disseminatable bucket.


_blockType

protected long _blockType
blockType is the type of block we are encoding or decoding.


_frags

protected Fragment[] _frags
Array to store the fragments (its length is based on whether we are waiting to disseminate, or are recoalescing, the fragments)


_ackFrags

protected boolean[] _ackFrags
Array to store whether a fragment has been acknowledged after dissemination.


_numAcksRecv

protected int _numAcksRecv
Number of ack's recv'd for disseminated fragments belonging to a particular fragmentBucket.


_nackCount

protected int _nackCount
Number of NACK's received.


_frags_free_space

protected int _frags_free_space
Current free space pointer into _frags


_nextBucket

protected SecureHash _nextBucket
Points to the next FragmentBucket in a chain of FragmentBuckets. This is used to group FragmentBuckets of the same version / checkpt


_refGuid

protected SecureHash _refGuid
reference to guid of top most root block (GUID which refers to this FB).


_canDecode

protected boolean _canDecode
boolean on whether can decode.


_successfullyDecoded

protected boolean _successfullyDecoded
boolean on whether can decode.


_archiveInterpretFlag

protected boolean _archiveInterpretFlag
Flag determines whether the archive should do "something" special with the decoded block i.e create data obj.


_node_id

protected NodeId _node_id
_node_id is the NodeId of the local server where this class is running.

Constructor Detail

FragmentBucket

public FragmentBucket(NodeId node_id,
                      SecureHash node_guid)
Default constructor


FragmentBucket

public FragmentBucket(int numFrags,
                      NodeId node_id,
                      SecureHash node_guid)
Constructor: initializes FragmentBucket to contain a number of fragments.


FragmentBucket

public FragmentBucket(InputBuffer buffer)
               throws QSException
Constructs a FragmentBucket from its serialized form.

Parameters:
buffer - serialized form of object.
Method Detail

OVERHEAD

public static int OVERHEAD(int numFrags)
overhead of a fragment bucket (in bytes).


computeMemoryRequirement

public static int computeMemoryRequirement(int bSize,
                                           int numFrags,
                                           int inverseRate,
                                           int type)
computMemoryRequirement computes the memory requirement for a single disseminatable.

Parameters:
bSize - = size of block in bytes.
numFrags - = total number of fragments for block.
inverseRate - = inverseRate of encoding.
type - = type of erasure coding.
Returns:
return = the fragment size corresponding to the input parameters.

instanciateRandom

protected static void instanciateRandom(int seed,
                                        NodeId node_id)
instanciateRandom creates an instance of a Random associated with NodeId and instanciated with the seed.

Parameters:
seed - = seed to instanciate Random variable with.
node_id - = NodeId to associate with Random variable.

instanceRandomContains

protected static boolean instanceRandomContains(NodeId node_id)
instanceRandomContains returns true if map of instance instance variables contains node_id, false otherwise.

Parameters:
node_id - = NodeId to test.
Returns:
true if map of instance instance variables contains node_id, false otherwise.

clear

public void clear()
clears internal data structures.

Specified by:
clear in interface DisseminatableBucket

reset

public void reset(NodeId node_id,
                  SecureHash node_guid)
resets internal data structures.

Specified by:
reset in interface DisseminatableBucket

serialize

public void serialize(OutputBuffer buffer)
Specified by ostore.util.QuickSerializable

Specified by:
serialize in interface QuickSerializable
Parameters:
buffer - the output buffer to add the object to

getBlockType

public long getBlockType()
getBlockType returns the type of block that we are encoding or decoding.

Returns:
= type of block that we are encoding or decoding.

getStartTime

public long getStartTime()
getStartTime returns the time the Bucket was created(put on table).

Specified by:
getStartTime in interface DisseminatableBucket
Returns:
= time bucket was created (put on hash table).

getEndTime

public long getEndTime()
getEndTime returns the time the Bucket was destroyed(removed from table).

Specified by:
getEndTime in interface DisseminatableBucket
Returns:
= time bucket bucket was destroyed (removed from hash table).

getArchiveInterpretFlag

public boolean getArchiveInterpretFlag()
returns archive interpret decoded block flag.

Returns:
== archive interpret decoded flag.

setBlockType

public void setBlockType(long type)
setBlockType sets the type of block that we are encoding or decoding.

Parameters:
type - = type of block that we are encoding or decoding.

setStartTime

public void setStartTime(long time)
setStartTime sets the time the Bucket was created(put on table).

Specified by:
setStartTime in interface DisseminatableBucket
Parameters:
time - = the time the Bucket was created.

setEndTime

public void setEndTime(long time)
setEndTime sets the time the Bucket was destroyed(removed from table).

Specified by:
setEndTime in interface DisseminatableBucket
Parameters:
time - == the time the Bucket was destroyed.

setArchiveInterpretFlag

public void setArchiveInterpretFlag(boolean flag)
set's archive interpret decode block flag.

Parameters:
flag - == archive interpret decode block flag.

getNumBytes

public int getNumBytes()
Retrieve the total number of bytes stored in this bucket.

Specified by:
getNumBytes in interface DisseminatableBucket
Returns:
== the total number of bytes stored in this bucket.

getNextBucket

public SecureHash getNextBucket()
Get the next Bucket in this chain.

Specified by:
getNextBucket in interface DisseminatableBucket
Returns:
== the next bucket in this chain.

setNextBucket

public void setNextBucket(SecureHash bucket)
Set the next Bucket in this chain.

Specified by:
setNextBucket in interface DisseminatableBucket
Parameters:
bucket - == the next bucket in this chain.

getRefGuid

public SecureHash getRefGuid()
Get GUID that refers to this bucket (in some higher-level hashtable).

Specified by:
getRefGuid in interface DisseminatableBucket
Returns:
== the guid that refers to this bucket.

setRefGuid

public void setRefGuid(SecureHash guid)
Set GUID that refers to this bucket (in some higher-level hashtable).

Specified by:
setRefGuid in interface DisseminatableBucket
Parameters:
guid - == guid that refers to this bucket.

getGuid

public SecureHash getGuid()
Get GUID that is the name of the diss objects in this bucket.

Specified by:
getGuid in interface DisseminatableBucket
Returns:
== guid that is the name of the diss objects in this bucket.

getNumGood

public int getNumGood()
Retrieve the total number of disseminatables stored in this bucket.

Specified by:
getNumGood in interface DisseminatableBucket
Returns:
== total number of disseminatables stored in this bucket.

getLength

public int getLength()
Retrieve the total capacity of this bucket.

Specified by:
getLength in interface DisseminatableBucket
Returns:
== the total capacity of this bucket.

getDisseminatable

public Disseminatable getDisseminatable(int index)
Retrieve a single Disseminatable object

Specified by:
getDisseminatable in interface DisseminatableBucket
Parameters:
index - == index of the disseminatable object to retrieve.
Returns:
== disseminatable object that corresponds to index.

getFragment

public Fragment getFragment(int index)
Retrieve a single Disseminatable object

Parameters:
index - == index of the disseminatable object to retrieve.
Returns:
== disseminatable object that corresponds to index.

getNackCount

public int getNackCount()
getNackCount returns the number of NACK's received.

Specified by:
getNackCount in interface DisseminatableBucket
Returns:
return==number of NACK's received.

incrNackCount

public void incrNackCount()
incrNackCount increments the NACK count.

Specified by:
incrNackCount in interface DisseminatableBucket

add

public void add(Disseminatable diss)
Add a disseminatable object to this bucket.

Specified by:
add in interface DisseminatableBucket
Parameters:
diss - == the object to add.

setAckRecv

public void setAckRecv(int index)
Receive an acknowledgement

Specified by:
setAckRecv in interface DisseminatableBucket
Parameters:
index - == index of the Disseminatable to mark as ack'ed.

getAcksRecv

public boolean getAcksRecv(int index)
getAcksRecv return true if fragment at given index has been received; otherwise, false.

Specified by:
getAcksRecv in interface DisseminatableBucket
Parameters:
index - Index of disseminatable to test if ack has been received.
Returns:
true if fragment at given index has been received; otherwise, false.

getNumAcksRecv

public int getNumAcksRecv()
getNumAcksRecv returns the number of ack's recv'd

Specified by:
getNumAcksRecv in interface DisseminatableBucket
Returns:
number of ack's recv'd

receivedAllAcks

public boolean receivedAllAcks(double percentRequired)
ReceivedAllAcks returns true if all disseminated fragments have been ack'd otherwise returns false.

Specified by:
receivedAllAcks in interface DisseminatableBucket
Parameters:
percentRequired - == perecent of acks we will actually count as being "all" of the acks.
Returns:
return==true if all disseminated fragments have been ack'd otherwise returns false.

recv

public boolean recv(Disseminatable diss)
Receive a disseminatable object (presumably from the network) and add it to this bucket. This routine is called whenever we receive a new fragment during recoalescence. NOTE: The fragment should be verified before calling this function

Specified by:
recv in interface DisseminatableBucket
Parameters:
diss - the object to add.
Returns:
true iff we have enough diss objects to safely decode.

canDecode

public boolean canDecode()
Determine if we can decode this bucket's object.

Specified by:
canDecode in interface DisseminatableBucket
Returns:
== true iff we can decode this bucket's object.

testAndSetDecoded

public boolean testAndSetDecoded()
Atomically test successfullyDecoded. If it is false, set it to true ALERT: Make this synchronized!.

Specified by:
testAndSetDecoded in interface DisseminatableBucket
Returns:
== return true/false whether object is being decoded.

setDecoded

public void setDecoded(boolean success)
Set successfullyDecoded ... ALERT: Make this synchronized!

Specified by:
setDecoded in interface DisseminatableBucket
Parameters:
success - == set decoded to true or false

loseFragments

public void loseFragments(double fractionToKeep)
This routine is used for debuggin;

Parameters:
fractionToKeep - == fraction of fragments to keep.

toString

public String toString()
Specified by java.lang.Object

Overrides:
toString in class Object