com.neeve.pkt
Class PktSubheaderRR

java.lang.Object
  extended by com.neeve.util.UtlListElement
      extended by com.neeve.pkt.PktSerializable
          extended by com.neeve.pkt.PktBody
              extended by com.neeve.pkt.PktSubheader
                  extended by com.neeve.pkt.PktSubheaderFixed
                      extended by com.neeve.pkt.PktSubheaderRR
All Implemented Interfaces:
com.neeve.io.IOElasticBuffer.Initializer, com.neeve.io.IOElasticBuffer.Sizer

public final class PktSubheaderRR
extends PktSubheaderFixed

The RR (Request-Response) packet subheader.

This class is the subheader used to indicate that a packet is part of a request-reply exchange and whether it is the request or reply in that exchange. It also carries information to correlate the request to the reply and request processing information.

Threading:
Packet subheaders are not safe for concurrent access by multiple threads.

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.pkt.PktSubheader
PREAMBLE_LENGTH, PREAMBLE_LENGTH_V1, V1, VERSION
 
Fields inherited from class com.neeve.util.UtlListElement
count, head, next, prev
 
Method Summary
static PktBody create()
          Creates a default RR subheader
static PktBody create(Properties props)
          Creates an RR subheader
 boolean equals(Object obj)
          Indicates whether some other object is equal to this one.
 long getCorrelationId()
          Get the correlation id
 int getReplyCount()
          Get the reply count from a success reply.
 long getReplyErrorCode()
          Get the error code from a reply indicating a failure.
 int getReplyNum()
          Get the reply number from a success reply.
 long getRequestCode()
          Get the request code.
 int hashCode()
          Returns the hashcode for this object
 boolean isReply()
          Get if packet is a reply.
 boolean isReplySuccess()
          Get whether the reply indicates a failure or success.
 boolean isRequest()
          Get if packet is a request.
static boolean prepareReply(PktPacket request, PktPacket reply, int replyCount, int replyNum)
          Prepare a packet as a success reply to a request.
static boolean prepareReply(PktPacket request, PktPacket reply, long errorCode)
          Prepare a packet as a failure reply to a request.
 void setCorrelationId(long corrid)
          Set the correlation id.
 void setReplyWithCountAndNum(int replyCount, int replyNum)
          Set packet as a reply of a single/multi reply request.
 void setReplyWithError(long errorCode)
          Set packet as a reply indicating failure.
 void setRequest(long requestCode)
          Set packet as a request.
 String toString()
          Returns a string representation of the object
 
Methods inherited from class com.neeve.pkt.PktSubheaderFixed
doGetSerializedLength, getSerializedLength
 
Methods inherited from class com.neeve.pkt.PktSubheader
getType
 
Methods inherited from class com.neeve.pkt.PktBody
deserialize, deserialize, deserialize, deserialize, deserialize, deserialize, deserialize, dump, getBuffer, getInitialBufferLength, getSerializedLength, getType, initializeBuffer, isNative, reset, serialize, serialize, serialize, serialize, serialize, serialize, serialize
 
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
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static PktBody create(Properties props)
Creates an RR subheader

Parameters:
props - The property set to use to qualify creation of the body.

create

public static PktBody create()
Creates a default RR subheader


prepareReply

public static boolean prepareReply(PktPacket request,
                                   PktPacket reply,
                                   int replyCount,
                                   int replyNum)
Prepare a packet as a success reply to a request.

Parameters:
request - The request packet for which to prepare the reply.
reply - The reply packet to prepare. The reply can be the same as the request.
replyCount - The total number of replies for the request.
replyNum - The reply number that this reply is.
Returns:
Returns true in case the reply was successfully prepared. Returns false in case the request packet did not have a a request reply subheader in it.
Threading:
This method is not safe for concurrent access by multiple threads on the same request and reply.

prepareReply

public static boolean prepareReply(PktPacket request,
                                   PktPacket reply,
                                   long errorCode)
Prepare a packet as a failure reply to a request.

Parameters:
request - The request packet for which to prepare the reply.
reply - The reply packet to prepare. The reply can be the same as the request.
errorCode - The reply error code.
Returns:
Returns true in case the reply was successfully prepared. Returns false in case the request packet did not have a a request reply subheader in it.
Threading:
This method is not safe for concurrent access by multiple threads on the same request and reply.

setCorrelationId

public final void setCorrelationId(long corrid)
Set the correlation id.

Threading:
This method is not safe for concurrent access by multiple threads.

getCorrelationId

public final long getCorrelationId()
Get the correlation id

Threading:
This method is not safe for concurrent access by multiple threads.

setRequest

public final void setRequest(long requestCode)
Set packet as a request.

Threading:
This method is not safe for concurrent access by multiple threads.

isRequest

public final boolean isRequest()
Get if packet is a request.

Threading:
This method is not safe for concurrent access by multiple threads.

getRequestCode

public final long getRequestCode()
Get the request code.

Throws:
IllegalStateException - Thrown in case the packet is not a request.
Threading:
This method is not safe for concurrent access by multiple threads.

setReplyWithError

public final void setReplyWithError(long errorCode)
Set packet as a reply indicating failure.

Threading:
This method is not safe for concurrent access by multiple threads.

setReplyWithCountAndNum

public final void setReplyWithCountAndNum(int replyCount,
                                          int replyNum)
Set packet as a reply of a single/multi reply request.

Threading:
This method is not safe for concurrent access by multiple threads.

isReply

public final boolean isReply()
Get if packet is a reply.

Threading:
This method is not safe for concurrent access by multiple threads.

isReplySuccess

public final boolean isReplySuccess()
Get whether the reply indicates a failure or success.

Throws:
IllegalStateException - Thrown in case the packet is not a reply.
Threading:
This method is not safe for concurrent access by multiple threads.

getReplyErrorCode

public final long getReplyErrorCode()
Get the error code from a reply indicating a failure.

Throws:
IllegalStateException - Thrown in case the packet a success reply.
Threading:
This method is not safe for concurrent access by multiple threads.

getReplyCount

public final int getReplyCount()
Get the reply count from a success reply.

Throws:
IllegalStateException - Thrown in case the packet a failure reply.
Threading:
This method is not safe for concurrent access by multiple threads.

getReplyNum

public final int getReplyNum()
Get the reply number from a success reply.

Throws:
IllegalStateException - Thrown in case the packet a failure reply.
Threading:
This method is not safe for concurrent access by multiple threads.

toString

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

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

equals

public final boolean equals(Object obj)
Indicates whether some other object is equal to this one.

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

hashCode

public final int hashCode()
Returns the hashcode for this object

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


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