T
- The type of the message payload.public class Message<T>
extends java.lang.Object
MessageIn
and MessageOut
fused
in one class.Modifier and Type | Class and Description |
---|---|
static class |
Message.Builder<T> |
static class |
Message.Header
Split into a separate object to allow partial message deserialization without wasting work and allocation
afterwards, if the entire message is necessary and available.
|
static class |
Message.InvalidLegacyProtocolMagic |
static class |
Message.Serializer
Each message contains a header with several fixed fields, an optional key-value params section, and then
the message payload itself.
|
Modifier and Type | Field and Description |
---|---|
Message.Header |
header |
T |
payload |
static Message.Serializer |
serializer |
Modifier and Type | Method and Description |
---|---|
static <T> Message.Builder<T> |
builder(Message<T> message) |
static <T> Message.Builder<T> |
builder(Verb verb,
T payload) |
long |
createdAtNanos()
Creation time of the message.
|
long |
creationTimeMillis() |
long |
elapsedSinceCreated(java.util.concurrent.TimeUnit units)
For how long the message has lived.
|
Message<NoPayload> |
emptyResponse()
Builds a response Message with no payload, and all the right fields inferred from request Message
|
long |
expiresAtNanos() |
Message<RequestFailureReason> |
failureResponse(RequestFailureReason reason)
Builds a failure response Message with an explicit reason, and fields inferred from request Message
|
ForwardingInfo |
forwardTo()
Used for cross-DC write optimisation - pick one node in the DC and have it relay the write to its local peers
|
InetAddressAndPort |
from()
Sender of the message.
|
long |
id()
id of the request/message.
|
static <T> Message<T> |
internalResponse(Verb verb,
T payload) |
boolean |
isCrossNode()
Whether the message has crossed the node boundary, that is whether it originated from another node.
|
static <T> Message<T> |
out(Verb verb,
T payload)
Make a request
Message with supplied verb and payload. |
static <T> Message<T> |
out(Verb verb,
T payload,
long expiresAtNanos) |
static <T> Message<T> |
outWithFlag(Verb verb,
T payload,
MessageFlag flag) |
static <T> Message<T> |
outWithFlags(Verb verb,
T payload,
MessageFlag flag1,
MessageFlag flag2) |
InetAddressAndPort |
respondTo()
The originator of the request - used when forwarding and will differ from
from() |
<T> Message<T> |
responseWith(T payload)
Builds a response Message with provided payload, and all the right fields inferred from request Message
|
int |
serializedSize(int version)
Serialized size of the entire message, for the provided messaging version.
|
java.lang.String |
toString() |
java.util.UUID |
traceSession() |
Tracing.TraceType |
traceType() |
boolean |
trackRepairedData()
See CASSANDRA-14145
|
Verb |
verb() |
Message<T> |
withForwardTo(ForwardingInfo peers) |
public final Message.Header header
public final T payload
public static final Message.Serializer serializer
public InetAddressAndPort from()
public boolean isCrossNode()
public long id()
public Verb verb()
public long createdAtNanos()
DatabaseDescriptor.hasCrossNodeTimeout()
,
deserialize()
will use the marshalled value, otherwise will use current time on the deserializing machine.public long expiresAtNanos()
public long elapsedSinceCreated(java.util.concurrent.TimeUnit units)
public long creationTimeMillis()
public boolean trackRepairedData()
@Nullable public ForwardingInfo forwardTo()
@Nullable public InetAddressAndPort respondTo()
from()
@Nullable public java.util.UUID traceSession()
@Nullable public Tracing.TraceType traceType()
public static <T> Message<T> out(Verb verb, T payload)
Message
with 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 of out()
that allow providing them at point of message constructions, rather than allocating new messages
with those added flags and params. See outWithFlag()
, outWithFlags()
, and outWithParam()
family.public static <T> Message<T> outWithFlag(Verb verb, T payload, MessageFlag flag)
public static <T> Message<T> outWithFlags(Verb verb, T payload, MessageFlag flag1, MessageFlag flag2)
public <T> Message<T> responseWith(T payload)
public Message<NoPayload> emptyResponse()
public Message<RequestFailureReason> failureResponse(RequestFailureReason reason)
public Message<T> withForwardTo(ForwardingInfo peers)
public java.lang.String toString()
toString
in class java.lang.Object
public static <T> Message.Builder<T> builder(Message<T> message)
public static <T> Message.Builder<T> builder(Verb verb, T payload)
public int serializedSize(int version)
Copyright © 2009-2021 The Apache Software Foundation