com.healthmarketscience.rmiio
Interface RemoteOutputStream

All Superinterfaces:
Flushable, Remote
All Known Implementing Classes:
GZIPRemoteOutputStream, RemoteOutputStreamClientProxy, RemoteOutputStreamServer, RemoteOutputStreamWrapper, SimpleRemoteOutputStream

public interface RemoteOutputStream
extends Remote, Flushable

Remote interface which allows exporting an OutputStream-like interface over the network. When combined with the RemoteOutputStreamServer subclasses on the server side and the RemoteOutputStreamClient on the client side, this class provides a true remote OutputStream (in other words, should never be used alone, use the utility classes).

Note that all methods on this interface are idempotent (when used correctly), and can therefore be retried as necessary in the face of RemoteExceptions.

An actual instance of this class is not intended for use by more than one client, and should be treated in a similar manner to an "un-synchronized" local interface.

Author:
James Ahlborn

Method Summary
 void close(boolean writeSuccess)
          Closes the output stream and releases the resources for this server object.
 void flush()
          Flushes the output stream and forces as much as possible of any buffered bytes to be written out.
 boolean usingGZIPCompression()
          Returns true if the stream is using GZIP compression over the wire.
 void writePacket(byte[] packet, int packetId)
          Writes the next chunk of data to this stream.
 

Method Detail

usingGZIPCompression

boolean usingGZIPCompression()
                             throws IOException,
                                    RemoteException
Returns true if the stream is using GZIP compression over the wire.

Returns:
true iff the stream data is compressed, false otherwise
Throws:
IOException
RemoteException

close

void close(boolean writeSuccess)
           throws IOException,
                  RemoteException
Closes the output 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.

Parameters:
writeSuccess - true iff all data was sent successfully from the client, false otherwise
Throws:
IOException
RemoteException

flush

void flush()
           throws IOException,
                  RemoteException
Flushes the output stream and forces as much as possible of any buffered bytes to be written out. Some of the layers of buffering may not be able to be flushed, so this method should not be depended upon to do much. The close() method will do any final flushing necessary (and can be depended upon).

Specified by:
flush in interface Flushable
Throws:
IOException
RemoteException

writePacket

void writePacket(byte[] packet,
                 int packetId)
                 throws IOException,
                        RemoteException
Writes the next chunk of data to this stream. 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 write a given packet, it may reattempt to write 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 write any other previous packets). When writing a new packet, the caller does not need to give a sequential id, just a greater one (hence the term monotonically increasing).

Parameters:
packet - iff the packetId was the same one from the last read call, this chunk of data is ignored. Otherwise, writes this new chunk of data to the stream.
packetId - client specified id for this packet
Throws:
IOException
RemoteException


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