com.neeve.sma
Class MessageMetadata

java.lang.Object
  extended by com.neeve.util.UtlListElement
      extended by com.neeve.sma.MessageMetadata
All Implemented Interfaces:
UtlPool.Item<MessageMetadata>

public final class MessageMetadata
extends UtlListElement
implements UtlPool.Item<MessageMetadata>

Helper class to transport message metadata.

This class serves as helper class for provider implementations that do not possess native capabilities to transport message metadata elements (sender, flow, sno, ...) natively. The class provides facilities to serialize and deserialize metadata elements to/from a flat wire format for use by the provider implementations to transport the metadata elements across the wire.


Field Summary
static int FIXED_WIRE_LENGTH
           
static int FIXED_WIRE_LENGTH_V1
           
static int FIXED_WIRE_LENGTH_V2
           
static byte V1
           
static byte V2
           
static byte VERSION
           
 
Fields inherited from class com.neeve.util.UtlListElement
count, head, next, prev
 
Method Summary
 MessageMetadata acquire()
          Acquires the MessageMetadata preventing it from being returned to the underlying pool.
 int deserialize(ByteBuffer serializedMetadata)
          Deserialize contents from a byte buffer
 void dispose()
          Dispose off this MessageMetadata
 PktBuffer getBuffer()
          Get the backing buffer The metadata object manipulates its field in place in its backing buffer returned by this method.
static short getLatestVersion()
          Get the latest metadata version.
 short getMessageChannelId()
          Get the message channel id (V1 metadata Field).
static short getMessageChannelId(ByteBuffer buffer)
          Get the message channel id (V1 metadata Field) from a serialized buffer.
 String getMessageChannelName()
          Get the message channel name (V1 metadata Field).
static String getMessageChannelName(ByteBuffer buffer)
          Get the message channel name (V1 metadata Field) from a serialized buffer.
 XString getMessageChannelNameAsRaw()
          Get the message channel name (V1 metadata Field).
static void getMessageChannelNameToRaw(ByteBuffer buffer, XString target)
          Get the message channel name (V1 metadata Field) from a serialized buffer.
 byte getMessageEncodingType()
          Get the message encoding type (V1 metadata Field).
static byte getMessageEncodingType(ByteBuffer buffer)
          Get the message encoding type (V1 metadata Field) from a serialized buffer.
 int getMessageFlow()
          Get the message flow (V1 metadata Field).
static int getMessageFlow(ByteBuffer buffer)
          Get the message flow (V1 metadata Field) from a serialized buffer.
 int getMessageSender()
          Get the message sender (V1 metadata Field).
static int getMessageSender(ByteBuffer buffer)
          Get the message sender (V1 metadata Field) from a serialized buffer
 long getMessageSno()
          Get the message sequence number (V1 metadata Field).
static long getMessageSno(ByteBuffer buffer)
          Get the message sequence number (V1 metadata Field) from a serialized buffer.
 short getMessageViewFactory()
          Get the message view factory (V1 metadata Field).
static short getMessageViewFactory(ByteBuffer buffer)
          Get the message view factory (V1 metadata Field) from a serialized buffer.
 short getMessageViewType()
          Get the message view (V2 metadata Field).
static short getMessageViewType(ByteBuffer buffer)
          Get the message view (V2 metadata Field) from a serialized buffer.
 UtlPool<MessageMetadata> getPool()
          Implementation of UtlPool.Item#getPool
 int getSerializedLength()
          Get the serialized length of the message metadata elements.
 short getVersion()
          Get the metadata version (V1 metadata Field).
 MessageMetadata init()
          Implementation of UtlPool.Item#init
 void serializeV1(byte encodingType, short vfid, int sender, int flow, long sno, short channelId, XString channelName)
          Serialize version 1 metadata content
 void serializeV2(byte encodingType, short vfid, short vid, int sender, int flow, long sno, short channelId, XString channelName)
          Serialize version 2 metadata content
 MessageMetadata setPool(UtlPool<MessageMetadata> pool)
          Implementation of UtlPool.Item#setPool
 String toString()
          Return a string representation of the object.
 int wrap(com.neeve.io.IOBuffer serializedMetadata)
          Wrap a metadata object around an IO buffer.
 
Methods inherited from class com.neeve.util.UtlListElement
count, insertAfter, insertBefore, isLinked, next, previous, unlink, wipe
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIXED_WIRE_LENGTH_V1

public static final int FIXED_WIRE_LENGTH_V1
See Also:
Constant Field Values

FIXED_WIRE_LENGTH_V2

public static final int FIXED_WIRE_LENGTH_V2
See Also:
Constant Field Values

FIXED_WIRE_LENGTH

public static final int FIXED_WIRE_LENGTH
See Also:
Constant Field Values

V1

public static final byte V1
See Also:
Constant Field Values

V2

public static final byte V2
See Also:
Constant Field Values

VERSION

public static final byte VERSION
See Also:
Constant Field Values
Method Detail

getLatestVersion

public static final short getLatestVersion()
Get the latest metadata version.


