seda.sandStorm.lib.aDisk
Class AFileTPImpl

java.lang.Object
  extended by seda.sandStorm.core.SimpleSink
      extended by seda.sandStorm.lib.aDisk.AFileImpl
          extended by seda.sandStorm.lib.aDisk.AFileTPImpl
All Implemented Interfaces:
ProfilableIF, QueueElementIF, SinkIF

 class AFileTPImpl
extends AFileImpl
implements QueueElementIF

This is an implementation of AFile which uses a pool of threads which perform blocking I/O (through the java.io.RandomAccessFile class) on files. This is a portable implementation but is not intended to be high-performance.

See Also:
AFile

Field Summary
private  AFile afile
           
private  boolean closed
           
private  SinkIF compQ
           
private  FiniteQueue eventQ
           
private  java.io.File f
           
(package private)  java.io.RandomAccessFile raf
           
private  boolean readOnly
           
private  AFileTPTM tm
           
 
Constructor Summary
AFileTPImpl(AFile afile, java.lang.String fname, SinkIF compQ, boolean create, boolean readOnly, AFileTPTM tm)
          Create an AFileTPIMpl with the given AFile, filename, completion queue, create/readOnly flags, and Thread Manager.
 
Method Summary
 void close()
          Close the file after all enqueued requests have completed.
 boolean enqueue_lossy(QueueElementIF req)
          Enqueues the given request (which must be an AFileRequest) to the file.
 void enqueue_many(QueueElementIF[] elements)
          Enqueues the given requests (which must be AFileRequests) to the file.
 void enqueue(QueueElementIF req)
          Enqueues the given request (which must be an AFileRequest) to the file.
 void flush()
          Causes a SinkFlushedEvent to be posted on the file's completion queue when all pending requests have completed.
(package private)  QueueIF getQueue()
          Return the per-file event queue.
(package private)  AFileStat stat()
          Return information on the properties of the file.
 
Methods inherited from class seda.sandStorm.core.SimpleSink
enqueue_abort, enqueue_commit, enqueue_prepare, getEnqueuePredicate, profileSize, setEnqueuePredicate, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

f

private java.io.File f

raf

java.io.RandomAccessFile raf

afile

private AFile afile

tm

private AFileTPTM tm

compQ

private SinkIF compQ

eventQ

private FiniteQueue eventQ

readOnly

private boolean readOnly

closed

private boolean closed
Constructor Detail

AFileTPImpl

AFileTPImpl(AFile afile,
            java.lang.String fname,
            SinkIF compQ,
            boolean create,
            boolean readOnly,
            AFileTPTM tm)
      throws java.io.IOException
Create an AFileTPIMpl with the given AFile, filename, completion queue, create/readOnly flags, and Thread Manager.

Throws:
java.io.IOException
Method Detail

enqueue

public void enqueue(QueueElementIF req)
             throws SinkException
Enqueues the given request (which must be an AFileRequest) to the file.

Specified by:
enqueue in interface SinkIF
Specified by:
enqueue in class AFileImpl
Parameters:
req - The QueueElementIF to enqueue
Throws:
SinkFullException - Indicates that the sink is temporarily full.
SinkClosedException - Indicates that the sink is no longer being serviced.
SinkException

enqueue_lossy

public boolean enqueue_lossy(QueueElementIF req)
Enqueues the given request (which must be an AFileRequest) to the file.

Specified by:
enqueue_lossy in interface SinkIF
Specified by:
enqueue_lossy in class AFileImpl
Parameters:
req - The QueueElementIF to enqueue
Returns:
true if the element was enqueued, false otherwise.

enqueue_many

public void enqueue_many(QueueElementIF[] elements)
                  throws SinkException
Enqueues the given requests (which must be AFileRequests) to the file.

Specified by:
enqueue_many in interface SinkIF
Specified by:
enqueue_many in class AFileImpl
Parameters:
elements - The element array to enqueue
Throws:
SinkFullException - Indicates that the sink is temporarily full.
SinkClosedException - Indicates that the sink is no longer being serviced.
SinkException

stat

AFileStat stat()
Return information on the properties of the file.

Specified by:
stat in class AFileImpl

close

public void close()
Close the file after all enqueued requests have completed. Disallows any additional requests to be enqueued on this file. A SinkClosedEvent will be posted on the file's completion queue when the close is complete.

Specified by:
close in class AFileImpl

flush

public void flush()
Causes a SinkFlushedEvent to be posted on the file's completion queue when all pending requests have completed.

Specified by:
flush in class AFileImpl

getQueue

QueueIF getQueue()
Return the per-file event queue.