Package org.apache.cassandra.net
Class Message<T>
java.lang.Object
org.apache.cassandra.net.Message<T>
- Type Parameters:
T- The type of the message payload.
Immutable main unit of internode communication - what used to be
MessageIn and MessageOut fused
in one class.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classSplit into a separate object to allow partial message deserialization without wasting work and allocation afterwards, if the entire message is necessary and available.static final classstatic final classEach message contains a header with several fixed fields, an optional key-value params section, and then the message payload itself. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Message.Builder<T>static <T> Message.Builder<T>longCreation time of the message.longlongelapsedSinceCreated(TimeUnit units) For how long the message has lived.Builds a response Message with no payload, and all the right fields inferred from request MessagelongfailureResponse(RequestFailureReason reason) Builds a failure response Message with an explicit reason, and fields inferred from request MessageUsed for cross-DC write optimisation - pick one node in the DC and have it relay the write to its local peersfrom()Sender of the message.longid()id of the request/message.static <T> Message<T>internalResponse(Verb verb, T payload) booleanWhether the message has crossed the node boundary, that is whether it originated from another node.booleanstatic <T> Message<T>Make a requestMessagewith supplied verb and payload.static <T> Message<T>static <T> Message<T>outWithFlag(Verb verb, T payload, MessageFlag flag) static <T> Message<T>outWithFlags(Verb verb, T payload, MessageFlag flag1, MessageFlag flag2) static <T> Message<T>outWithFlags(Verb verb, T payload, Dispatcher.RequestTime requestTime, List<MessageFlag> flags) static <T> Message<T>remoteResponse(InetAddressAndPort from, Verb verb, T payload) Used by theMultiRangeReadCommandto split multi-range responses from a replica into single-range responses.The originator of the request - used when forwarding and will differ fromfrom()<T> Message<T>responseWith(T payload) Builds a response Message with provided payload, and all the right fields inferred from request MessageintserializedSize(int version) Serialized size of the entire message, for the provided messaging version.static <T> Message<T>synthetic(InetAddressAndPort from, Verb verb, T payload) toString()booleanSee CASSANDRA-14145booleanverb()withFlag(MessageFlag flag) withForwardTo(ForwardingInfo peers) withFrom(InetAddressAndPort from) withParams(Map<ParamType, Object> values) <V> Message<V>withPayload(V newPayload)
-
Field Details
-
header
-
payload
-
serializer
-
-
Method Details
-
from
Sender of the message. -
isCrossNode
public boolean isCrossNode()Whether the message has crossed the node boundary, that is whether it originated from another node. -
id
public long id()id of the request/message. In 4.0+ can be shared between multiple messages of the same logical request, whilst in versions above a new id would be allocated for each message sent. -
verb
-
isFailureResponse
public boolean isFailureResponse() -
createdAtNanos
public long createdAtNanos()Creation time of the message. If cross-node timeouts are enabled (DatabaseDescriptor.hasCrossNodeTimeout(),deserialize()will use the marshalled value, otherwise will use current time on the deserializing machine. -
expiresAtNanos
public long expiresAtNanos() -
elapsedSinceCreated
For how long the message has lived. -
creationTimeMillis
public long creationTimeMillis() -
trackWarnings
public boolean trackWarnings() -
trackRepairedData
public boolean trackRepairedData()See CASSANDRA-14145 -
forwardTo
Used for cross-DC write optimisation - pick one node in the DC and have it relay the write to its local peers -
respondTo
The originator of the request - used when forwarding and will differ fromfrom() -
traceSession
-
traceType
-
out
Make a requestMessagewith supplied verb and payload. Will fill in remaining fields automatically. If you know that you will need to set some params or flags - prefer using variants ofout()that allow providing them at point of message constructions, rather than allocating new messages with those added flags and params. SeeoutWithFlag(),outWithFlags(), andoutWithParam()family. -
synthetic
-
out
-
outWithFlag
-
outWithFlags
public static <T> Message<T> outWithFlags(Verb verb, T payload, MessageFlag flag1, MessageFlag flag2) -
outWithFlags
public static <T> Message<T> outWithFlags(Verb verb, T payload, Dispatcher.RequestTime requestTime, List<MessageFlag> flags) -
internalResponse
-
remoteResponse
Used by theMultiRangeReadCommandto split multi-range responses from a replica into single-range responses. -
responseWith
Builds a response Message with provided payload, and all the right fields inferred from request Message -
emptyResponse
Builds a response Message with no payload, and all the right fields inferred from request Message -
failureResponse
Builds a failure response Message with an explicit reason, and fields inferred from request Message -
withPayload
-
withForwardTo
-
withFrom
-
withFlag
-
withParam
-
withParams
-
toString
-
builder
-
builder
-
serializedSize
public int serializedSize(int version) Serialized size of the entire message, for the provided messaging version. Caches the calculated value.
-