|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.util.UtlListElement
com.neeve.pkt.PktSerializable
com.neeve.pkt.PktBody
public abstract class PktBody
Base class for all packet bodies.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.neeve.pkt.PktSerializable |
---|
PktSerializable.DeserializeContext, PktSerializable.SerializeContext |
Field Summary |
---|
Fields inherited from class com.neeve.util.UtlListElement |
---|
count, head, next, prev |
Method Summary | |
---|---|
void |
deserialize(byte[] array,
int arrayOffset,
int length)
Deserialize a packet body from a byte array |
void |
deserialize(ByteBuffer buf,
int length)
Deserialize a packet body from a byte buffer |
void |
deserialize(ByteBuffer buf,
int bufOffset,
int length)
Deserialize a packet body from a byte buffer |
void |
deserialize(com.neeve.io.IOBuffer iobuf,
int iobufOffset,
int length,
boolean wrap)
Deserialize a packet body from an IO buffer |
void |
deserialize(com.neeve.io.IOElasticBuffer iobuf,
int iobufOffset,
int length)
Deserialize a packet body from an elastic IO buffer |
void |
deserialize(long address,
int addressOffset,
int length)
Deserialize a packet body from a native memory region |
void |
deserialize(PktSerializable.DeserializeContext context,
int length,
Tracer tracer)
Implementation of PktSerializable.deserialize(com.neeve.pkt.PktSerializable.DeserializeContext, int, com.neeve.trace.Tracer) |
String |
dump(String prefix)
Dump the contents of a packet body |
PktBuffer |
getBuffer()
Get the backing buffer |
int |
getInitialBufferLength()
Implementation of IOElasticBuffer.Sizer.getInitialBufferLength() |
int |
getSerializedLength()
Implementation of PktSerializable.getSerializedLength() |
int |
getType()
Get the body type |
void |
initializeBuffer()
Implementation of IOElasticBuffer.Initializer.initializeBuffer()
The default implementation of this method is no-op. |
boolean |
isNative()
Get if the body is backed by a native or heap buffer |
void |
reset()
Reset the body contents This method resets the contents of a packet body. |
int |
serialize(byte[] array,
int arrayOffset)
Serialize a packet body to a byte array |
int |
serialize(ByteBuffer buf)
Serialize a packet body to a byte buffer |
int |
serialize(ByteBuffer buf,
int bufOffset)
Serialize a packet body to a byte buffer |
int |
serialize(com.neeve.io.IOBuffer iobuf,
int iobufOffset)
Serialize a packet body to an IO buffer |
int |
serialize(com.neeve.io.IOElasticBuffer iobuf,
int iobufOffset)
Serialize a packet body to an elastic IO buffer |
int |
serialize(long address,
int addressOffset)
Serialize a packet body to a native memory region |
void |
serialize(PktSerializable.SerializeContext context,
Tracer tracer)
Implementation of PktSerializable.serialize(com.neeve.pkt.PktSerializable.SerializeContext, com.neeve.trace.Tracer)
This method serializes the packet body into the buffer list
in the specified serialization context. |
Methods inherited from class com.neeve.pkt.PktSerializable |
---|
deserialize, getDeserializationPolicy, getSerializationPolicy, isValidDeserializationPolicy, isValidSerializationPolicy, serialize, setDeserializationPolicy, setSerializationPolicy |
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, toString, wait, wait, wait |
Method Detail |
---|
public final int getType()
public final boolean isNative()
public final PktBuffer getBuffer()
public final void reset()
This method resets the contents of a packet body. Upon return from this method, the contents of the body are the same as a freshly created body of the same type.
This method retains its references (if any) to its enclosing packet and associated packet header.
This method is intended for use with object pools through which packet body objects can be recycled rather than created fresh every time.
public final int getSerializedLength()
PktSerializable.getSerializedLength()
getSerializedLength
in class PktSerializable
public final void serialize(PktSerializable.SerializeContext context, Tracer tracer) throws EPktSerializeException
PktSerializable.serialize(com.neeve.pkt.PktSerializable.SerializeContext, com.neeve.trace.Tracer)
This method serializes the packet body into the buffer list
in the specified serialization context. This method invokes
PktSerializable.resolveSerializationPolicy(int)
using the
policy in the specified context to resolve the serialization
policy to use. The default serialization policy set in this
entity is determined using the configuration information for
the type of the packet being serialized.
serialize
in class PktSerializable
context
- The context to be used by the serialization process. See
PktSerializable.SerializeContext
for more information.tracer
- Tracer used to output serialization related trace. Can be
null in which case no trace is output.
EPktSerializeException
- Thrown in case an error is encountered
during the serialization process.
This method serializes a serialiable entity into a byte array presented as a set of byte buffers. As input, this method accepts a serialization context that, among other fields, contains a list of buffers of type {link java.nio.ByteBuffer} into which the entity is to serialize itself. The serialization operation is policy driven and the policy determines whether the header is copied into space remaining in the provided buffers or whether the internal entity buffers are just appended to the provided buffer list. In case the decision is made to copy the serialized data into the provided buffers, the data is always copied into the last buffer in the list. In case the last buffer does not contain enough remaining space to accomodate all the serialized data, this method will allocate and append a new buffer that will be of the same type and capacity as the last buffer in the provided list. Read the documentation of the policy constants to understand which policies cause the header to be copied as opposed to appended (the policy constant names are also self descriptive)
public final int serialize(ByteBuffer buf)
buf
- The byte buffer to serialize to
This method serialized the contents of a packet body by copying the contents of the packet body's buffer to a byte buffer. This method copies the contents to the target buffer starting at the target buffer's position. This method does not change any of the markers of the target byte buffer.
Note:Since this method does not change any markers of the target buffer, the caller needs to ensure the buffer limit is set correctly to accommodate the body's contents. The caller can invokegetSerializedLength()
to get
the length of the body's contents and use that to set the target buffer's
limit before invoking this method.
public final int serialize(ByteBuffer buf, int bufOffset)
buf
- The byte buffer to serialize tobufOffset
- The offset into the buffer where the serialized contents
of the packet body needs to be serialized (copied)
This method serialized the contents of a packet body by copying the contents of the packet body's buffer to a byte buffer. This method copies the contents to the target buffer starting at the supplied buffer offset. This method does not change any of the markers of the target byte buffer.
Note:Since this method does not change any markers of the target buffer, the caller needs to ensure the buffer limit is set correctly to accommodate the body's contents. The caller can invokegetSerializedLength()
to get
the length of the body's contents and use that to set the target buffer's
limit before invoking this method.
public final int serialize(byte[] array, int arrayOffset)
array
- The byte array to serialize toarrayOffset
- The offset into the array where the serialized contents
of the packet body needs to be serialized (copied)
This method serialized the contents of a packet body by copying the contents of the packet body's buffer to a byte array.
public final int serialize(com.neeve.io.IOBuffer iobuf, int iobufOffset)
iobuf
- The IO buffer to serialize toiobufOffset
- The offset into the IO buffer where the serialized contents
of the packet body needs to be serialized (copied)
This method serialized the contents of a packet body by copying the contents of the packet body's buffer to an IO buffer.
public final int serialize(com.neeve.io.IOElasticBuffer iobuf, int iobufOffset)
iobuf
- The IO buffer to serialize toiobufOffset
- The offset into the IO buffer where the serialized contents
of the packet body needs to be serialized (copied)
This method serialized the contents of a packet body by copying the contents of the packet body's buffer to an elastic IO buffer.
public final int serialize(long address, int addressOffset)
address
- The address of the native memory region to serialize toaddressOffset
- The offset into the memory region where the serialized
contents of the packet body should be serialized to.
This method serialized the contents of a packet body by copying the contents of the packet body's buffer to a native memory region.
public final void deserialize(PktSerializable.DeserializeContext context, int length, Tracer tracer) throws EPktDeserializeException
PktSerializable.deserialize(com.neeve.pkt.PktSerializable.DeserializeContext, int, com.neeve.trace.Tracer)
deserialize
in class PktSerializable
context
- The context to be used by the deserialization process.
See PktSerializable.DeserializeContext
for more information.length
- This parameter is present for entities
whose serialized form does not contain the serialized length of the
entity. For such entities, the caller needs to pass in the serialized
length to the entity during deserialize time. For other entities, this
value will be ignored and should be set to -1 (some entities that
pull the length from the serialized form may indeed validate that
the passed in value is -1)tracer
- Tracer used to output deserialization related trace. Can be
null in which case no trace is output.
EPktDeserializeException
- Thrown in case an error is encountered
during the deserialization process.
This method initializes a serializable entity from a byte buffer. As
input, this method accepts a deserialization context that contains, in
addition to other fields, a ByteBuffer
from where
the entity is to be initialized. It is assumed that the caller has
validated (using some other means) that the buffer contains enough data
to initialize the entity. Upon successful return, the context is
updated with information relating to the deserialization e.g. how
many bytes were consumed from the buffer to initialize the entity
and whether a reference to the buffer is being retained by the entity
subsequent to returning from this method. Refer to the context
documentation for detailed information on how and when the fields
are updated.
Before returning from this method, the implementation must replace the buffer in the context with a sliced version of the provided buffer so that the next entity in the deserialization chain can operate out of the buffer provided to it using absolute indices i.e. relative to the beginning of the buffer rather than relative to the current buffer position.
public final void deserialize(ByteBuffer buf, int length)
buf
- The byte buffer to deserialize fromlength
- The length of the body's serialized contents
This method deserializes the contents of a packet body by copying contents from a byte buffer to the packet body's buffer. This method copies the content starting from the source buffer's position to its limit. It does not change any of the markers of the source byte buffer
public final void deserialize(ByteBuffer buf, int bufOffset, int length)
buf
- The byte buffer to deserialize frombufOffset
- The offset into the buffer where the serialized contents
of the packet body begins.length
- The length of the body's serialized contents
This method deserializes the contents of a packet body by copying contents from a byte buffer to the packet body's buffer. This method copies the content starting from the supplied offset. It does not change any of the markers of the source byte buffer
public final void deserialize(byte[] array, int arrayOffset, int length) throws EPktDeserializeException
array
- The byte array to deserialize fromarrayOffset
- The offset into the array where the serialized contents
of the packet body begins.length
- The length of the body's serialized contents
This method deserializes the contents of a packet body by copying contents from a byte array to the packet body's buffer.
EPktDeserializeException
public final void deserialize(com.neeve.io.IOBuffer iobuf, int iobufOffset, int length, boolean wrap) throws EPktDeserializeException
iobuf
- The IO buffer to deserialize fromiobufOffset
- The offset into the IO buffer where the serialized contents
of the packet body begins.length
- The length of the body's serialized contentswrap
- Indicates whether the deserialization process should copy the
contents of the IO buffer to the packet body or wrap the packet body's
buffer around the supplied IO buffer
This method deserializes the contents of a packet body by wrapping or copying contents of an IO buffer to the packet body's buffer.
EPktDeserializeException
public final void deserialize(com.neeve.io.IOElasticBuffer iobuf, int iobufOffset, int length) throws EPktDeserializeException
iobuf
- The IO buffer to deserialize fromiobufOffset
- The offset into the IO buffer where the serialized
contents of the packet body begins.length
- The length of the body's serialized contents
This method deserializes the contents of a packet body by copying contents from an elastic IO buffer to the packet body's buffer.
EPktDeserializeException
public final void deserialize(long address, int addressOffset, int length) throws EPktDeserializeException
address
- The address of the native memory region to deserialize fromaddressOffset
- The offset into the memory region where the serialized
contents of the packet body begins.length
- The length of the body's serialized contents
This method deserializes the contents of a packet body by copying contents from a native (off heap) memory region to the packet body's buffer.
EPktDeserializeException
public final String dump(String prefix)
public final int getInitialBufferLength()
IOElasticBuffer.Sizer.getInitialBufferLength()
getInitialBufferLength
in interface com.neeve.io.IOElasticBuffer.Sizer
doGetInitialBufferLength()
if not instantiated from
fork.public void initializeBuffer()
IOElasticBuffer.Initializer.initializeBuffer()
The default implementation of this method is no-op. The concrete body implementation should override and implement this method if it needs to do buffer initialization.
initializeBuffer
in interface com.neeve.io.IOElasticBuffer.Initializer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |