com.healthmarketscience.rmiio
Class RemoteInputStreamWrapper

java.lang.Object
  extended by com.healthmarketscience.rmiio.RemoteWrapper<RemoteInputStream>
      extended by com.healthmarketscience.rmiio.RemoteInputStreamWrapper
All Implemented Interfaces:
RemoteClient, RemoteInputStream, InvocationHandler, Remote

public class RemoteInputStreamWrapper
extends RemoteWrapper<RemoteInputStream>
implements RemoteInputStream

Wrapper for a RemoteInputStream stub which handles retry magic under the hood. The retry policy for a given method call will use the internal policy for the default methods, but may be overridden on a per-call basis using the extended methods.

Author:
James Ahlborn

Field Summary
 
Fields inherited from class com.healthmarketscience.rmiio.RemoteWrapper
_log, _retry, _stub
 
Fields inherited from interface com.healthmarketscience.rmiio.RemoteClient
DEFAULT_RETRY
 
Constructor Summary
RemoteInputStreamWrapper(RemoteInputStream stub, RemoteRetry retry, org.apache.commons.logging.Log log)
           
 
Method Summary
 int available()
          Returns the number of bytes that can be read from this stream without blocking.
 int available(RemoteRetry retry)
           
 void close(boolean readSuccess)
          Closes the input stream and releases the resources for this server object.
 void close(boolean readSuccess, RemoteRetry retry)
           
 byte[] readPacket(int packetId)
          Reads the next chunk of data for this stream.
 byte[] readPacket(int packetId, RemoteRetry retry)
           
 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.
 long skip(long n, int skipId, RemoteRetry retry)
           
 boolean usingGZIPCompression()
          Returns true if the stream is using GZIP compression over the wire.
 boolean usingGZIPCompression(RemoteRetry retry)
           
 
Methods inherited from class com.healthmarketscience.rmiio.RemoteWrapper
getLog, getRemoteRetry, getStub, getWrapper, invoke, setRemoteRetry, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteInputStreamWrapper

public RemoteInputStreamWrapper(RemoteInputStream stub,
                                RemoteRetry retry,
                                org.apache.commons.logging.Log log)
Method Detail

usingGZIPCompression

public boolean usingGZIPCompression()
                             throws IOException
Description copied from interface: RemoteInputStream
Returns true if the stream is using GZIP compression over the wire.

Specified by:
usingGZIPCompression in interface RemoteInputStream
Returns:
true iff the stream data is compressed, false otherwise
Throws:
IOException

usingGZIPCompression

public boolean usingGZIPCompression(RemoteRetry retry)
                             throws IOException
Throws:
IOException

available

public int available()
              throws IOException
Description copied from interface: RemoteInputStream
Returns the number of bytes that can be read from this stream without blocking. Note that this is an approximate number and should be treated as such.

Specified by:
available in interface RemoteInputStream
Returns:
the number of bytes that can be read without blocking
Throws:
IOException

available

public int available(RemoteRetry retry)
              throws IOException
Throws:
IOException

close

public void close(boolean readSuccess)
           throws IOException
Description copied from interface: RemoteInputStream
Closes the input stream and releases the resources for this server object. Note that the remote object may no longer be accessible after this call (depending on the implementation), so clients should not attempt to use this stream after making this call.

Specified by:
close in interface RemoteInputStream
Parameters:
readSuccess - true iff all data was read successfully by the client, false otherwise
Throws:
IOException

close

public void close(boolean readSuccess,
                  RemoteRetry retry)
           throws IOException
Throws:
IOException

readPacket

public byte[] readPacket(int packetId)
                  throws IOException
Description copied from interface: RemoteInputStream
Reads the next chunk of data for this stream. The amount of data returned is up to the underlying implementation. The given packetId parameter (if used correctly) allows this operation to be idempotent. This parameter must be a monotonically increasing, positive integer. If the client fails to receive a given packet, it may reattempt to retrieve the same packet by giving the same packetId as from the failed call. However, only the current packet may be reattempted (the client cannot attempt to retrieve any other previous packets). When requesting a new packet, the caller does not need to give a sequential id, just a greater one (hence the term monotonically increasing).

Specified by:
readPacket in interface RemoteInputStream
Parameters:
packetId - client specified id for this packet
Returns:
iff the packetId was the same one from the last read call, returns the last read chunk of data. Otherwise, reads and returns a new chunk of data.
Throws:
IOException

readPacket

public byte[] readPacket(int packetId,
                         RemoteRetry retry)
                  throws IOException
Throws:
IOException

skip

public long skip(long n,
                 int skipId)
          throws IOException
Description copied from interface: RemoteInputStream
Skips and discards up to the given number of bytes in the stream, and returns the actual number of bytes skipped. This method is not allowed to be called if using compression on the wire (because of the various layers of buffering). The given skipId parameter (if used correctly) allows this operation to be idempotent. This parameter must be a monotonically increasing, positive integer. If the client fails to receive the return from a skip call, it may reattempt the same skip call by giving the same skipId as from the failed call. However, only the current skip may be reattempted (the client cannot reattempt previous skips). When attempting a new skip call, the caller does not need to give a sequential id, just a greater one (hence the term monotonically increasing).

Specified by:
skip in interface RemoteInputStream
Parameters:
n - the number of bytes to skip
skipId - client specified id for this skip attempt
Returns:
iff the skipId was the same one from the last skip call, returns the result of the last skip call. Otherwise, skips up to the given number of bytes and returns the actual number of bytes skipped.
Throws:
IOException

skip

public long skip(long n,
                 int skipId,
                 RemoteRetry retry)
          throws IOException
Throws:
IOException


Copyright © 2006–2016 Health Market Science. All rights reserved.