Class SimpleMessageHandler

java.lang.Object
io.deephaven.sbe.standalone.client.SimpleMessageHandler
All Implemented Interfaces:
MessageHandler

public class SimpleMessageHandler
extends Object
implements MessageHandler
Simple message handler implementation that decodes incoming messages and does listener call-backs.

This example makes some effort to avoid excessive allocation by reusing buffers for incoming data but makes a compromise for convenience and still allocates for some immutable objects like Strings, BigDecimal, etc.

NOTE: this implementation is not thread safe. A unique instance must be passed to each concurrent TableClient.

  • Field Details

  • Constructor Details

  • Method Details

    • mapToChar

      protected char mapToChar​(Object v)
    • getInstant

      protected Instant getInstant​(long epochNanos)
    • addListener

      public void addListener​(SimpleMessageHandlerListener listener)
      Add a listener to handle incoming decoded messages from the table server.
      Parameters:
      listener - The listener
    • handleConnectionError

      public void handleConnectionError​(IOException ex)
      Handle a connection error by passing it on to any interested listeners.
      Specified by:
      handleConnectionError in interface MessageHandler
      Parameters:
      ex - The exception that resulted in this notification
    • decodeConnectionResponse

      public int decodeConnectionResponse​(ConnectionResponseDecoder connectionResponseDecoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode the connection response and allocate buffers according to the message buffer size indicated by the server.
      Specified by:
      decodeConnectionResponse in interface MessageHandler
      Parameters:
      connectionResponseDecoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
      Returns:
      message buffer size (decoded from the ConnectionResponse message)
    • decodeSubscribeResponse

      public void decodeSubscribeResponse​(TableSubscribeResponseDecoder subscribeResponseDecoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a SubscribeResponse message and pass along to interested listeners.
      Specified by:
      decodeSubscribeResponse in interface MessageHandler
      Parameters:
      subscribeResponseDecoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeUnsubscribeResponse

      public void decodeUnsubscribeResponse​(TableUnsubscribeResponseDecoder unsubscribeResponseDecoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode an UnsubscribeResponse message and pass along to interested listeners.
      Specified by:
      decodeUnsubscribeResponse in interface MessageHandler
      Parameters:
      unsubscribeResponseDecoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeSubscriptionError

      public void decodeSubscriptionError​(TableSubscriptionErrorDecoder subscriptionErrorDecoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a SubscriptionError message and pass along to any interested listeners.
      Specified by:
      decodeSubscriptionError in interface MessageHandler
      Parameters:
      subscriptionErrorDecoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeBeginTableUpdate

      public void decodeBeginTableUpdate​(BeginTableUpdateDecoder beginTableUpdateDecoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a BeginTableUpdate message and pass along to any interested listeners.
      Specified by:
      decodeBeginTableUpdate in interface MessageHandler
      Parameters:
      beginTableUpdateDecoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeEndTableUpdate

      public void decodeEndTableUpdate​(EndTableUpdateDecoder endTableUpdateDecoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode an EndTableUpdate message and pass along to any interested listeners.
      Specified by:
      decodeEndTableUpdate in interface MessageHandler
      Parameters:
      endTableUpdateDecoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeRowsRemoved

      public void decodeRowsRemoved​(RowsRemovedDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a RowsRemoved message and pass along to any interested listeners.
      Specified by:
      decodeRowsRemoved in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(ByteColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a ByteColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(BooleanColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a BooleanColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(CharColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a CharColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(DoubleColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a DoubleColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(FloatColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a FloatColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(LongColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a LongColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(DateTimeColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a DateTimeColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(IntColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode an IntColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(ShortColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a ShortColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(ByteArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a ByteArrayColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(BooleanArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a BooleanArrayColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(CharArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a CharArrayColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(DoubleArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a DoubleArrayColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(FloatArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a FloatArrayColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(IntArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode an IntArrayColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(LongArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a LongArrayColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(ShortArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a ShortArrayColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • notifyListeners

      protected void notifyListeners​(int subId, int colId, SimpleBool isModified, int nRows, int nData)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(DecimalColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a DecimalColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(StringColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a StringColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(StringArrayColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a StringArrayColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)
    • decodeColumnUpdate

      public void decodeColumnUpdate​(StringSetColumnDataDecoder decoder, org.agrona.concurrent.UnsafeBuffer directBuffer, int bufferOffset, int actingBlockLength, int actingVersion)
      Decode a StringSetColumnData message and pass along to any interested listeners.
      Specified by:
      decodeColumnUpdate in interface MessageHandler
      Parameters:
      decoder - Decoder which can be used to extract the message from the given buffer
      directBuffer - The underlying receive buffer
      bufferOffset - The offset in the given buffer at which to start decoding
      actingBlockLength - Block length from SBE header (pass to decoder wrap method)
      actingVersion - Version from SBE header (pass to decoder wrap method)