com.northconcepts.datapipeline.core
Class AsyncReader

java.lang.Object
  extended by com.northconcepts.datapipeline.core.DataEndpoint
      extended by com.northconcepts.datapipeline.core.DataReader
          extended by com.northconcepts.datapipeline.core.ProxyReader
              extended by com.northconcepts.datapipeline.core.AsyncReader

public class AsyncReader
extends ProxyReader

A proxy that reads data asynchronously using a separate thread.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State
 
Field Summary
static int MINIMUM_BUFFER_SIZE
           
 
Fields inherited from class com.northconcepts.datapipeline.core.DataEndpoint
BUFFER_SIZE, log
 
Constructor Summary
AsyncReader(DataReader reader)
           
 
Method Summary
 DataException addExceptionProperties(DataException exception)
          Adds this endpoint's current state to a DataException.
 int available()
          Returns the number of records that can probably be read without blocking.
 void close()
          Indicates that this endpoint has finished reading or writing.
 long getBufferSizeInBytes()
           
 DataException getException()
           
 int getId()
           
 long getMaxBufferSizeInBytes()
           
 String getName()
           
 long getPeakBufferSizeInBytes()
           
 int getPriority()
           
 void open()
          Makes this endpoint ready for reading or writing.
protected  Record pop()
          Removes and returns the next record in this DataReaders buffer or null if it is empty.
 void push(Record record)
          Adds a record to this DataReaders buffer.
protected  Record readImpl()
          Overridden by subclasses to read the next record from this DataReader.
 AsyncReader setMaxBufferSizeInBytes(long maxBufferSize)
           
 AsyncReader setPriority(int priority)
           
 String toString()
           
 
Methods inherited from class com.northconcepts.datapipeline.core.ProxyReader
getNestedReader, interceptRecord, setNestedDataReader, setNestedDataReader
 
Methods inherited from class com.northconcepts.datapipeline.core.DataReader
getBufferSize, getRootReader, peek, read, skip
 
Methods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
assertNotOpened, assertOpened, decrementRecordCount, exception, exception, exception, finalize, getDescription, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, getState, incrementRecordCount, isClosed, isOpen, isRecordCountBigInteger, resetRecordCount, setDescription
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MINIMUM_BUFFER_SIZE

public static final int MINIMUM_BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

AsyncReader

public AsyncReader(DataReader reader)
Method Detail

getMaxBufferSizeInBytes

public long getMaxBufferSizeInBytes()

setMaxBufferSizeInBytes

public AsyncReader setMaxBufferSizeInBytes(long maxBufferSize)

getBufferSizeInBytes

public long getBufferSizeInBytes()

getPeakBufferSizeInBytes

public long getPeakBufferSizeInBytes()

getPriority

public int getPriority()

setPriority

public AsyncReader setPriority(int priority)

getException

public DataException getException()

getId

public int getId()

getName

public String getName()

toString

public String toString()
Overrides:
toString in class DataEndpoint

open

public void open()
          throws DataException
Description copied from class: DataEndpoint
Makes this endpoint ready for reading or writing.

Overrides:
open in class ProxyReader
Throws:
DataException

close

public void close()
           throws DataException
Description copied from class: DataEndpoint
Indicates that this endpoint has finished reading or writing.

Overrides:
close in class ProxyReader
Throws:
DataException

push

public void push(Record record)
Description copied from class: DataReader
Adds a record to this DataReaders buffer. Records in the buffer will be returned by DataReader.read() before attempting to read from the underlying implementation.

Overrides:
push in class DataReader
See Also:
DataReader.read()

pop

protected Record pop()
Description copied from class: DataReader
Removes and returns the next record in this DataReaders buffer or null if it is empty.

Overrides:
pop in class DataReader
See Also:
DataReader.push(Record)

available

public int available()
              throws DataException
Description copied from class: DataReader
Returns the number of records that can probably be read without blocking.

Overrides:
available in class ProxyReader
Throws:
DataException

readImpl

protected Record readImpl()
                   throws Throwable
Description copied from class: DataReader
Overridden by subclasses to read the next record from this DataReader.

If no record is available, null will be returned.

Overrides:
readImpl in class ProxyReader
Throws:
Throwable

addExceptionProperties

public DataException addExceptionProperties(DataException exception)
Description copied from class: DataEndpoint
Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.

Overrides:
addExceptionProperties in class ProxyReader


Copyright (c) 2007-2012 North Concepts Inc. All Rights Reserved.