class DDMReader
extends java.lang.Object
At layer A are request, reply and data correlation, structure chaining, continuation or termination of chains when errors are detected, interleaving and multi-leaving request, reply, and data DSSs for multitasking environments. For TCP/IP, the format of the DDM envelope is 2 bytes Length of the data 1 byte 'D0' - indicates DDM data 1 byte DDM format byte(DSSFMT) - type of DSS(RQSDSS,RPYDSS), whether it is chained, information about the next chained DSS 2 bytes request correlation identifier
The correlation identifier ties together a request, the request data and the reply. In a chained DSS, each request has a correlation identifier which is higher than the previous request (all correlation identifiers must be greater than 0).
At layer B are object mapping, object validation and command routing. Layer B objects with data 5 bytes less than 32K bytes consist of 2 bytes Length 2 bytes Type of the object (code point) Object data Object data is either SCALAR or COLLECTION data. Scalar data consists of a string of bytes formatted as the class description of the object required. Collections consist of a set of objects in which the entries in the collection are nested within the length/ code point of the collection.
Layer B objects with data >=32763 bytes long format is 2 bytes Length - length of class, length, and extended total length fields (high order bit set, indicating >=32763) 2 bytes Type of the object (code point) n bytes Extended total length - length of the object (n = Length - 4) Object data
At layer C are services each class of DDM object provides. |-------------------------------------------| Layer C | Specific | Specific | Specific | | Commands | Replies | Scalars and | | and their | and their | Collections | |-------------------------------------------|----------------| Layer B | Commands | Reply | Scalars and | Communications | | | Messages | Collections | | |-----------|---------------|---------------|----------------| Layer A | RQSDSS | RPYDSS | OBJDSS | CMNDSS | | | | | Mapped Data | |-----------|---------------|---------------|----------------| | DDM Data Stream Structures | |------------------------------------------------------------| DSS's may be chained so that more than one can be transmitted at a time to improve performance. For more details, see DRDA Volume 3 (Distributed Data Management(DDM) Architecture (DDS definition)
Modifier and Type | Field and Description |
---|---|
private static boolean |
ADJUST_LENGTHS |
private DRDAConnThread |
agent |
private byte[] |
buffer |
private CcsidManager |
ccsidManager |
private int |
count |
private long[] |
ddmCollectionLenStack |
private long |
ddmScalarLen |
private static int |
DEFAULT_BUFFER_SIZE |
private boolean |
doingLayerBStreaming |
private int |
dssCorrelationID |
private boolean |
dssIsChainedWithDiffID |
private boolean |
dssIsChainedWithSameID |
private boolean |
dssIsContinued |
private int |
dssLength |
private DssTrace |
dssTrace |
private EbcdicCcsidManager |
ebcdicCcsidManager |
private static int |
EMPTY_STACK |
private java.io.InputStream |
inputStream |
private static long |
MAX_EXTDTA_SIZE |
private static int |
MAX_MARKS_NESTING |
private static boolean |
NO_ADJUST_LENGTHS |
private static int |
NO_CODEPOINT |
private int |
pos |
private int |
prevCorrelationID |
private int |
svrcod |
private static int[][] |
tenRadixMagnitude |
private boolean |
terminateChainOnErr |
private int |
topDdmCollectionStack |
(package private) long |
totalByteCount |
private Utf8CcsidManager |
utf8CcsidManager |
Constructor and Description |
---|
DDMReader(DRDAConnThread agent,
DssTrace dssTrace) |
DDMReader(java.io.InputStream inputStream)
This constructor is used for testing the protocol
It is used by ProtocolTestAdapter to read the protocol returned by the
server
|
Modifier and Type | Method and Description |
---|---|
private void |
adjustLengths(int length)
Adjust remaining length
|
protected void |
clearBuffer() |
private void |
compressBLayerData(int continueDssHeaderCount)
Compress B Layer data if extended total length is used
by removing the continuation headers
|
private int[] |
computeMagnitude(int[] input)
Compute the int array of magnitude from input value segments.
|
protected java.lang.String |
convertBytes(byte[] buf)
Convert EBCDIC byte array to unicode string
|
(package private) boolean |
doingLayerBStreaming() |
private void |
ensureALayerDataInBuffer(int desiredDataSize)
Make sure a certain amount of Layer A data is in the buffer.
|
private void |
ensureBLayerDataInBuffer(int desiredDataSize,
boolean adjustLen)
Make sure a certain amount of Layer B data is in the buffer.
|
private void |
ensureSpaceInBufferForFill(int desiredSpace)
This method makes sure there is enough room in the buffer
for a certain number of bytes.
|
private void |
fill(int minimumBytesNeeded)
This method will attempt to read a minimum number of bytes
from the underlying stream.
|
private void |
finishLayerBStreaming() |
protected int |
getCodePoint()
Get the next CodePoint from a collection
|
protected int |
getCodePoint(int codePointCheck)
Get the next CodePoint from a collection and check that it matches the specified
CodePoint
|
protected byte |
getCurrChainState()
Return chaining bit for current DSS.
|
protected long |
getDdmLength()
Length of current DDM object
|
(package private) byte[] |
getExtData(long desiredLength,
boolean checkNullability) |
(package private) EXTDTAReaderInputStream |
getEXTDTAReaderInputStream(boolean checkNullability)
Creates an InputStream which can stream EXTDTA objects.
|
protected void |
initialize(DRDAConnThread agent,
DssTrace dssTrace)
Initialize values for this session, the reader is reused so we need to
set null and 0 values
|
protected boolean |
isChainedWithDiffID()
Next DSS has different correlator than current DSS
|
protected boolean |
isChainedWithSameID()
Next DSS has same correlator as current DSS
|
protected boolean |
isCmd()
Check for the command protocol
|
private boolean |
isEXTDTANull() |
protected void |
markCollection()
Push DDM Length on to collection stack
|
protected boolean |
moreData()
Is there more data in the buffer
|
protected boolean |
moreDdmData()
Is there more in this DDM object
|
protected boolean |
moreDssData()
Is there more in this DDS object
|
private int |
packedNybblesToInt(byte[] buffer,
int offset,
int startNybble,
int numberOfNybbles)
Convert a range of packed nybbles (up to 9 digits without overflow) to an int.
|
private long |
packedNybblesToLong(byte[] buffer,
int offset,
int startNybble,
int numberOfNybbles)
Convert a range of packed nybbles (up to 18 digits without overflow) to a long.
|
protected java.math.BigDecimal |
readBigDecimal(int precision,
int scale)
Read a BigDecimal value
|
protected byte |
readByte()
Read byte value
|
protected byte[] |
readBytes()
Read byte string value
|
protected byte[] |
readBytes(int length)
Read byte string value
|
protected java.lang.String |
readCmdString()
Read string value
|
protected java.lang.String |
readCmdString(int length)
Read string value
|
protected int |
readCodePoint()
Read the CodePoint
|
protected double |
readDouble(int byteOrder)
Read platform double value
|
private void |
readDSSContinuationHeader() |
protected int |
readDssHeader()
Read DSS header
DSS Header format is
2 bytes - length
1 byte - 'D0' - indicates DDM data
1 byte - DSS format
|---|---------|----------|
| 0 | flags | type |
|---|---------|----------|
| 0 | 1 2 3 | 4 5 6 7 |
|---|---------|----------|
bit 0 - '0'
bit 1 - '0' - unchained, '1' - chained
bit 2 - '0' - do not continue on error, '1' - continue on error
bit 3 - '0' - next DSS has different correlator, '1' - next DSS has
same correlator
type - 1 - Request DSS
- 2 - Reply DSS
- 3 - Object DSS
- 4 - Communications DSS
- 5 - Request DSS where no reply is expected
2 bytes - request correlation id
|
protected java.lang.String |
readEncryptedString(DecryptionManager decryptM,
int securityMechanism,
byte[] initVector,
byte[] sourcePublicKey)
Read encrypted string
|
protected float |
readFloat(int byteOrder)
Read platform float value
|
protected int |
readInt(int byteOrder)
Read platform int value
|
protected java.lang.String |
readLDStringData(java.lang.String encoding)
Read length delimited string value in DDM data with default encoding
|
protected int |
readLengthAndCodePoint(boolean isLayerBStreamingPossible)
Read the DDM Length and CodePoint
|
private java.io.ByteArrayInputStream |
readLOBChunk(boolean readHeader,
long desiredLength)
This method is used by EXTDTAReaderInputStream to read the next chunk
of data.
|
(package private) java.io.ByteArrayInputStream |
readLOBContinuationStream()
This method is used by EXTDTAReaderInputStream to read the next chunk
of data.
|
(package private) java.io.ByteArrayInputStream |
readLOBContinuationStream(long desiredLength)
This method is used by EXTDTAReaderInputStream to read the next chunk
of data.
|
(package private) java.io.ByteArrayInputStream |
readLOBInitStream()
This method is used by EXTDTAReaderInputStream to read the first chunk
of data.
|
(package private) java.io.ByteArrayInputStream |
readLOBInitStream(long desiredLength)
This method is used by EXTDTAReaderInputStream to read the first chunk
of data.
|
protected long |
readLong(int byteOrder)
Read platform long value
|
protected int |
readNetworkInt()
Read network int value
|
protected long |
readNetworkLong()
Read network long value
|
protected int |
readNetworkShort()
Read network short value
|
protected long |
readNetworkSixByteLong()
Read network six byte value and put it in a long v
|
protected void |
readReplyDss()
Read Reply DSS
This is used in testing the protocol.
|
protected short |
readShort(int byteOrder)
Read platform short value
|
protected int |
readSignedNetworkShort()
Read signed network short value
|
protected java.lang.String |
readString()
Read string value
|
protected void |
readString(DRDAString dst,
int size,
boolean unpad)
Read string value into a
DRDAString object. |
protected java.lang.String |
readString(int length)
Read string value
Strings in DRDA protocol are encoded in EBCDIC by default so we
need to convert to UCS2
|
protected java.lang.String |
readString(int length,
java.lang.String encoding)
Read encoded string value
|
protected java.lang.String |
readStringData(int length)
Read specified length of string value in DDM data with default encoding
|
protected int |
readUnsignedByte()
Read byte value and mask out high order bytes before returning
|
protected void |
setEbcdicCcsid() |
protected void |
setUtf8Ccsid() |
private void |
shiftBuffer(byte[] destinationBuffer)
This is a helper method which shifts the buffered bytes from
wherever they are in the current buffer to the beginning of
different buffer (note these buffers could be the same).
|
protected void |
skipBytes()
Skip byte string value
|
protected void |
skipBytes(int length)
Skip byte string value
|
protected void |
skipDss()
Skip remaining DSS
|
private void |
startLayerBStreaming() |
protected boolean |
terminateChainOnErr() |
private void |
trace(java.lang.String msg)
Print a internal trace message
|
private static final int DEFAULT_BUFFER_SIZE
private static final int MAX_MARKS_NESTING
private static final int NO_CODEPOINT
private static final int EMPTY_STACK
private static final boolean ADJUST_LENGTHS
private static final boolean NO_ADJUST_LENGTHS
private static final long MAX_EXTDTA_SIZE
private static final int[][] tenRadixMagnitude
private DRDAConnThread agent
private Utf8CcsidManager utf8CcsidManager
private EbcdicCcsidManager ebcdicCcsidManager
private CcsidManager ccsidManager
private byte[] buffer
private int pos
private int count
private int topDdmCollectionStack
private long[] ddmCollectionLenStack
private long ddmScalarLen
private int dssLength
private boolean dssIsContinued
private boolean terminateChainOnErr
private boolean dssIsChainedWithSameID
private boolean dssIsChainedWithDiffID
private int dssCorrelationID
private int prevCorrelationID
private int svrcod
private DssTrace dssTrace
private java.io.InputStream inputStream
private boolean doingLayerBStreaming
volatile long totalByteCount
DDMReader(DRDAConnThread agent, DssTrace dssTrace)
DDMReader(java.io.InputStream inputStream)
protected void initialize(DRDAConnThread agent, DssTrace dssTrace)
protected void setUtf8Ccsid()
protected void setEbcdicCcsid()
protected boolean terminateChainOnErr()
protected boolean isChainedWithSameID()
protected boolean isChainedWithDiffID()
protected long getDdmLength()
protected boolean moreDdmData()
protected boolean moreDssData()
protected boolean moreData()
protected boolean isCmd() throws DRDAProtocolException, java.io.UnsupportedEncodingException
DRDAProtocolException
- if a protocol error is detectedjava.io.UnsupportedEncodingException
protected int readDssHeader() throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected void readReplyDss() throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected int readLengthAndCodePoint(boolean isLayerBStreamingPossible) throws DRDAProtocolException
isLayerBStreamingPossible
- true only when layer B streaming is possibleDRDAProtocolException
- if a protocol error is detectedprotected int readCodePoint()
protected void markCollection()
protected int getCodePoint() throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected int getCodePoint(int codePointCheck) throws DRDAProtocolException
codePointCheck
- - codePoint to check againstDRDAProtocolException
- if a protocol error is detectedprotected byte readByte() throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected int readUnsignedByte() throws DRDAProtocolException
DRDAProtocolException
protected int readNetworkShort() throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected int readSignedNetworkShort() throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected short readShort(int byteOrder) throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected int readNetworkInt() throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected int readInt(int byteOrder) throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected long readNetworkLong() throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected long readNetworkSixByteLong() throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected long readLong(int byteOrder) throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected float readFloat(int byteOrder) throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected double readDouble(int byteOrder) throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected java.math.BigDecimal readBigDecimal(int precision, int scale) throws DRDAProtocolException
precision
- of the BigDecimalscale
- of the BigDecimalDRDAProtocolException
- if a protocol error is detectedEXTDTAReaderInputStream getEXTDTAReaderInputStream(boolean checkNullability) throws DRDAProtocolException
checkNullability
- used to check if the stream is null. If it is
null, this method returns nullDRDAProtocolException
- standard DRDA protocol exceptionjava.io.ByteArrayInputStream readLOBInitStream() throws DRDAProtocolException
DRDAProtocolException
- standard DRDA protocol exceptionjava.io.ByteArrayInputStream readLOBInitStream(long desiredLength) throws DRDAProtocolException
desiredLength
- the desired length of chunk. This parameter is ignored when layerB Streaming is doing.DRDAProtocolException
- standard DRDA protocol exceptionjava.io.ByteArrayInputStream readLOBContinuationStream() throws java.io.IOException
java.io.IOException
- IOExceptionjava.io.ByteArrayInputStream readLOBContinuationStream(long desiredLength) throws java.io.IOException
desiredLength
- the desired length of chunk. This parameter is ignored when layerB Streaming is doing.java.io.IOException
- IOExceptionprivate java.io.ByteArrayInputStream readLOBChunk(boolean readHeader, long desiredLength) throws DRDAProtocolException
readHeader
- set to true if the dss continuation should be readdesiredLength
- the desired length of chunk. This parameter is ignored when layerB Streaming is doing.DRDAProtocolException
- standard DRDA protocol exceptionbyte[] getExtData(long desiredLength, boolean checkNullability) throws DRDAProtocolException
DRDAProtocolException
private void readDSSContinuationHeader() throws DRDAProtocolException
DRDAProtocolException
private boolean isEXTDTANull() throws DRDAProtocolException
DRDAProtocolException
private int packedNybblesToInt(byte[] buffer, int offset, int startNybble, int numberOfNybbles)
buffer
- buffer to read fromoffset
- offset in the bufferstartNybble
- start nybblenumberOfNybbles
- number of nybblesprivate long packedNybblesToLong(byte[] buffer, int offset, int startNybble, int numberOfNybbles)
buffer
- buffer to read fromoffset
- offset in the bufferstartNybble
- start nybblenumberOfNybbles
- number of nybblesprivate int[] computeMagnitude(int[] input)
input
- value segmentsprotected java.lang.String readEncryptedString(DecryptionManager decryptM, int securityMechanism, byte[] initVector, byte[] sourcePublicKey) throws DRDAProtocolException, java.sql.SQLException
decryptM
- decryption managersecurityMechanism
- security mechanisminitVector
- initialization vector for ciphersourcePublicKey
- public key (as in Deffie-Hellman algorithm)
from source (encryptor)DRDAProtocolException
- if a protocol error is detectedjava.sql.SQLException
- wrapping any exception in decryptionprotected java.lang.String readString(int length) throws DRDAProtocolException
length
- - length of string to readDRDAProtocolException
- if a protocol error is detectedprotected void readString(DRDAString dst, int size, boolean unpad) throws DRDAProtocolException
DRDAString
object.dst
- destination for the read stringsize
- size (in bytes) of string to readunpad
- if true, remove padding (trailing spaces)DRDAProtocolException
protected java.lang.String readString(int length, java.lang.String encoding) throws DRDAProtocolException
length
- - length of string to readDRDAProtocolException
- if a protocol error is detectedprotected java.lang.String readStringData(int length) throws DRDAProtocolException
length
- - length of string to readDRDAProtocolException
- if a protocol error is detectedprotected java.lang.String readLDStringData(java.lang.String encoding) throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected java.lang.String readString() throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected byte[] readBytes(int length) throws DRDAProtocolException
length
- - length of string to readDRDAProtocolException
- if a protocol error is detectedprotected byte[] readBytes() throws DRDAProtocolException
DRDAProtocolException
- if a protocol error is detectedprotected void skipBytes(int length) throws DRDAProtocolException
length
- - length of string to skipDRDAProtocolException
- if a protocol error is detectedprotected void skipBytes() throws DRDAProtocolException
DRDAProtocolException
protected void skipDss() throws DRDAProtocolException
DRDAProtocolException
protected void clearBuffer() throws DRDAProtocolException
DRDAProtocolException
protected java.lang.String convertBytes(byte[] buf)
buf
- - byte arrayprivate void adjustLengths(int length)
length
- - adjustment lengthprotected java.lang.String readCmdString(int length) throws DRDAProtocolException, java.io.UnsupportedEncodingException
length
- - length of string to readDRDAProtocolException
- if a protocol error is detectedjava.io.UnsupportedEncodingException
protected java.lang.String readCmdString() throws DRDAProtocolException, java.io.UnsupportedEncodingException
DRDAProtocolException
- if a protocol error is detectedjava.io.UnsupportedEncodingException
private void ensureALayerDataInBuffer(int desiredDataSize) throws DRDAProtocolException
desiredDataSize
- - amount of data we needDRDAProtocolException
private void ensureBLayerDataInBuffer(int desiredDataSize, boolean adjustLen) throws DRDAProtocolException
desiredDataSize
- - amount of data we needadjustLen
- - whether to adjust the remaining lengthsDRDAProtocolException
- if a protocol error is detectedprivate void compressBLayerData(int continueDssHeaderCount) throws DRDAProtocolException
continueDssHeaderCount
- - amount of data we needthrows
- DRDAProtocolExceptionDRDAProtocolException
private void shiftBuffer(byte[] destinationBuffer)
destinationBuffer
- - buffer to shift data toprivate void ensureSpaceInBufferForFill(int desiredSpace)
desiredSpace
- - amount of data we needprivate void fill(int minimumBytesNeeded) throws DRDAProtocolException
minimumBytesNeeded
- - minimum required bytesDRDAProtocolException
- if a protocol error is detectedprivate void trace(java.lang.String msg)
protected byte getCurrChainState()
private void startLayerBStreaming()
private void finishLayerBStreaming()
boolean doingLayerBStreaming()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.