Hyperic HQ Plugin API v. 4.4.0.2

org.hyperic.hq.transport.util
Class InputStreamServiceImpl

java.lang.Object
  extended by org.hyperic.hq.transport.util.InputStreamServiceImpl
All Implemented Interfaces:
InputStreamService

public class InputStreamServiceImpl
extends java.lang.Object
implements InputStreamService

The input stream service implementation that resides on the remote source from which a RemoteInputStream reads its data. It is expected that the remote source will retrieve a remote stream instance, send it to the remote client, and then, within a single thread, the remote source write the buffers to the remote stream until the end of stream is signaled. To prevent an excessive amount of buffered data from residing in main memory (on the source or client), buffer writes and reads are serialized such that only one buffer of data may be stored at any time in the remote source and the remote client.


Field Summary
static int DEFAULT_INPUTSTREAM_TIMEOUT
          The default remote input stream timeout (60 seconds).
static java.lang.String INPUTSTREAM_TIMEOUT
          The system property key for the remote input stream timeout (in seconds).
 
Method Summary
static InputStreamServiceImpl getInstance()
           
 StreamBuffer getNextBuffer(java.lang.String streamId)
          Retrieve the next buffer of data for the RemoteInputStream
 RemoteInputStream getRemoteStream()
          Retrieve the remote stream to send to the remote client.
 void signalEndOfRemoteStream(java.lang.String streamId)
          Signal that the end of stream has been reached for a given remote stream.
 void writeBufferToRemoteStream(java.lang.String streamId, byte[] buffer)
          Write a buffer to the remote stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INPUTSTREAM_TIMEOUT

public static final java.lang.String INPUTSTREAM_TIMEOUT
The system property key for the remote input stream timeout (in seconds). This timeout corresponds to the maximum time that a thread writing a buffer to a remote stream will be blocked waiting for the previously written buffer to be read. It also corresponds to the maximum time that the remote client retrieving the next buffer will wait for a buffer to be written to the remote stream.

See Also:
Constant Field Values

DEFAULT_INPUTSTREAM_TIMEOUT

public static final int DEFAULT_INPUTSTREAM_TIMEOUT
The default remote input stream timeout (60 seconds).

See Also:
Constant Field Values
Method Detail

getInstance

public static InputStreamServiceImpl getInstance()
Returns:
The singleton instance. of this service.

getNextBuffer

public StreamBuffer getNextBuffer(java.lang.String streamId)
                           throws java.io.IOException
Description copied from interface: InputStreamService
Retrieve the next buffer of data for the RemoteInputStream

Specified by:
getNextBuffer in interface InputStreamService
Parameters:
streamId - The remote input stream id.
Returns:
The buffer of data.
Throws:
java.io.IOException - if there is no remote stream registered for the given stream id or if there is no buffered data available to be read.
See Also:
InputStreamService.getNextBuffer(java.lang.String)

getRemoteStream

public RemoteInputStream getRemoteStream()
Retrieve the remote stream to send to the remote client.

Returns:
The remote input stream.

writeBufferToRemoteStream

public void writeBufferToRemoteStream(java.lang.String streamId,
                                      byte[] buffer)
                               throws java.lang.InterruptedException,
                                      java.io.IOException
Write a buffer to the remote stream. This method blocks until the previously written buffer has been read by the remote client.

Parameters:
streamId - The remote input stream id.
buffer - The buffer to write to the remote stream.
Throws:
java.io.IOException - if there is no remote stream registered for the given stream id or if the DEFAULT_INPUTSTREAM_TIMEOUT is reached.
java.lang.NullPointerException - if the buffer is null.
java.lang.IllegalArgumentException - if the buffer is empty.
java.lang.InterruptedException

signalEndOfRemoteStream

public void signalEndOfRemoteStream(java.lang.String streamId)
                             throws java.lang.InterruptedException,
                                    java.io.IOException
Signal that the end of stream has been reached for a given remote stream. This signal unregisters the remote stream so that no more buffers may be written to it. This method blocks until the previously written buffer has been read by the remote client.

Parameters:
streamId - The remote input stream id.
Throws:
java.io.IOException - if there is no remote stream registered for the given stream id or if the DEFAULT_INPUTSTREAM_TIMEOUT is reached.
java.lang.InterruptedException

Hyperic HQ Plugin API v. 4.4.0.2

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.