gov.nasa.gsfc.drl.rtstps.clients.spooler
Class Pipe

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.clients.spooler.Pipe

final class Pipe
extends java.lang.Object

SocketReader uses this FIFO queue of Blocks to send data to the SocketWriter.


Field Summary
private  Block[] blockArray
           
private  boolean eos
           
private  int readIndex
           
private  int writeIndex
           
 
Constructor Summary
Pipe()
          Create a pipe of 32 blocks.
Pipe(int blockCount, int blockSizeBytes)
          Create a custom pipe.
 
Method Summary
(package private)  byte[] getWriteBuffer()
          Get a buffer to be used for writing to the pipe.
(package private)  boolean isEmpty()
          Is the pipe empty?
(package private)  boolean isEndOfStream()
          Is this the end of stream?
(package private)  boolean putWriteBuffer(int length)
          Put the write-buffer into the pipe.
(package private)  Block read()
          Get a filled block from the pipe.
(package private)  void release()
          Return the last read block to the free block pool.
(package private)  void setEndOfStream(boolean eos)
          Mark end-of-stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writeIndex

private int writeIndex

readIndex

private int readIndex

eos

private boolean eos

blockArray

private Block[] blockArray
Constructor Detail

Pipe

Pipe()
Create a pipe of 32 blocks. Each block is 2048 bytes long.


Pipe

Pipe(int blockCount,
     int blockSizeBytes)
Create a custom pipe.

Parameters:
blockCount - The maximum number of blocks in the pipe.
blockSizeBytes - The size of each block in bytes.
Method Detail

setEndOfStream

final void setEndOfStream(boolean eos)
Mark end-of-stream. SocketReader tells SocketWriter that no more data will follow.


isEndOfStream

final boolean isEndOfStream()
Is this the end of stream?


isEmpty

final boolean isEmpty()
Is the pipe empty?


getWriteBuffer

byte[] getWriteBuffer()
Get a buffer to be used for writing to the pipe.

Returns:
null if no block is available.

putWriteBuffer

boolean putWriteBuffer(int length)
Put the write-buffer into the pipe.

Parameters:
length - the true buffer length, which may be less than its allocated block length.
Returns:
true if this is the last available buffer in the pipe.

read

Block read()
Get a filled block from the pipe.

Returns:
the block or null if none are available.

release

void release()
Return the last read block to the free block pool.