com.onionnetworks.fec.io
Class PacketPlacement

java.lang.Object
  extended by com.onionnetworks.fec.io.PacketPlacement

public class PacketPlacement
extends java.lang.Object

This class allocates and tracks how packets are written to disk. It is fully synchronized to safely support multi-threaded access. Its data structures and operations are fairly well optimized. (c) Copyright 2001 Onion Networks (c) Copyright 2000 OpenCola

Author:
Justin F. Chapweske (justin@chapweske.com)

Field Summary
static short DECODED_BLOCK
           
 
Constructor Summary
PacketPlacement(FECParameters params)
          Creates a new PacketPlacement object.
 
Method Summary
 int addPacketEntry(int blockNum, int stripeNum)
          Add a new entry to an available slot.
 int getDecodedBlockCount()
           
 int getPacketCount(int blockNum)
           
 int getPacketIndex(int blockNum, int stripeNum)
          Perform a reverse lookup on the index to find the index of a specific packet.
 int[] getStripeNums(int blockNum)
           
 int[] getStripeNums(int blockNum, int count)
           
 int getWrittenCount()
           
 boolean isBlockDecoded(int blockNum)
           
 void setBlockDecoded(int blockNum)
          Signify that this block has been decoded.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DECODED_BLOCK

public static final short DECODED_BLOCK
See Also:
Constant Field Values
Constructor Detail

PacketPlacement

public PacketPlacement(FECParameters params)
Creates a new PacketPlacement object.

Parameters:
params - The FECParameters for this download.
Method Detail

getDecodedBlockCount

public int getDecodedBlockCount()
Returns:
the number of blocks that have been decoded and written back to disk.

setBlockDecoded

public void setBlockDecoded(int blockNum)
Signify that this block has been decoded.

Parameters:
blockNum - The blockNum of the decoded block.

isBlockDecoded

public boolean isBlockDecoded(int blockNum)
Parameters:
The - blockNum of the block to check.
Returns:
true if the block has been decoded.

getPacketCount

public int getPacketCount(int blockNum)
Parameters:
blockNum - the blockNum for which to count packets.
Returns:
The number of packets in the block. PacketPlacement.DECODED_BLOCK (-1) if the block is decoded.

getWrittenCount

public int getWrittenCount()
Returns:
The total number of packets that have been written to disk.

getPacketIndex

public int getPacketIndex(int blockNum,
                          int stripeNum)
Perform a reverse lookup on the index to find the index of a specific packet.

Parameters:
blockNum - The blockNum of the packet.
stripeNum - The stripeNum of the packet.
Returns:
the packetIndex if the packet is on disk, else -1

addPacketEntry

public int addPacketEntry(int blockNum,
                          int stripeNum)
Add a new entry to an available slot. BlockFulls will be thrown in preference to DuplicatePackets.

Parameters:
blockNum - The blockNum of the entry.
stripeNum - the stripeNum of the entry.
Returns:
the packetIndex which the data will be written to.
Throws:
DuplicatePacketException - When there is an attempt to write a packet a second time.
BlockFullException - When the desired block is already full.

getStripeNums

public int[] getStripeNums(int blockNum)

getStripeNums

public int[] getStripeNums(int blockNum,
                           int count)


Copyright © 2002 Onion Networks. All Rights Reserved.