NetConnectionRequest
class Request
extends java.lang.Object
Modifier and Type | Field | Description |
---|---|---|
protected java.nio.ByteBuffer |
buffer |
|
private int |
correlationID_ |
|
private int |
dssLengthLocation_ |
|
private int[] |
markStack_ |
|
private static int |
MAX_MARKS_NESTING |
|
protected NetAgent |
netAgent_ |
|
protected boolean |
passwordIncluded_ |
|
protected int |
passwordLength_ |
|
protected int |
passwordStart_ |
|
private boolean |
simpleDssFinalize |
|
private int |
top_ |
Modifier and Type | Method | Description |
---|---|---|
private void |
buildDss(boolean dssHasSameCorrelator,
boolean chainedToNextStructure,
boolean nextHasSameCorrelator,
int dssType,
int corrId,
boolean simpleFinalizeBuildingNextDss) |
|
private void |
buildLengthAndCodePointForLob(int codePoint,
boolean writeNullByte) |
|
private void |
buildLengthAndCodePointForLob(int codePoint,
long leftToRead,
boolean writeNullByte,
int extendedLengthByteCount) |
|
(package private) void |
buildTripletHeader(int tripletLength,
int tripletType,
int tripletId) |
|
private int |
calculateExtendedLengthByteCount(long ddmSize) |
|
private void |
clearBuffer() |
|
protected void |
createCommand() |
|
(package private) void |
createCommandData() |
|
(package private) void |
createEncryptedCommandData() |
|
private boolean |
doesRequestContainData() |
|
private int |
encodeString(java.lang.String string) |
Encode a string and put it into the buffer.
|
private void |
ensureLength(int length) |
|
private void |
finalizeDssLength() |
Signal the completion of a DSS Layer A object.
|
private void |
finalizePreviousChainedDss(boolean dssHasSameCorrelator) |
|
protected void |
flush(java.io.OutputStream socketOutputStream) |
|
private void |
flushExistingDSS() |
|
private int |
flushScalarStreamSegment() |
|
private int |
flushScalarStreamSegment(long leftToRead,
int bytesToRead) |
|
(package private) void |
initialize() |
|
private void |
mark() |
|
protected void |
markForCachingPKGNAMCSN() |
|
protected void |
markLengthBytes(int codePoint) |
|
private void |
maskOutPassword() |
|
private void |
padBytes(byte padByte,
int length) |
|
private void |
padScalarStreamForError(long leftToRead,
int bytesToRead,
boolean writeStatus,
byte status) |
Pads a value with zeros until it has reached its defined length.
|
private static boolean |
peekStream(java.io.BufferedInputStream in) |
|
private int |
popMark() |
|
protected int |
popMarkForCachingPKGNAMCSN() |
|
private int |
prepScalarStream(boolean chained,
boolean chainedWithSameCorrelator,
boolean writeNullByte,
long leftToRead) |
|
private void |
sendBytes(java.io.OutputStream socketOutputStream) |
|
void |
setCorrelationID(int id) |
|
void |
setDssLengthLocation(int location) |
|
protected void |
updateLengthBytes() |
|
(package private) void |
write1Byte(int value) |
|
(package private) void |
write2Bytes(int value) |
|
(package private) void |
write4Bytes(long value) |
|
(package private) void |
writeBigDecimal(java.math.BigDecimal v,
int declaredPrecision,
int declaredScale) |
|
(package private) void |
writeBoolean(boolean v) |
|
private void |
writeByte(byte v) |
|
(package private) void |
writeBytes(byte[] buf) |
|
(package private) void |
writeBytes(byte[] buf,
int length) |
|
(package private) void |
writeCodePoint4Bytes(int codePoint,
int value) |
|
(package private) void |
writeDate(DateTimeValue date) |
|
protected void |
writeDouble(double v) |
|
private void |
writeEXTDTAStatus(byte flag) |
Writes the Derby-specific EXTDTA status flag to the send buffer.
|
private void |
writeExtendedLengthBytes(int extendedLengthByteCount,
long length) |
|
protected void |
writeFloat(float v) |
|
(package private) void |
writeInt(int v) |
|
protected void |
writeIntFdocaData(int v) |
|
(package private) void |
writeLDBytes(byte[] bytes) |
|
private void |
writeLDBytesX(int ldSize,
byte[] bytes) |
|
private void |
writeLDBytesXSubset(int ldSize,
int bytesToCopy,
byte[] bytes) |
|
(package private) void |
writeLengthCodePoint(int length,
int codePoint) |
|
private void |
writeLidAndLengths(int[][] lidAndLengthOverrides,
int count,
int offset) |
|
(package private) void |
writeLidAndLengths(int[][] lidAndLengthOverrides,
int count,
int offset,
boolean mddRequired,
java.util.Hashtable map) |
|
(package private) void |
writeLong(long v) |
|
(package private) void |
writeLong6Bytes(long v) |
Writes a long into the buffer, using six bytes.
|
protected void |
writeLongFdocaData(long v) |
|
private void |
writePlainScalarStream(boolean chained,
boolean chainedWithSameCorrelator,
int codePoint,
long length,
java.io.InputStream in,
boolean writeNullByte,
int parameterIndex) |
Writes a stream with a known length onto the wire.
|
private void |
writePlainScalarStream(boolean chained,
boolean chainedWithSameCorrelator,
int codePoint,
java.io.InputStream in,
boolean writeNullByte,
int parameterIndex) |
Writes a stream with unknown length onto the wire.
|
protected void |
writeScalar1Byte(int codePoint,
int value) |
|
(package private) void |
writeScalar2Bytes(int codePoint,
int value) |
|
protected void |
writeScalar4Bytes(int codePoint,
long value) |
|
(package private) void |
writeScalar8Bytes(int codePoint,
long value) |
|
(package private) void |
writeScalarBytes(int codePoint,
byte[] buff) |
|
(package private) void |
writeScalarBytes(int codePoint,
byte[] buff,
int start,
int length) |
|
(package private) void |
writeScalarPaddedBytes(byte[] buff,
int paddedLength,
byte padByte) |
|
(package private) void |
writeScalarStream(boolean chained,
boolean chainedWithSameCorrelator,
int codePoint,
int length,
java.io.Reader r,
boolean writeNullByte,
int parameterIndex) |
|
(package private) void |
writeScalarStream(boolean chained,
boolean chainedWithSameCorrelator,
int codePoint,
long length,
java.io.InputStream in,
boolean writeNullByte,
int parameterIndex) |
|
(package private) void |
writeScalarStream(boolean chained,
boolean chainedWithSameCorrelator,
int codePoint,
java.io.InputStream in,
boolean writeNullByte,
int parameterIndex) |
|
(package private) void |
writeScalarStream(boolean chained,
boolean chainedWithSameCorrelator,
int codePoint,
java.io.Reader r,
boolean writeNullByte,
int parameterIndex) |
|
(package private) void |
writeScalarString(int codePoint,
java.lang.String string) |
Write string with no minimum or maximum limit.
|
(package private) void |
writeScalarString(int codePoint,
java.lang.String string,
int byteMinLength,
int byteLengthLimit,
java.lang.String sqlState) |
insert a 4 byte length/codepoint pair plus ddm character data into
the buffer.
|
(package private) void |
writeShort(short v) |
|
protected void |
writeShortFdocaData(short v) |
|
(package private) void |
writeSingleorMixedCcsidLDString(java.lang.String s,
java.nio.charset.Charset encoding) |
|
(package private) void |
writeTime(DateTimeValue time) |
|
(package private) void |
writeTimestamp(DateTimeValue timestamp) |
|
(package private) void |
writeUDT(java.lang.Object val) |
protected java.nio.ByteBuffer buffer
private static final int MAX_MARKS_NESTING
private int[] markStack_
private int top_
private int dssLengthLocation_
private int correlationID_
private boolean simpleDssFinalize
protected boolean passwordIncluded_
protected int passwordStart_
protected int passwordLength_
protected NetAgent netAgent_
Request(NetAgent netAgent, int minSize)
private final void clearBuffer()
final void initialize()
private final void ensureLength(int length)
protected final void createCommand()
final void createCommandData()
final void createEncryptedCommandData()
private final void buildDss(boolean dssHasSameCorrelator, boolean chainedToNextStructure, boolean nextHasSameCorrelator, int dssType, int corrId, boolean simpleFinalizeBuildingNextDss)
final void writeScalarStream(boolean chained, boolean chainedWithSameCorrelator, int codePoint, java.io.InputStream in, boolean writeNullByte, int parameterIndex) throws DisconnectException, SqlException
DisconnectException
SqlException
final void writeScalarStream(boolean chained, boolean chainedWithSameCorrelator, int codePoint, long length, java.io.InputStream in, boolean writeNullByte, int parameterIndex) throws DisconnectException, SqlException
DisconnectException
SqlException
private final void writePlainScalarStream(boolean chained, boolean chainedWithSameCorrelator, int codePoint, long length, java.io.InputStream in, boolean writeNullByte, int parameterIndex) throws DisconnectException, SqlException
To avoid DRDA protocol exceptions, the data is truncated or padded as required to complete the transfer. This can be avoided by implementing the request abort mechanism specified by DRDA, but it is rather complex and may not be worth the trouble.
Also note that any exceptions generated while writing the stream will be accumulated and raised at a later time.
length
- the byte length of the streamin
- the stream to transferwriteNullByte
- whether or not to write a NULL indicatorparameterIndex
- one-based parameter indexDisconnectException
- if a severe error condition is encountered,
causing the connection to be brokenSqlException
private final void writePlainScalarStream(boolean chained, boolean chainedWithSameCorrelator, int codePoint, java.io.InputStream in, boolean writeNullByte, int parameterIndex) throws DisconnectException
To avoid DRDA protocol exceptions, the data is truncated or padded as required to complete the transfer. This can be avoided by implementing the request abort mechanism specified by DRDA, but it is rather complex and may not be worth the trouble.
Also note that any exceptions generated while writing the stream will be accumulated and raised at a later time.
Implementation note: This method does not support sending values with a specified length using layer B streaming and at the same time applying length checking. For large values layer B streaming may be more efficient than using layer A streaming.
in
- the stream to transferwriteNullByte
- whether or not to write a NULL indicatorparameterIndex
- one-based parameter indexDisconnectException
- if a severe error condition is encountered,
causing the connection to be brokenfinal void writeScalarStream(boolean chained, boolean chainedWithSameCorrelator, int codePoint, int length, java.io.Reader r, boolean writeNullByte, int parameterIndex) throws DisconnectException, SqlException
DisconnectException
SqlException
final void writeScalarStream(boolean chained, boolean chainedWithSameCorrelator, int codePoint, java.io.Reader r, boolean writeNullByte, int parameterIndex) throws DisconnectException, SqlException
DisconnectException
SqlException
private final int prepScalarStream(boolean chained, boolean chainedWithSameCorrelator, boolean writeNullByte, long leftToRead) throws DisconnectException
DisconnectException
private final void flushExistingDSS() throws DisconnectException
DisconnectException
private final int flushScalarStreamSegment(long leftToRead, int bytesToRead) throws DisconnectException
DisconnectException
private final int flushScalarStreamSegment() throws DisconnectException
DisconnectException
private final void padScalarStreamForError(long leftToRead, int bytesToRead, boolean writeStatus, byte status) throws DisconnectException
This functionality was introduced to handle the error situation where the actual length of the user stream is shorter than specified. To avoid DRDA protocol errors (or in this case a hang), we have to pad the data until the specified length has been reached. In a later increment the Derby-specific EXTDTA status flag was introduced to allow the client to inform the server that the value sent is invalid.
leftToRead
- total number of bytes left to readbytesToRead
- remaining bytes to read before flushingwriteStatus
- whether or not to wrote the Derby-specific trailing
EXTDTA status flag (see DRDAConstants)status
- the EXTDTA status (for this data value), ignored if
writeStatus
is false
DisconnectException
- if flushing the buffer failsprivate final void writeExtendedLengthBytes(int extendedLengthByteCount, long length)
private final void finalizePreviousChainedDss(boolean dssHasSameCorrelator)
private final boolean doesRequestContainData()
private final void finalizeDssLength()
The length of the DSS object will be calculated based on the difference
between the start of the DSS, saved in the variable
dssLengthLocation_
, and the current offset into the buffer which
marks the end of the data.
In the event the length requires the use of continuation DSS headers, one for each 32k chunk of data, the data will be shifted and the continuation headers will be inserted with the correct values as needed. Note: In the future, we may try to optimize this approach in an attempt to avoid these shifts.
protected final void markLengthBytes(int codePoint)
private final void mark()
private final int popMark()
protected final void markForCachingPKGNAMCSN()
protected final int popMarkForCachingPKGNAMCSN()
protected final void updateLengthBytes() throws SqlException
SqlException
private final int calculateExtendedLengthByteCount(long ddmSize)
private final void padBytes(byte padByte, int length)
final void write1Byte(int value)
final void buildTripletHeader(int tripletLength, int tripletType, int tripletId)
private void writeLidAndLengths(int[][] lidAndLengthOverrides, int count, int offset)
final void writeLidAndLengths(int[][] lidAndLengthOverrides, int count, int offset, boolean mddRequired, java.util.Hashtable map)
final void write2Bytes(int value)
final void write4Bytes(long value)
final void writeBytes(byte[] buf, int length)
final void writeBytes(byte[] buf)
final void writeCodePoint4Bytes(int codePoint, int value)
protected final void writeScalar1Byte(int codePoint, int value)
final void writeScalar2Bytes(int codePoint, int value)
protected final void writeScalar4Bytes(int codePoint, long value)
final void writeScalar8Bytes(int codePoint, long value)
final void writeLengthCodePoint(int length, int codePoint)
final void writeScalarString(int codePoint, java.lang.String string) throws SqlException
codePoint
- codepoint to writestring
- value to writeSqlException
final void writeScalarString(int codePoint, java.lang.String string, int byteMinLength, int byteLengthLimit, java.lang.String sqlState) throws SqlException
codePoint
- codepoint to writestring
- valuebyteMinLength
- minimum length. String will be padded with spaces
if value is too short. Assumes space character is one byte.byteLengthLimit
- Limit to string length. SQLException will be
thrown if we exceed this limit.sqlState
- SQLState to throw with string as param if byteLengthLimit
is exceeded.SqlException
- if string exceeds byteLengthLimitprivate int encodeString(java.lang.String string) throws SqlException
string
- the string to encodeSqlException
final void writeScalarBytes(int codePoint, byte[] buff)
final void writeScalarBytes(int codePoint, byte[] buff, int start, int length)
final void writeScalarPaddedBytes(byte[] buff, int paddedLength, byte padByte)
protected void flush(java.io.OutputStream socketOutputStream) throws java.io.IOException
java.io.IOException
private void sendBytes(java.io.OutputStream socketOutputStream) throws java.io.IOException
java.io.IOException
private final void maskOutPassword()
private void writeByte(byte v)
final void writeShort(short v)
void writeInt(int v)
final void writeLong6Bytes(long v)
v
- the value to writejava.lang.IllegalArgumentException
- if the long value is too large to be
represented by six bytes.final void writeLong(long v)
protected void writeShortFdocaData(short v)
protected void writeIntFdocaData(int v)
protected void writeLongFdocaData(long v)
protected void writeFloat(float v)
protected void writeDouble(double v)
final void writeBigDecimal(java.math.BigDecimal v, int declaredPrecision, int declaredScale) throws SqlException
SqlException
final void writeDate(DateTimeValue date) throws SqlException
SqlException
final void writeTime(DateTimeValue time)
final void writeTimestamp(DateTimeValue timestamp) throws SqlException
SqlException
final void writeBoolean(boolean v)
final void writeSingleorMixedCcsidLDString(java.lang.String s, java.nio.charset.Charset encoding) throws SqlException
SqlException
final void writeLDBytes(byte[] bytes)
private final void writeLDBytesX(int ldSize, byte[] bytes)
private final void writeLDBytesXSubset(int ldSize, int bytesToCopy, byte[] bytes)
final void writeUDT(java.lang.Object val) throws SqlException
SqlException
private void buildLengthAndCodePointForLob(int codePoint, long leftToRead, boolean writeNullByte, int extendedLengthByteCount) throws DisconnectException
DisconnectException
private void buildLengthAndCodePointForLob(int codePoint, boolean writeNullByte) throws DisconnectException
DisconnectException
private void writeEXTDTAStatus(byte flag) throws DisconnectException
The existing buffer is flushed to make space for the flag if required.
flag
- the Derby-specific EXTDTA status flagDisconnectException
- if flushing the buffer failspublic void setDssLengthLocation(int location)
public void setCorrelationID(int id)
private static boolean peekStream(java.io.BufferedInputStream in) throws java.io.IOException
java.io.IOException
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.