|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> [ drda overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.impl.drda
Class DDMReader

java.lang.Objectorg.apache.derby.impl.drda.DDMReader
- class DDMReader
- extends java.lang.Object
The DDMReader is used to read DRDA protocol. DRDA Protocol is divided into three layers corresponding to the DDM three-tier architecture. For each layer, their is a DSS (Data Stream Structure) defined. Layer A Communications management services Layer B Agent services Layer C Data management services
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)
| Field Summary | |
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 int |
dssCorrelationID
|
private boolean |
dssIsChainedWithDiffID
|
private boolean |
dssIsChainedWithSameID
|
private boolean |
dssIsContinued
|
private int |
dssLength
|
private DssTrace |
dssTrace
|
private static int |
EMPTY_STACK
|
private java.io.InputStream |
inputStream
|
private static boolean |
internalTrace
|
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
|
| Constructor Summary | |
protected |
DDMReader(CcsidManager ccsidManager,
java.io.InputStream inputStream)
This constructor is used for testing the protocol It is used by TestProto to read the protocol returned by the server |
protected |
DDMReader(DRDAConnThread agent,
DssTrace dssTrace)
|
| Method Summary | |
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 |
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. |
protected byte[] |
getBuffer()
Return buffer |
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(boolean checkNullability)
|
(package private) byte[] |
getExtData(long desiredLength,
boolean checkNullability)
|
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 void |
initialize(java.io.InputStream inputStream)
This initializer is used for testing the protocol It is used by TestProto for the reader it uses |
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 boolean |
readBoolean()
Read boolean 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()
Read the DDM Length and CodePoint |
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 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()
Read string value in DDM data with default encoding |
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 |
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 |
protected boolean |
terminateChainOnErr()
|
protected java.lang.String |
toDebugString(java.lang.String indent)
|
private void |
trace(java.lang.String msg)
Print a internal trace message |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
MAX_MARKS_NESTING
private static final int MAX_MARKS_NESTING
- See Also:
- Constant Field Values
NO_CODEPOINT
private static final int NO_CODEPOINT
- See Also:
- Constant Field Values
EMPTY_STACK
private static final int EMPTY_STACK
- See Also:
- Constant Field Values
ADJUST_LENGTHS
private static final boolean ADJUST_LENGTHS
- See Also:
- Constant Field Values
NO_ADJUST_LENGTHS
private static final boolean NO_ADJUST_LENGTHS
- See Also:
- Constant Field Values
MAX_EXTDTA_SIZE
private static final long MAX_EXTDTA_SIZE
- See Also:
- Constant Field Values
internalTrace
private static boolean internalTrace
tenRadixMagnitude
private static final int[][] tenRadixMagnitude
agent
private DRDAConnThread agent
ccsidManager
private CcsidManager ccsidManager
buffer
private byte[] buffer
pos
private int pos
count
private int count
topDdmCollectionStack
private int topDdmCollectionStack
ddmCollectionLenStack
private long[] ddmCollectionLenStack
ddmScalarLen
private long ddmScalarLen
dssLength
private int dssLength
dssIsContinued
private boolean dssIsContinued
terminateChainOnErr
private boolean terminateChainOnErr
dssIsChainedWithSameID
private boolean dssIsChainedWithSameID
dssIsChainedWithDiffID
private boolean dssIsChainedWithDiffID
dssCorrelationID
private int dssCorrelationID
prevCorrelationID
private int prevCorrelationID
svrcod
private int svrcod
dssTrace
private DssTrace dssTrace
inputStream
private java.io.InputStream inputStream
| Constructor Detail |
DDMReader
protected DDMReader(DRDAConnThread agent, DssTrace dssTrace)
DDMReader
protected DDMReader(CcsidManager ccsidManager, java.io.InputStream inputStream)
- This constructor is used for testing the protocol
It is used by TestProto to read the protocol returned by the
server
| Method Detail |
initialize
protected void initialize(java.io.InputStream inputStream)
- This initializer is used for testing the protocol
It is used by TestProto for the reader it uses
initialize
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
terminateChainOnErr
protected boolean terminateChainOnErr()
isChainedWithSameID
protected boolean isChainedWithSameID()
- Next DSS has same correlator as current DSS
isChainedWithDiffID
protected boolean isChainedWithDiffID()
- Next DSS has different correlator than current DSS
getDdmLength
protected long getDdmLength()
- Length of current DDM object
moreDdmData
protected boolean moreDdmData()
- Is there more in this DDM object
moreDssData
protected boolean moreDssData()
- Is there more in this DDS object
moreData
protected boolean moreData()
- Is there more data in the buffer
isCmd
protected boolean isCmd()
throws DRDAProtocolException,
java.io.UnsupportedEncodingException
- Check for the command protocol
getBuffer
protected byte[] getBuffer()
- Return buffer
readDssHeader
protected int readDssHeader()
throws DRDAProtocolException
- 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
readReplyDss
protected void readReplyDss()
throws DRDAProtocolException
- Read Reply DSS
This is used in testing the protocol. We shouldn't see a reply
DSS when we are servicing DRDA commands
readLengthAndCodePoint
protected int readLengthAndCodePoint()
throws DRDAProtocolException
- Read the DDM Length and CodePoint
readCodePoint
protected int readCodePoint()
- Read the CodePoint
markCollection
protected void markCollection()
- Push DDM Length on to collection stack
getCodePoint
protected int getCodePoint()
throws DRDAProtocolException
- Get the next CodePoint from a collection
getCodePoint
protected int getCodePoint(int codePointCheck)
throws DRDAProtocolException
- Get the next CodePoint from a collection and check that it matches the specified
CodePoint
readByte
protected byte readByte()
throws DRDAProtocolException
- Read byte value
readUnsignedByte
protected int readUnsignedByte()
throws DRDAProtocolException
- Read byte value and mask out high order bytes before returning
readNetworkShort
protected int readNetworkShort()
throws DRDAProtocolException
- Read network short value
readSignedNetworkShort
protected int readSignedNetworkShort()
throws DRDAProtocolException
- Read signed network short value
readShort
protected short readShort(int byteOrder)
throws DRDAProtocolException
- Read platform short value
readNetworkInt
protected int readNetworkInt()
throws DRDAProtocolException
- Read network int value
readInt
protected int readInt(int byteOrder)
throws DRDAProtocolException
- Read platform int value
readNetworkLong
protected long readNetworkLong()
throws DRDAProtocolException
- Read network long value
readNetworkSixByteLong
protected long readNetworkSixByteLong()
throws DRDAProtocolException
- Read network six byte value and put it in a long v
readLong
protected long readLong(int byteOrder)
throws DRDAProtocolException
- Read platform long value
readFloat
protected float readFloat(int byteOrder)
throws DRDAProtocolException
- Read platform float value
readDouble
protected double readDouble(int byteOrder)
throws DRDAProtocolException
- Read platform double value
readBigDecimal
protected java.math.BigDecimal readBigDecimal(int precision, int scale) throws DRDAProtocolException
- Read a BigDecimal value
getExtData
byte[] getExtData(boolean checkNullability)
throws DRDAProtocolException
getExtData
byte[] getExtData(long desiredLength,
boolean checkNullability)
throws DRDAProtocolException
readDSSContinuationHeader
private void readDSSContinuationHeader()
throws DRDAProtocolException
isEXTDTANull
private boolean isEXTDTANull()
throws DRDAProtocolException
packedNybblesToInt
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.
Note that for performance purpose, it does not do array-out-of-bound checking.
packedNybblesToLong
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.
Note that for performance purpose, it does not do array-out-of-bound checking.
computeMagnitude
private int[] computeMagnitude(int[] input)
- Compute the int array of magnitude from input value segments.
readBoolean
protected boolean readBoolean()
throws DRDAProtocolException
- Read boolean value
readEncryptedString
protected java.lang.String readEncryptedString(DecryptionManager decryptM, int securityMechanism, byte[] initVector, byte[] sourcePublicKey) throws DRDAProtocolException, java.sql.SQLException
- Read encrypted string
readString
protected java.lang.String readString(int length) throws DRDAProtocolException
- Read string value
Strings in DRDA protocol are encoded in EBCDIC by default so we
need to convert to UCS2
readString
protected java.lang.String readString(int length, java.lang.String encoding) throws DRDAProtocolException
- Read encoded string value
readStringData
protected java.lang.String readStringData() throws DRDAProtocolException
- Read string value in DDM data with default encoding
readStringData
protected java.lang.String readStringData(int length) throws DRDAProtocolException
- Read specified length of string value in DDM data with default encoding
readLDStringData
protected java.lang.String readLDStringData(java.lang.String encoding) throws DRDAProtocolException
- Read length delimited string value in DDM data with default encoding
readString
protected java.lang.String readString() throws DRDAProtocolException
- Read string value
readBytes
protected byte[] readBytes(int length)
throws DRDAProtocolException
- Read byte string value
readBytes
protected byte[] readBytes()
throws DRDAProtocolException
- Read byte string value
skipBytes
protected void skipBytes(int length)
throws DRDAProtocolException
- Skip byte string value
skipBytes
protected void skipBytes()
throws DRDAProtocolException
- Skip byte string value
skipDss
protected void skipDss()
throws DRDAProtocolException
- Skip remaining DSS
clearBuffer
protected void clearBuffer()
throws DRDAProtocolException
convertBytes
protected java.lang.String convertBytes(byte[] buf)
- Convert EBCDIC byte array to unicode string
adjustLengths
private void adjustLengths(int length)
- Adjust remaining length
readCmdString
protected java.lang.String readCmdString(int length) throws DRDAProtocolException, java.io.UnsupportedEncodingException
- Read string value
readCmdString
protected java.lang.String readCmdString() throws DRDAProtocolException, java.io.UnsupportedEncodingException
- Read string value
ensureALayerDataInBuffer
private void ensureALayerDataInBuffer(int desiredDataSize)
throws DRDAProtocolException
- Make sure a certain amount of Layer A data is in the buffer.
The data will be in the buffer after this method is called.
ensureBLayerDataInBuffer
private void ensureBLayerDataInBuffer(int desiredDataSize,
boolean adjustLen)
throws DRDAProtocolException
- Make sure a certain amount of Layer B data is in the buffer.
The data will be in the buffer after this method is called.
compressBLayerData
private void compressBLayerData(int continueDssHeaderCount)
throws DRDAProtocolException
- Compress B Layer data if extended total length is used
by removing the continuation headers
shiftBuffer
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).
State information is updated as needed after the shift.
ensureSpaceInBufferForFill
private void ensureSpaceInBufferForFill(int desiredSpace)
- This method makes sure there is enough room in the buffer
for a certain number of bytes. This method will allocate
a new buffer if needed and shift the bytes in the current buffer
to make ensure space is available for a fill. Right now
this method will shift bytes as needed to make sure there is
as much room as possible in the buffer before trying to
do the read. The idea is to try to have space to get as much data as possible
if we need to do a read on the socket's stream.
fill
private void fill(int minimumBytesNeeded)
throws DRDAProtocolException
- This method will attempt to read a minimum number of bytes
from the underlying stream. This method will keep trying to
read bytes until it has obtained at least the minimum number.
trace
private void trace(java.lang.String msg)
- Print a internal trace message
toDebugString
protected java.lang.String toDebugString(java.lang.String indent)
getCurrChainState
protected byte getCurrChainState()
- Return chaining bit for current DSS.
|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> [ drda overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.derby.impl.drda.DDMReader