getVersion

public final short getVersion()
Get the metadata version (V1 metadata Field).


getMessageEncodingType

public static final byte getMessageEncodingType(ByteBuffer buffer)
Get the message encoding type (V1 metadata Field) from a serialized buffer.


getMessageEncodingType

public final byte getMessageEncodingType()
Get the message encoding type (V1 metadata Field).


getMessageViewFactory

public static final short getMessageViewFactory(ByteBuffer buffer)
Get the message view factory (V1 metadata Field) from a serialized buffer.


getMessageViewFactory

public final short getMessageViewFactory()
Get the message view factory (V1 metadata Field).


getMessageViewType

public static final short getMessageViewType(ByteBuffer buffer)
Get the message view (V2 metadata Field) from a serialized buffer.


getMessageViewType

public final short getMessageViewType()
Get the message view (V2 metadata Field).


getMessageSender

public static final int getMessageSender(ByteBuffer buffer)
Get the message sender (V1 metadata Field) from a serialized buffer


getMessageSender

public final int getMessageSender()
Get the message sender (V1 metadata Field).


getMessageFlow

public static final int getMessageFlow(ByteBuffer buffer)
Get the message flow (V1 metadata Field) from a serialized buffer.


getMessageFlow

public final int getMessageFlow()
Get the message flow (V1 metadata Field).


getMessageSno

public static final long getMessageSno(ByteBuffer buffer)
Get the message sequence number (V1 metadata Field) from a serialized buffer.


getMessageSno

public final long getMessageSno()
Get the message sequence number (V1 metadata Field).


getMessageChannelId

public static final short getMessageChannelId(ByteBuffer buffer)
Get the message channel id (V1 metadata Field) from a serialized buffer.


getMessageChannelId

public final short getMessageChannelId()
Get the message channel id (V1 metadata Field).


getMessageChannelName

public static final String getMessageChannelName(ByteBuffer buffer)
Get the message channel name (V1 metadata Field) from a serialized buffer.


getMessageChannelNameToRaw

public static final void getMessageChannelNameToRaw(ByteBuffer buffer,
                                                    XString target)
Get the message channel name (V1 metadata Field) from a serialized buffer.


getMessageChannelNameAsRaw

public final XString getMessageChannelNameAsRaw()
Get the message channel name (V1 metadata Field).


getMessageChannelName

public final String getMessageChannelName()
Get the message channel name (V1 metadata Field).


getBuffer

public final PktBuffer getBuffer()
Get the backing buffer

The metadata object manipulates its field in place in its backing buffer returned by this method. The caller can call this method to get the buffer with the latest copy of its contents at any time during the lifecycle of the metadata object.


serializeV1

public final void serializeV1(byte encodingType,
                              short vfid,
                              int sender,
                              int flow,
                              long sno,
                              short channelId,
                              XString channelName)
Serialize version 1 metadata content


serializeV2

public final void serializeV2(byte encodingType,
                              short vfid,
                              short vid,
                              int sender,
                              int flow,
                              long sno,
                              short channelId,
                              XString channelName)
Serialize version 2 metadata content


wrap

public final int wrap(com.neeve.io.IOBuffer serializedMetadata)
               throws SmaException
Wrap a metadata object around an IO buffer.

Parameters:
serializedMetadata - Contains the serialized form of the metadata

This method wraps a message metadata object around a supplied IO buffer. The method assumes that the serialized form of the metadata starts at the beginning of the IO buffer and the number of valid bytes in the buffer is equal to the length of the IO buffer.

Throws:
SmaException

deserialize

public final int deserialize(ByteBuffer serializedMetadata)
                      throws SmaException
Deserialize contents from a byte buffer

Throws:
SmaException

getSerializedLength

public final int getSerializedLength()
Get the serialized length of the message metadata elements.

This method returns the serialized length of the message metadata elements. This length is governed by the metadata wire format version. /P>


acquire

public final MessageMetadata acquire()
Acquires the MessageMetadata preventing it from being returned to the underlying pool.

Returns:
This MessageMetadata for invocation chaining.

dispose

public final void dispose()
Dispose off this MessageMetadata


init

public final MessageMetadata init()
Implementation of UtlPool.Item#init

Specified by:
init in interface UtlPool.Item<MessageMetadata>
Returns:
Return 'this' object for method invocation chaining.

setPool

public final MessageMetadata setPool(UtlPool<MessageMetadata> pool)
Implementation of UtlPool.Item#setPool

Specified by:
setPool in interface UtlPool.Item<MessageMetadata>
Returns:
Return 'this' object for method invocation chaining.

getPool

public final UtlPool<MessageMetadata> getPool()
Implementation of UtlPool.Item#getPool

Specified by:
getPool in interface UtlPool.Item<MessageMetadata>
Returns:
the pool set using UtlPool.Item.setPool(com.neeve.util.UtlPool)

toString

public final String toString()
Return a string representation of the object.

Overrides:
toString in class Object
Threading:
This method is safe for concurrent access by multiple threads


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.