|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.nasa.gsfc.drl.rtstps.core.output.hdf5.PacketPoolBySize
public class PacketPoolBySize
A very simplistic pooling class for packets for use by the HDF output module only. It assumes good behavior by the user -- packets are created and given away and then the expectation is the user will put them back in the pool when done... if not they are lost to the garbage collector. The packets are put on array of lists by packet size. When pulled off the queue the size is used as an index. If there are no packets at that size, the array is searched by adding one to size until it reaches the end. If some packet is found, it is reset to the requested size. This does not cost too much, no new memory is needed. If on the other hand this fails, then the search proceeds from the first smallest index (7) to the original size. If a packet is found, it is reset to the new size. This results in new memory being created inside of the Packet class itself. If both of these fail, then the Java heap is used.
Field Summary | |
---|---|
private static int |
CCSDSMaxSize
|
private static int |
CCSDSMinSize
|
private Packets[] |
pool
|
private boolean |
sciencePool
|
private Stats |
stats
|
private int |
timeToClear
|
private int |
timeToClearCounter
|
private long |
totalCreated
|
private long |
totalMemory
|
private long |
totalOnPool
|
private java.lang.String |
whoAmI
|
Constructor Summary | |
---|---|
PacketPoolBySize(java.lang.String poolName,
Stats stats)
init, create and initialize the pool |
Method Summary | |
---|---|
void |
drain()
Return all packets in the pool back to the Java heap. |
private Packet |
findPacketBySize(int size)
|
void |
flush(java.util.List<Packet> packetList)
Take all the packets on the supplied list and hang them on the internal pool list |
Packet |
get(int size)
Ask for a get a packet of size |
void |
preen()
Send little used packets back to the heap |
void |
put(Packet packet)
Give the packet to the pool for storage |
private void |
statMemoryUsed()
|
private void |
statPacketPool()
|
private void |
statPacketsCreated()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final int CCSDSMaxSize
private static final int CCSDSMinSize
private Packets[] pool
private long totalOnPool
private long totalCreated
private long totalMemory
private java.lang.String whoAmI
private Stats stats
private boolean sciencePool
private int timeToClearCounter
private final int timeToClear
Constructor Detail |
---|
public PacketPoolBySize(java.lang.String poolName, Stats stats)
Method Detail |
---|
public Packet get(int size) throws RtStpsException
get
in interface PacketPool
size
- size in bytes needed hold packet including header and body
RtStpsException
- If size is not legalpublic void put(Packet packet) throws RtStpsException
put
in interface PacketPool
packet
-
RtStpsException
- If illegal sizepublic void flush(java.util.List<Packet> packetList) throws RtStpsException
flush
in interface PacketPool
packetList
- the list of packets to put on the pool
RtStpsException
public void preen()
preen
in interface PacketPool
public void drain()
PacketPool
drain
in interface PacketPool
public java.lang.String toString()
toString
in class java.lang.Object
private Packet findPacketBySize(int size)
private void statPacketPool()
private void statMemoryUsed()
private void statPacketsCreated()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |