Class DDMWriter

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

class DDMWriter extends 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

    Fields
    Modifier and Type
    Field
    Description
     
    private ByteBuffer
    Output buffer.
    private CcsidManager
     
    private int
     
    private static final int
     
    private int
     
    private DssTrace
     
     
    private final CharsetEncoder
    Encoder which encodes strings with the server's default encoding.
    private boolean
     
    private boolean
     
    private int
     
    private int[]
     
    private static final int
     
    (package private) static final int
    The maximum length in bytes for strings sent by writeLDString(), which is the maximum unsigned integer value that fits in two bytes.
    private int
     
    private int
     
    private byte
     
    private int
     
    private int
     
    (package private) long
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DDMWriter(DRDAConnThread agent, DssTrace dssTrace)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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
    Calculate extended length byte count which follows the DSS header for extended DDM.
    protected void
    Clear the entire send buffer
    protected void
    Erase all writes for the current ddm and reset the top
    protected void
    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
    Create DSS data object
    protected void
    Create DSS reply object
    protected void
    Create DSS request object NOTE: This is _ONLY_ used for testing the protocol (via the ProtocolTestAdapter.java file in this package)!
    protected boolean
     
    protected void
    End the current DDM
    protected void
    End final DDM and DSS header by writing the length in the length location
    protected void
    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, OutputStream socketOutputStream)
    Finalize the current DSS chain and send it if needed.
    private void
    Finish a DSS Layer A object.
    protected void
    Flush buffer to outputstream
    protected void
    flush(OutputStream socketOutputStream)
    Flush buffer to specified stream
    private void
    flushScalarStreamSegment(boolean lastSegment, OutputStream out)
     
    protected byte[]
    getBufferContents(int startPos)
    Get a copy of a subsequence of the output buffer, starting at the specified position and ending at the current buffer position.
    protected int
    Get the current position in the output buffer.
    private int
    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 CcsidManager
     
    protected int
    Get the length of the current DSS block we're working on.
    private static int
     
    private static boolean
    Check if a byte value represents a continuation byte in a UTF-8 byte sequence.
    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
    Takes note of the location of the most recently completed DSS in the buffer, and then returns the current offset.
    private int
    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
     
    private static OutputStream
     
    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
    Reset any chaining state that needs to be reset at time of the send
    private void
    sendBytes(OutputStream socketOutputStream)
     
    private void
    sendBytes(OutputStream socketOutputStream, boolean flashStream)
     
    protected void
    setBufferPosition(int position)
    Change the current position in the output buffer.
    protected void
    set protocol to CMD protocol
    protected void
     
    protected void
     
    protected void
    startDdm(int codePoint)
    Mark the location of the length bytes for the collection so they can be updated later
    protected void
    truncateDSS(int value)
    Truncate the current DSS.
    (package private) void
    writeBigDecimal(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
     
    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
    Write length delimited string
    protected void
    writeLDString(String s, int index, DRDAStatement stmt, boolean isParameter)
    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
    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
    (package private) void
    writeScalarPaddedString(int codePoint, 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(DRDAString drdaString, int paddedLength)
    Write padded scalar DRDAString object value.
    protected void
    writeScalarStream(boolean chainedWithSameCorrelator, int codePoint, EXTDTAInputStream in, boolean writeNullByte)
     
    (package private) void
    writeScalarString(int codePoint, 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
    Write string with default encoding
    protected void
    writeUDT(Object val, int index)
    Write a value of a user defined type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_MARKS_NESTING

      private static final int MAX_MARKS_NESTING
      See Also:
    • DEFAULT_BUFFER_SIZE

      private static final int DEFAULT_BUFFER_SIZE
      See Also:
    • MAX_VARCHAR_BYTE_LENGTH

      static final int MAX_VARCHAR_BYTE_LENGTH
      The maximum length in bytes for strings sent by writeLDString(), which is the maximum unsigned integer value that fits in two bytes.
      See Also:
    • buffer

      private ByteBuffer buffer
      Output buffer.
    • markStack

      private int[] markStack
    • top

      private int top
    • ebcdicCcsidManager

      private EbcdicCcsidManager ebcdicCcsidManager
    • utf8CcsidManager

      private Utf8CcsidManager utf8CcsidManager
    • 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 CharsetEncoder encoder
      Encoder which encodes strings with the server's default encoding.
    • totalByteCount

      volatile long totalByteCount
  • Constructor Details

  • Method Details

    • setUtf8Ccsid

      protected void setUtf8Ccsid()
    • setEbcdicCcsid

      protected void setEbcdicCcsid()
    • getCurrentCcsidManager

      protected CcsidManager getCurrentCcsidManager()
    • reset

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

      protected int getBufferPosition()
      Get the current position in the output buffer.
      Returns:
      current position
    • setBufferPosition

      protected void setBufferPosition(int position)
      Change the current position in the output buffer.
      Parameters:
      position - new position
    • getBufferContents

      protected byte[] getBufferContents(int startPos)
      Get a copy of a subsequence of the output buffer, starting at the specified position and ending at the current buffer position.
      Parameters:
      startPos - the position of the first byte to copy
      Returns:
      all bytes from startPos up to the current position
    • 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 ProtocolTestAdapter.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 ProtocolTestAdpater.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)
    • 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, 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, 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, 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(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
    • 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(String s) throws DRDAProtocolException
      Write length delimited string
      Parameters:
      s - value to be written with integer
      Throws:
      DRDAProtocolException
    • writeUDT

      protected void writeUDT(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(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(String s, int index, DRDAStatement stmt, boolean isParameter) throws DRDAProtocolException
      Write length delimited string
      Parameters:
      s - value to be written with integer
      index - column index to put in warning
      stmt - the executing statement (null if not invoked as part of statement execution)
      isParameter - true if the value written is for an output parameter in a procedure call
      Throws:
      DRDAProtocolException
    • isContinuationByte

      private static boolean isContinuationByte(byte b)
      Check if a byte value represents a continuation byte in a UTF-8 byte sequence. Continuation bytes in UTF-8 always match the bit pattern 10xxxxxx.
      Parameters:
      b - the byte to check
      Returns:
      true if b is a continuation byte, or false if it is the first byte in a UTF-8 sequence
    • writeString

      protected void writeString(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 IOException
      Flush buffer to outputstream
      Throws:
      IOException
    • flush

      protected void flush(OutputStream socketOutputStream) throws IOException
      Flush buffer to specified stream
      Parameters:
      socketOutputStream -
      Throws:
      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(BigDecimal b, int precision, int scale) throws 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:
      SQLException - Thrown if # digits > 31
    • sendBytes

      private void sendBytes(OutputStream socketOutputStream) throws IOException
      Throws:
      IOException
    • sendBytes

      private void sendBytes(OutputStream socketOutputStream, boolean flashStream) throws IOException
      Throws:
      IOException
    • 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, 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(InputStream in) throws IOException
      Throws:
      IOException
    • getLayerBStreamingBufferSize

      private static int getLayerBStreamingBufferSize()
    • placeLayerBStreamingBuffer

      private static OutputStream placeLayerBStreamingBuffer(OutputStream original)