Package org.apache.derby.impl.drda
Class EXTDTAReaderInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.derby.impl.drda.EXTDTAReaderInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
LayerBStreamedEXTDTAReaderInputStream
,StandardEXTDTAReaderInputStream
abstract class EXTDTAReaderInputStream extends java.io.InputStream
Implementation of InputStream which get EXTDTA from the DDMReader.This class can be used to stream LOBs from Network client to the Network server.
To be able to correctly stream data from the client without reading the while value up front, a trailing Derby-specific status byte was introduced (version 10.6). It is used by the client to tell the server if the data it received was valid, or if it detected an error while streaming the data. The DRDA protocol, or at least Derby's implementation of it, doesn't enable the client to inform the server about the error whilst streaming (there is a mechanism in DRDA to interrupt a running request, but it didn't seem like a feasible approach in this case).
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
isLayerBStream
Whether or not the subclass is a layer B stream.protected boolean
readStatusByte
Whether or not to read the trailing Derby-specific status byte.private byte
status
The status Derby-specific status byte, if any.private boolean
statusSet
Tells if the status byte has been set.private boolean
suppressException
Whether or not to suppress the exception when an error is indicated by the status byte.
-
Constructor Summary
Constructors Modifier Constructor Description protected
EXTDTAReaderInputStream(boolean layerB, boolean readStatusByte)
Initializes the class.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkStatus(int clientStatus)
Interprets the Derby-specific status byte, and throws an exception if an error condition has been detected on the client.byte
getStatus()
Returns the status byte.boolean
isLayerBStream()
boolean
isStatusSet()
Returns whether the status has been set or not.protected abstract void
onClientSideStreamingError()
Performs necessary clean up when an error is signalled by the client.private void
setStatus(int status)
Saves the status byte read off the wire.(package private) void
setSuppressException(boolean flag)
Sets whether or not to suppress the exception when setting the status.(package private) static void
throwEXTDTATransferException(int status)
Throws an exception as mandated by the EXTDTA status byte.
-
-
-
Field Detail
-
isLayerBStream
protected final boolean isLayerBStream
Whether or not the subclass is a layer B stream.
-
readStatusByte
protected final boolean readStatusByte
Whether or not to read the trailing Derby-specific status byte.
-
statusSet
private boolean statusSet
Tells if the status byte has been set.- See Also:
checkStatus(int)
-
status
private byte status
The status Derby-specific status byte, if any.- See Also:
isStatusSet()
-
suppressException
private boolean suppressException
Whether or not to suppress the exception when an error is indicated by the status byte.
-
-
Method Detail
-
setStatus
private void setStatus(int status)
Saves the status byte read off the wire.- Parameters:
status
- the status- See Also:
DRDAConstants
-
isStatusSet
public boolean isStatusSet()
Returns whether the status has been set or not.- Returns:
true
if set,false
if not.
-
getStatus
public byte getStatus()
Returns the status byte.NOTE: Check if the status byte has been set by calling isStatusSet().
- Returns:
- The status byte.
-
setSuppressException
void setSuppressException(boolean flag)
Sets whether or not to suppress the exception when setting the status.- Parameters:
flag
-true
to suppress,false
to throw exception if an error condition is indicated by the status flag
-
isLayerBStream
public boolean isLayerBStream()
-
checkStatus
protected void checkStatus(int clientStatus) throws java.io.IOException
Interprets the Derby-specific status byte, and throws an exception if an error condition has been detected on the client.- Parameters:
clientStatus
- the status flag sent by the client- Throws:
java.io.IOException
- if the status byte indicates an error condition
-
onClientSideStreamingError
protected abstract void onClientSideStreamingError()
Performs necessary clean up when an error is signalled by the client.
-
throwEXTDTATransferException
static void throwEXTDTATransferException(int status) throws java.io.IOException
Throws an exception as mandated by the EXTDTA status byte.- Parameters:
status
- the EXTDTA status byte received from the client, should not be DRDAConstants.STREAM_OK- Throws:
java.io.IOException
- the exception generated based on the status byte
-
-