|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.healthmarketscience.rmiio.RemoteStreamServer<RemoteInputStreamServer,RemoteInputStream> com.healthmarketscience.rmiio.RemoteInputStreamServer
public abstract class RemoteInputStreamServer
Server implementation base class for a RemoteInputStream. Handles the retry logic (the sequence ids) and the RemoteStreamMonitor updates for the server. Subclasses must implement the actual data handling methods.
RemoteStreamServer.writeReplace()
,
Serialized FormField Summary | |
---|---|
protected int |
_chunkSize
the target chunk size for data packets sent over the wire |
protected InputStream |
_in
the real input stream from which we are reading data |
static int |
DEFAULT_CHUNK_SIZE
default chunk size for shuffling data over the wire. |
static RemoteStreamMonitor<RemoteInputStreamServer> |
DUMMY_MONITOR
Default monitor for operations done by RemoteInputStreamServer which does nothing. |
Fields inherited from class com.healthmarketscience.rmiio.RemoteStreamServer |
---|
_monitor, INITIAL_INVALID_SEQUENCE_ID, INITIAL_VALID_SEQUENCE_ID, LOG |
Constructor Summary | |
---|---|
protected |
RemoteInputStreamServer(InputStream in)
|
protected |
RemoteInputStreamServer(InputStream in,
RemoteStreamMonitor<RemoteInputStreamServer> monitor)
|
|
RemoteInputStreamServer(InputStream in,
RemoteStreamMonitor<RemoteInputStreamServer> monitor,
int chunkSize)
|
Method Summary | |
---|---|
int |
available()
Returns the number of bytes that can be read from this stream without blocking. |
protected abstract int |
availableImpl()
Returns the number of bytes that can be read from this stream without blocking. |
void |
close(boolean readSuccess)
Closes the input stream and releases the resources for this server object. |
protected void |
closeImpl(boolean readSuccess)
Closes (possibly flushes) the underlying streams and cleans up any resources. |
protected RemoteInputStreamServer |
getAsSub()
Returns a handle to this object as a subclass instance. |
InputStream |
getInputStream()
Returns the real InputStream from which this stream is reading data |
protected Object |
getLock()
Returns a handle to the object used to lock the underlying stream operations for this remote stream. |
Class<RemoteInputStream> |
getRemoteClass()
|
protected abstract byte[] |
readPacket()
Reads the next packet of approximately _chunkSize from the
underlying stream and returns it. |
byte[] |
readPacket(int packetId)
Reads the next chunk of data for this stream. |
protected abstract long |
skip(long n)
Skips at most the given amount of bytes in the underlying stream and returns the actual number of bytes skipped. |
long |
skip(long n,
int skipId)
Skips and discards up to the given number of bytes in the stream, and returns the actual number of bytes skipped. |
Methods inherited from class com.healthmarketscience.rmiio.RemoteStreamServer |
---|
abort, checkAborted, close, export, exported, finish, isClosed, unreferenced, writeReplace |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.healthmarketscience.rmiio.RemoteInputStream |
---|
usingGZIPCompression |
Field Detail |
---|
public static final int DEFAULT_CHUNK_SIZE
public static final RemoteStreamMonitor<RemoteInputStreamServer> DUMMY_MONITOR
protected final transient InputStream _in
protected final transient int _chunkSize
Constructor Detail |
---|
protected RemoteInputStreamServer(InputStream in)
protected RemoteInputStreamServer(InputStream in, RemoteStreamMonitor<RemoteInputStreamServer> monitor)
public RemoteInputStreamServer(InputStream in, RemoteStreamMonitor<RemoteInputStreamServer> monitor, int chunkSize)
in
- the real input stream from which the data will be readmonitor
- monitor for tracking the progress of the stream usagechunkSize
- target value for the byte size of the packets of data
sent over the wire. note that this is a suggestion,
actual package sizes may vary.Method Detail |
---|
public InputStream getInputStream()
protected final Object getLock()
RemoteStreamServer
getLock
in class RemoteStreamServer<RemoteInputStreamServer,RemoteInputStream>
protected RemoteInputStreamServer getAsSub()
RemoteStreamServer
getAsSub
in class RemoteStreamServer<RemoteInputStreamServer,RemoteInputStream>
public Class<RemoteInputStream> getRemoteClass()
getRemoteClass
in class RemoteStreamServer<RemoteInputStreamServer,RemoteInputStream>
protected void closeImpl(boolean readSuccess) throws IOException
RemoteStreamServer
closeImpl
in class RemoteStreamServer<RemoteInputStreamServer,RemoteInputStream>
readSuccess
- true
iff all data was successfully
transferred, false
otherwise
IOException
public final void close(boolean readSuccess) throws IOException
RemoteInputStream
close
in interface RemoteInputStream
readSuccess
- true
iff all data was read successfully
by the client, false
otherwise
IOException
public final int available() throws IOException
RemoteInputStream
available
in interface RemoteInputStream
IOException
public final byte[] readPacket(int packetId) throws IOException
RemoteInputStream
readPacket
in interface RemoteInputStream
packetId
- client specified id for this packet
IOException
public final long skip(long n, int skipId) throws IOException
RemoteInputStream
skip
in interface RemoteInputStream
n
- the number of bytes to skipskipId
- client specified id for this skip attempt
IOException
protected abstract int availableImpl() throws IOException
IOException
protected abstract byte[] readPacket() throws IOException
_chunkSize
from the
underlying stream and returns it. If this stream is using compression,
this packet should contain compressed data.
IOException
protected abstract long skip(long n) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |