org.apache.derby.impl.drda
Class DDMWriter

java.lang.Object
  extended by org.apache.derby.impl.drda.DDMWriter

 class DDMWriter
extends java.lang.Object

The DDMWriter is used to write DRDA protocol. The DRDA Protocol is described in the DDMReader class. For more details, see DRDA Volume 3 (Distributed Data Management(DDM) Architecture (DDS definition)


Field Summary
private  DRDAConnThread agent
           
private  java.nio.ByteBuffer buffer
          Output buffer.
private  CcsidManager ccsidManager
           
private  int correlationID
           
private static int DEFAULT_BUFFER_SIZE
           
private  int dssLengthLocation
           
private  DssTrace dssTrace
           
private  java.nio.charset.CharsetEncoder encoder
          Encoder which encodes strings with the server's default encoding.
private  boolean isContinuationDss
           
private  boolean isDRDAProtocol
           
private  int lastDSSBeforeMark
           
private  int[] markStack
           
private static int MAX_MARKS_NESTING
           
private  int nextCorrelationID
           
private  int prevHdrLocation
           
private  byte previousChainByte
           
private  int previousCorrId
           
private  int top
           
(package private)  long totalByteCount
           
 
Constructor Summary
DDMWriter(CcsidManager ccsidManager, DRDAConnThread agent, DssTrace dssTrace)
           
 
Method Summary
private  void beginDss(boolean chainedToNextStructure, int dssType)
          Begins a DSS stream (for writing LOB data).
private  void beginDss(int dssType, boolean ensureLen)
          Write 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
private  int calculateExtendedLengthByteCount(long ddmSize)
          Calculate extended length byte count which follows the DSS header for extended DDM.
protected  void clearBuffer()
          Clear the entire send buffer
protected  void clearDdm()
          Erase all writes for the current ddm and reset the top
protected  void clearDSSesBackToMark(int mark)
          Does a logical "clear" of everything written to the buffer after the received mark.
protected  byte[] copyDSSDataToEnd(int start)
          Copy Data to End Create a buffer and copy from the position given to the end of data Note that the position given is treated as relative to the current DSS, for there may be other DSS blocks (chained, presumably) which are sitting unwritten in the buffer.
protected  void createDssObject()
          Create DSS data object
protected  void createDssReply()
          Create DSS reply object
protected  void createDssRequest()
          Create DSS request object NOTE: This is _ONLY_ used for testing the protocol (via the TestProto.java file in this package)!
protected  boolean doesRequestContainData()
           
protected  void endDdm()
          End the current DDM
protected  void endDdmAndDss()
          End final DDM and DSS header by writing the length in the length location
protected  void endDss()
          End DSS header by writing the length in the length location and setting the chain bit.
private  void endDss(boolean finalizeLength)
          End DSS header by writing the length in the length location and setting the chain bit.
protected  void endDss(byte chainByte)
          End DSS header by writing the length in the length location and setting the chain bit.
private  void ensureLength(int length)
          Ensure that there is space in the buffer
protected  void finalizeChain(byte currChainByte, java.io.OutputStream socketOutputStream)
          Finalize the current DSS chain and send it if needed.
private  void finalizeDssLength()
          Finish a DSS Layer A object.
protected  void flush()
          Flush buffer to outputstream
protected  void flush(java.io.OutputStream socketOutputStream)
          Flush buffer to specified stream
private  void flushScalarStreamSegment(boolean lastSegment, java.io.OutputStream out)
           
private  int getCorrelationID()
          Looks at chaining info for previous DSS written, and use that to figure out what the correlation id for the current DSS should be.
protected  int getDSSLength()
          Get the length of the current DSS block we're working on.
private static int getLayerBStreamingBufferSize()
           
private  void markDssAsContinued(boolean forLob)
          Mark the DSS that we're currently writing as a continued DSS, which is done by setting the high-order bit to "1", per DDM spec.
protected  int markDSSClearPoint()
          Takes note of the location of the most recently completed DSS in the buffer, and then returns the current offset.
private  int maxEncodedLength(java.lang.String s)
          Find the maximum number of bytes needed to represent the string in the default encoding.
private  void overrideChainByte(int pos, byte chainByte)
          Override the default chaining byte with the chaining byte that is passed in.
protected  void padBytes(byte val, int length)
          Write pad bytes using spaceChar
private static int peekStream(java.io.InputStream in)
           
private static java.io.OutputStream placeLayerBStreamingBuffer(java.io.OutputStream original)
           
private  int prepScalarStream(boolean chainedWithSameCorrelator, int codePoint, boolean writeNullByte)
          prepScalarStream does the following prep for writing stream data: 1.
protected  void reset(DssTrace dssTrace)
          reset values for sending next message
protected  void resetChainState()
          Reset any chaining state that needs to be reset at time of the send
private  void sendBytes(java.io.OutputStream socketOutputStream)
           
private  void sendBytes(java.io.OutputStream socketOutputStream, boolean flashStream)
           
protected  void setCMDProtocol()
          set protocol to CMD protocol
protected  void startDdm(int codePoint)
          Mark the location of the length bytes for the collection so they can be updated later
protected  void startDdm(int length, int codePoint)
          Write length and codepoint
protected  java.lang.String toDebugString(java.lang.String indent)
           
protected  void truncateDSS(int value)
          Truncate the current DSS.
(package private)  void writeBigDecimal(java.math.BigDecimal b, int precision, int scale)
          Write a Java java.math.BigDecimal to packed decimal bytes.
protected  void writeBoolean(boolean v)
          Write platform boolean
protected  void writeByte(int value)
          Write byte
protected  void writeBytes(byte[] buf)
          Write byte array
protected  void writeBytes(byte[] buf, int length)
          Write byte array
protected  void writeBytes(byte[] buf, int start, int length)
          Write byte array
(package private)  void writeCodePoint4Bytes(int codePoint, int value)
          Write code point and 4 bytes
protected  void writeDouble(double v)
          Write platform double
protected  void writeExtendedLength(long size)
           
protected  void writeFloat(float v)
          Write platform float
protected  void writeInt(int v)
          Write platform int
protected  void writeLDBytes(byte[] buf)
           
protected  void writeLDBytes(byte[] buf, int index)
           
protected  void writeLDString(java.lang.String s)
          Write length delimited string
protected  void writeLDString(java.lang.String s, int index)
          Write length delimited string
(package private)  void writeLengthCodePoint(int length, int codePoint)
           
protected  void writeLong(long v)
          Write platform long
protected  void writeNetworkInt(int value)
          Write network int
protected  void writeNetworkShort(int value)
          Write network short
(package private)  void writeScalar1Byte(int codePoint, int value)
          Write scalar 1 byte object includes length, codepoint and value
protected  void writeScalar2Bytes(int value)
           
protected  void writeScalar2Bytes(int codePoint, int value)
          Write scalar 2 byte object includes length, codepoint and value
protected  void writeScalarBytes(int codePoint, byte[] buf)
          Write scalar byte array object includes length, codepoint and value
protected  void writeScalarBytes(int codePoint, byte[] buf, int length)
          Write scalar byte array object includes length, codepoint and value
protected  void writeScalarBytes(int codePoint, byte[] buf, int start, int length)
          Write scalar byte array object includes length, codepoint and value
protected  void writeScalarHeader(int codePoint, int dataLength)
          Write scalar object header includes length and codepoint
protected  void writeScalarPaddedBytes(byte[] buf, int paddedLength, byte padByte)
          Write padded scalar byte array object value
protected  void writeScalarPaddedBytes(int codePoint, byte[] buf, int paddedLength, byte padByte)
          Write padded scalar byte array object includes length, codepoint and value
protected  void writeScalarPaddedString(DRDAString drdaString, int paddedLength)
          Write padded scalar DRDAString object value.
(package private)  void writeScalarPaddedString(int codePoint, java.lang.String string, int paddedLength)
          Write padded scalar string object includes length, codepoint and value the string is converted into the appropriate codeset (EBCDIC)
protected  void writeScalarPaddedString(java.lang.String string, int paddedLength)
          Write padded scalar string object value the string is converted into the appropriate codeset (EBCDIC)
protected  void writeScalarStream(boolean chainedWithSameCorrelator, int codePoint, EXTDTAInputStream in, boolean writeNullByte)
           
(package private)  void writeScalarString(int codePoint, java.lang.String string)
          Write scalar string object includes length, codepoint and value the string is converted into the appropriate codeset (EBCDIC)
protected  void writeShort(boolean b)
          Write boolean as short
protected  void writeShort(int v)
          Write platform short
protected  void writeString(java.lang.String s)
          Write string with default encoding
protected  void writeUDT(java.lang.Object val, int index)
          Write a value of a user defined type.
static java.lang.String zeroPadString(java.lang.String s, int precision)
          Prepend zeros to numeric string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_MARKS_NESTING

private static final int MAX_MARKS_NESTING
See Also:
Constant Field Values

DEFAULT_BUFFER_SIZE

private static final int DEFAULT_BUFFER_SIZE
See Also:
Constant Field Values

buffer

private java.nio.ByteBuffer buffer
Output buffer.


markStack

private int[] markStack

top

private int top

ccsidManager

private CcsidManager ccsidManager

agent

private DRDAConnThread agent

dssLengthLocation

private int dssLengthLocation

correlationID

private int correlationID

nextCorrelationID

private int nextCorrelationID

isDRDAProtocol

private boolean isDRDAProtocol

dssTrace

private DssTrace dssTrace

prevHdrLocation

private int prevHdrLocation

previousCorrId

private int previousCorrId

previousChainByte

private byte previousChainByte

isContinuationDss

private boolean isContinuationDss

lastDSSBeforeMark

private int lastDSSBeforeMark

encoder

private final java.nio.charset.CharsetEncoder encoder
Encoder which encodes strings with the server's default encoding.


totalByteCount

volatile long totalByteCount
Constructor Detail

DDMWriter

DDMWriter(CcsidManager ccsidManager,
          DRDAConnThread agent,
          DssTrace dssTrace)
Method Detail

reset

protected void reset(DssTrace dssTrace)
reset values for sending next message


setCMDProtocol

protected void setCMDProtocol()
set protocol to CMD protocol


createDssReply

protected void createDssReply()
Create DSS reply object


createDssRequest

protected void createDssRequest()
Create DSS request object NOTE: This is _ONLY_ used for testing the protocol (via the TestProto.java file in this package)! We should never create a DSS request in normal DRDA processing (we should only create DSS replies and DSS objects).


createDssObject

protected void createDssObject()
Create DSS data object


markDssAsContinued

private void markDssAsContinued(boolean forLob)
Mark the DSS that we're currently writing as a continued DSS, which is done by setting the high-order bit to "1", per DDM spec. This means: 1. One or more continuation DSSes will immediately follow the current (continued) DSS. 2. All continuation DSSes will have a 2-byte continuation header, followed by data; in other words, chaining state, correlation id, dss format info, and code point will NOT be included. All of that info is present ONLY in the FIRST DSS in the list of continued DSSes. NOTE: A DSS can be a "continuation" DSS _and_ a "continued" DSS at the same time. However, the FIRST DSS to be continued canNOT be a continuation DSS.


endDss

protected void endDss(byte chainByte)
End DSS header by writing the length in the length location and setting the chain bit. Unlike the other two endDss methods, this one overrides the default chaining byte (which is set in beginDss) with the chaining byte that is passed in. NOTE: This method is only used in association with createDssRequest, and thus is for TESTING purposes only (via TestProto.java). No calls should be made to this method in normal DRDA processing (because for normal processing, chaining must be determined automatically based on DSS requests).


overrideChainByte

private void overrideChainByte(int pos,
                               byte chainByte)
Override the default chaining byte with the chaining byte that is passed in.

Parameters:
pos - the position on which the chaining byte is located
chainByte - the chaining byte that overrides the default

endDss

protected void endDss()
End DSS header by writing the length in the length location and setting the chain bit.


endDss

private void endDss(boolean finalizeLength)
End DSS header by writing the length in the length location and setting the chain bit.


endDdmAndDss

protected void endDdmAndDss()
End final DDM and DSS header by writing the length in the length location


copyDSSDataToEnd

protected byte[] copyDSSDataToEnd(int start)
Copy Data to End Create a buffer and copy from the position given to the end of data Note that the position given is treated as relative to the current DSS, for there may be other DSS blocks (chained, presumably) which are sitting unwritten in the buffer. The caller doesn't know this, though, and works only with the current DSS. getDSSLength, copyDSSDataToEnd, and truncateDSS work together to provide a sub-protocol for DRDAConnThread to use in its implementation of the LMTBLKPRC protocol. They enable the caller to determine when it has written too much data into the current DSS, to reclaim the extra data that won't fit, and to truncate that extra data once it has been reclaimed and stored elsewhere. Note that this support only works for the current DSS. Earlier, chained DSS blocks cannot be accessed using these methods. For additional background information, the interested reader should investigate bugs DERBY-491 and 492 at: http://issues.apache.org/jira/browse/DERBY-491 and http://issues.apache.org/jira/browse/DERBY-492

Parameters:
start -

startDdm

protected void startDdm(int codePoint)
Mark the location of the length bytes for the collection so they can be updated later


clearDdm

protected void clearDdm()
Erase all writes for the current ddm and reset the top


clearBuffer

protected void clearBuffer()
Clear the entire send buffer


endDdm

protected void endDdm()
End the current DDM


getDSSLength

protected int getDSSLength()
Get the length of the current DSS block we're working on. This is used by the LMTBLKPRC protocol, which does its own conversational blocking protocol above the layer of the DRDA blocking. The LMTBLKPRC implementation (in DRDAConnThread) needs to be able to truncate a DSS block when splitting a QRYDTA response.

Returns:
current DSS block length

truncateDSS

protected void truncateDSS(int value)
Truncate the current DSS. Before making this call, you should ensure that you have copied the data to be truncated somewhere else, by calling copyDSSDataToEnd

Parameters:
value - DSS length

writeByte

protected void writeByte(int value)
Write byte

Parameters:
value - byte to be written

writeNetworkShort

protected void writeNetworkShort(int value)
Write network short

Parameters:
value - value to be written

writeNetworkInt

protected void writeNetworkInt(int value)
Write network int

Parameters:
value - value to be written

writeBytes

protected void writeBytes(byte[] buf,
                          int length)
Write byte array

Parameters:
buf - byte array to be written
length - - length to write

writeBytes

protected void writeBytes(byte[] buf,
                          int start,
                          int length)
Write byte array

Parameters:
buf - byte array to be written
start - - starting position
length - - length to write

writeBytes

protected void writeBytes(byte[] buf)
Write byte array

Parameters:
buf - byte array to be written

writeLDBytes

protected void writeLDBytes(byte[] buf)

writeLDBytes

protected void writeLDBytes(byte[] buf,
                            int index)

writeCodePoint4Bytes

void writeCodePoint4Bytes(int codePoint,
                          int value)
Write code point and 4 bytes

Parameters:
codePoint - - code point to write
value - - value to write after code point

writeScalar1Byte

void writeScalar1Byte(int codePoint,
                      int value)
Write scalar 1 byte object includes length, codepoint and value

Parameters:
codePoint - - code point to write
value - - value to write after code point

writeScalar2Bytes

protected void writeScalar2Bytes(int codePoint,
                                 int value)
Write scalar 2 byte object includes length, codepoint and value

Parameters:
codePoint - - code point to write
value - - value to write after code point

writeScalar2Bytes

protected void writeScalar2Bytes(int value)

startDdm

protected void startDdm(int length,
                        int codePoint)
Write length and codepoint

Parameters:
length - - length of object
codePoint - - code point to write

writeScalarBytes

protected void writeScalarBytes(int codePoint,
                                byte[] buf,
                                int length)
Write scalar byte array object includes length, codepoint and value

Parameters:
codePoint - - code point to write
buf - - value to write after code point
length - - number of bytes to write

writeScalarStream

protected void writeScalarStream(boolean chainedWithSameCorrelator,
                                 int codePoint,
                                 EXTDTAInputStream in,
                                 boolean writeNullByte)
                          throws DRDAProtocolException
Throws:
DRDAProtocolException

beginDss

private void beginDss(boolean chainedToNextStructure,
                      int dssType)
Begins a DSS stream (for writing LOB data).


prepScalarStream

private int prepScalarStream(boolean chainedWithSameCorrelator,
                             int codePoint,
                             boolean writeNullByte)
                      throws DRDAProtocolException
prepScalarStream does the following prep for writing stream data: 1. Flushes an existing DSS segment, if necessary 2. Determines if extended length bytes are needed 3. Creates a new DSS/DDM header and a null byte indicator, if applicable If value of length was less than 0, this method processes streaming as Layer B Streaming. cf. page 315 of specification of DRDA, Version 3, Volume 3

Throws:
DRDAProtocolException

doesRequestContainData

protected boolean doesRequestContainData()

flushScalarStreamSegment

private void flushScalarStreamSegment(boolean lastSegment,
                                      java.io.OutputStream out)
                               throws DRDAProtocolException
Throws:
DRDAProtocolException

writeLengthCodePoint

void writeLengthCodePoint(int length,
                          int codePoint)

writeScalarHeader

protected void writeScalarHeader(int codePoint,
                                 int dataLength)
Write scalar object header includes length and codepoint

Parameters:
codePoint - - code point to write
dataLength - - length of object data

writeScalarString

void writeScalarString(int codePoint,
                       java.lang.String string)
Write scalar string object includes length, codepoint and value the string is converted into the appropriate codeset (EBCDIC)

Parameters:
codePoint - - code point to write
string - - string to be written

writeScalarPaddedString

void writeScalarPaddedString(int codePoint,
                             java.lang.String string,
                             int paddedLength)
Write padded scalar string object includes length, codepoint and value the string is converted into the appropriate codeset (EBCDIC)

Parameters:
codePoint - - code point to write
string - - string to be written
paddedLength - - length to pad string to

writeScalarPaddedString

protected void writeScalarPaddedString(java.lang.String string,
                                       int paddedLength)
Write padded scalar string object value the string is converted into the appropriate codeset (EBCDIC)

Parameters:
string - - string to be written
paddedLength - - length to pad string to

writeScalarPaddedString

protected void writeScalarPaddedString(DRDAString drdaString,
                                       int paddedLength)
Write padded scalar DRDAString object value. The string is converted into the appropriate codeset.

Parameters:
drdaString - string to be written
paddedLength - length to pad string to

writeScalarPaddedBytes

protected void writeScalarPaddedBytes(int codePoint,
                                      byte[] buf,
                                      int paddedLength,
                                      byte padByte)
Write padded scalar byte array object includes length, codepoint and value

Parameters:
codePoint - - code point to write
buf - - byte array to be written
paddedLength - - length to pad string to
padByte - - byte to be used for padding

writeScalarPaddedBytes

protected void writeScalarPaddedBytes(byte[] buf,
                                      int paddedLength,
                                      byte padByte)
Write padded scalar byte array object value

Parameters:
buf - - byte array to be written
paddedLength - - length to pad string to
padByte - - byte to be used for padding

writeScalarBytes

protected void writeScalarBytes(int codePoint,
                                byte[] buf)
Write scalar byte array object includes length, codepoint and value

Parameters:
codePoint - - code point to write
buf - - byte array to be written

writeScalarBytes

protected void writeScalarBytes(int codePoint,
                                byte[] buf,
                                int start,
                                int length)
Write scalar byte array object includes length, codepoint and value

Parameters:
codePoint - - code point to write
buf - - byte array to be written
start - - starting point
length - - length to write

writeShort

protected void writeShort(int v)
Write platform short

Parameters:
v - value to be written

writeShort

protected void writeShort(boolean b)
Write boolean as short

Parameters:
b - boolean value true = 1 false = 0

writeInt

protected void writeInt(int v)
Write platform int

Parameters:
v - value to be written

writeLong

protected void writeLong(long v)
Write platform long

Parameters:
v - value to be written

writeFloat

protected void writeFloat(float v)
Write platform float

Parameters:
v - value to be written

writeDouble

protected void writeDouble(double v)
Write platform double

Parameters:
v - value to be written

writeBoolean

protected void writeBoolean(boolean v)
Write platform boolean

Parameters:
v - value to be written

writeLDString

protected void writeLDString(java.lang.String s)
                      throws DRDAProtocolException
Write length delimited string

Parameters:
s - value to be written with integer
Throws:
DRDAProtocolException

writeUDT

protected void writeUDT(java.lang.Object val,
                        int index)
                 throws DRDAProtocolException
Write a value of a user defined type.

Parameters:
val - object to be written
Throws:
DRDAProtocolException

maxEncodedLength

private int maxEncodedLength(java.lang.String s)
Find the maximum number of bytes needed to represent the string in the default encoding.

Parameters:
s - the string to encode
Returns:
an upper limit for the number of bytes needed to encode the string

writeLDString

protected void writeLDString(java.lang.String s,
                             int index)
                      throws DRDAProtocolException
Write length delimited string

Parameters:
s - value to be written with integer
index - column index to put in warning
Throws:
DRDAProtocolException

writeString

protected void writeString(java.lang.String s)
                    throws DRDAProtocolException
Write string with default encoding

Parameters:
s - value to be written
Throws:
DRDAProtocolException

padBytes

protected void padBytes(byte val,
                        int length)
Write pad bytes using spaceChar

Parameters:
val - value to be written
length - length to be written

flush

protected void flush()
              throws java.io.IOException
Flush buffer to outputstream

Throws:
java.io.IOException

flush

protected void flush(java.io.OutputStream socketOutputStream)
              throws java.io.IOException
Flush buffer to specified stream

Parameters:
socketOutputStream -
Throws:
java.io.IOException

beginDss

private void beginDss(int dssType,
                      boolean ensureLen)
Write 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


finalizeDssLength

private void finalizeDssLength()
Finish a DSS Layer A object. The length of dss object will be calculated based on the difference between the start of the dss, saved on the beginDss call, 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.


writeExtendedLength

protected void writeExtendedLength(long size)

calculateExtendedLengthByteCount

private int calculateExtendedLengthByteCount(long ddmSize)
Calculate extended length byte count which follows the DSS header for extended DDM.

Parameters:
ddmSize - - size of DDM command
Returns:
minimum number of extended length bytes needed. 0 indicates no extended length needed.

ensureLength

private void ensureLength(int length)
Ensure that there is space in the buffer

Parameters:
length - space required

writeBigDecimal

void writeBigDecimal(java.math.BigDecimal b,
                     int precision,
                     int scale)
               throws java.sql.SQLException
Write a Java java.math.BigDecimal to packed decimal bytes.

Parameters:
b - BigDecimal to write
precision - Precision of decimal or numeric type
scale - declared scale
Throws:
java.sql.SQLException - Thrown if # digits > 31

zeroPadString

public static java.lang.String zeroPadString(java.lang.String s,
                                             int precision)
Prepend zeros to numeric string

Parameters:
s - string
precision - - length of padded string
Returns:
zero padded string

sendBytes

private void sendBytes(java.io.OutputStream socketOutputStream)
                throws java.io.IOException
Throws:
java.io.IOException

sendBytes

private void sendBytes(java.io.OutputStream socketOutputStream,
                       boolean flashStream)
                throws java.io.IOException
Throws:
java.io.IOException

toDebugString

protected java.lang.String toDebugString(java.lang.String indent)

resetChainState

protected void resetChainState()
Reset any chaining state that needs to be reset at time of the send


getCorrelationID

private int getCorrelationID()
Looks at chaining info for previous DSS written, and use that to figure out what the correlation id for the current DSS should be. Return that correlation id.


finalizeChain

protected void finalizeChain(byte currChainByte,
                             java.io.OutputStream socketOutputStream)
                      throws DRDAProtocolException
Finalize the current DSS chain and send it if needed. Updates the chaining state of the most recently-written- to-buffer DSS to correspond to the most recently-read- from-client request. If that chaining state indicates we've reached the end of a chain, then we go ahead and send the buffer across the wire.

Parameters:
socketOutputStream - Output stream to which we're flushing.
Throws:
DRDAProtocolException

markDSSClearPoint

protected int markDSSClearPoint()
Takes note of the location of the most recently completed DSS in the buffer, and then returns the current offset. This method is used in conjunction with "clearDSSesBackToMark" to allow for DRDAConnThread to "back-out" DSSes in the event of errors.


clearDSSesBackToMark

protected void clearDSSesBackToMark(int mark)
Does a logical "clear" of everything written to the buffer after the received mark. It's assumed that this method will be used in error cases when we've started writing one or more DSSes, but then hit an error and need to back out. After backing out, we'll always need to write _something_ back to the client to indicate an error (typically, we just write an SQLCARD) but what exactly gets written is handled in DRDAConnThread. Here, we just do the necessary prep so that whatever comes next will succeed.


peekStream

private static int peekStream(java.io.InputStream in)
                       throws java.io.IOException
Throws:
java.io.IOException

getLayerBStreamingBufferSize

private static int getLayerBStreamingBufferSize()

placeLayerBStreamingBuffer

private static java.io.OutputStream placeLayerBStreamingBuffer(java.io.OutputStream original)

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.