public final class MessagingService extends java.lang.Object implements MessagingServiceMBean
Modifier and Type | Class and Description |
---|---|
static class |
MessagingService.SocketThread |
static class |
MessagingService.Verb |
Modifier and Type | Field and Description |
---|---|
static java.util.EnumMap<MessagingService.Verb,IVersionedSerializer<?>> |
callbackDeserializers
A Map of what kind of serializer to wire up to a REQUEST_RESPONSE callback, based on outbound Verb.
|
static int |
current_version |
static java.util.EnumSet<MessagingService.Verb> |
DROPPABLE_VERBS
Verbs it's okay to drop if the request has been queued longer than the request timeout.
|
static java.lang.String |
FAILURE_CALLBACK_PARAM |
static java.lang.String |
FAILURE_REASON_PARAM |
static java.lang.String |
FAILURE_RESPONSE_PARAM |
static boolean |
FORCE_3_0_PROTOCOL_VERSION |
static java.lang.String |
MBEAN_NAME |
MessagingMetrics |
metrics |
static byte[] |
ONE_BYTE |
static int |
PROTOCOL_MAGIC
we preface every message with this number so the recipient can validate the sender is sane
|
java.util.EnumMap<MessagingService.Verb,IVersionedSerializer<?>> |
verbSerializers
Messages we receive in IncomingTcpConnection have a Verb that tells us what kind of message it is.
|
static java.util.EnumMap<MessagingService.Verb,Stage> |
verbStages |
static MessagingService.Verb[] |
verbValues |
static int |
VERSION_12 |
static int |
VERSION_20 |
static int |
VERSION_21 |
static int |
VERSION_22 |
static int |
VERSION_30 |
static int |
VERSION_3014 |
Modifier and Type | Method and Description |
---|---|
int |
addCallback(IAsyncCallback cb,
MessageOut<?> message,
java.net.InetAddress to,
long timeout,
ConsistencyLevel consistencyLevel,
boolean allowHints) |
int |
addCallback(IAsyncCallback cb,
MessageOut message,
java.net.InetAddress to,
long timeout,
boolean failureCallback) |
void |
addLatency(java.net.InetAddress address,
long latency) |
void |
addMessageSink(IMessageSink sink) |
void |
applyBackPressure(java.lang.Iterable<java.net.InetAddress> hosts,
long timeoutInNanos)
Applies back-pressure for the given hosts, according to the configured strategy.
|
boolean |
areAllNodesAtLeast22() |
boolean |
areAllNodesAtLeast30() |
void |
clearCallbacksUnsafe() |
void |
clearMessageSinks() |
void |
convict(java.net.InetAddress ep)
called from gossiper when it notices a node is not responding.
|
void |
destroyConnectionPool(java.net.InetAddress to) |
java.util.Map<java.lang.String,java.lang.Double> |
getBackPressurePerHost()
Back-pressure rate limiting per host
|
static int |
getBits(int packed,
int start,
int count) |
OutboundTcpConnection |
getConnection(java.net.InetAddress to,
MessageOut msg) |
OutboundTcpConnectionPool |
getConnectionPool(java.net.InetAddress to) |
java.util.Map<java.lang.String,java.lang.Integer> |
getDroppedMessages()
dropped message counts for server lifetime
|
java.util.Map<java.lang.String,java.lang.Long> |
getGossipMessageCompletedTasks()
Completed tasks for gossip message TCP Connections
|
java.util.Map<java.lang.String,java.lang.Long> |
getGossipMessageDroppedTasks()
Dropped tasks for gossip message TCP Connections
|
java.util.Map<java.lang.String,java.lang.Integer> |
getGossipMessagePendingTasks()
Pending tasks for gossip message TCP Connections
|
java.util.Map<java.lang.String,java.lang.Long> |
getLargeMessageCompletedTasks()
Completed tasks for large message) TCP Connections
|
java.util.Map<java.lang.String,java.lang.Long> |
getLargeMessageDroppedTasks()
Dropped tasks for large message TCP Connections
|
java.util.Map<java.lang.String,java.lang.Integer> |
getLargeMessagePendingTasks()
Pending tasks for large message TCP Connections
|
int |
getLargeMessagePendingTasks(java.net.InetAddress address) |
int |
getRawVersion(java.net.InetAddress endpoint)
Returns the messaging-version exactly as announced by the given endpoint.
|
CallbackInfo |
getRegisteredCallback(int messageId) |
long |
getRegisteredCallbackAge(int messageId) |
java.util.Map<java.lang.String,java.lang.Long> |
getSmallMessageCompletedTasks()
Completed tasks for small message TCP Connections
|
java.util.Map<java.lang.String,java.lang.Long> |
getSmallMessageDroppedTasks()
Dropped tasks for small message TCP Connections
|
java.util.Map<java.lang.String,java.lang.Integer> |
getSmallMessagePendingTasks()
Pending tasks for small message TCP Connections
|
java.util.List<MessagingService.SocketThread> |
getSocketThreads() |
java.util.Map<java.lang.String,java.lang.Long> |
getTimeoutsPerHost()
Number of timeouts per host
|
long |
getTotalTimeouts()
Total number of timeouts happened on this node
|
IVerbHandler |
getVerbHandler(MessagingService.Verb type)
This method returns the verb handler associated with the registered
verb.
|
int |
getVersion(java.net.InetAddress endpoint)
Returns the messaging-version as announced by the given node but capped
to the min of the version as announced by the node and
current_version . |
int |
getVersion(java.lang.String endpoint) |
static IPartitioner |
globalPartitioner() |
void |
incrementDroppedMessages(MessageIn message,
long timeTaken) |
void |
incrementDroppedMessages(MessagingService.Verb verb) |
void |
incrementDroppedMessages(MessagingService.Verb verb,
boolean isCrossNode) |
void |
incrementDroppedMessages(MessagingService.Verb verb,
long timeTaken) |
void |
incrementDroppedMessages(MessagingService.Verb verb,
long timeTaken,
boolean isCrossNode) |
void |
incrementDroppedMutations(java.util.Optional<IMutation> mutationOpt,
long timeTaken) |
static MessagingService |
instance() |
boolean |
isBackPressureEnabled()
Get back-pressure enabled state
|
boolean |
isListening() |
boolean |
knowsVersion(java.net.InetAddress endpoint) |
void |
listen() |
void |
maybeAddLatency(IAsyncCallback cb,
java.net.InetAddress address,
long latency)
Track latency information for the dynamic snitch
|
void |
receive(MessageIn message,
int id) |
void |
register(ILatencySubscriber subcriber) |
void |
registerVerbHandlers(MessagingService.Verb verb,
IVerbHandler verbHandler)
Register a verb and the corresponding verb handler with the
Messaging Service.
|
void |
removeMessageSink(IMessageSink sink) |
CallbackInfo |
removeRegisteredCallback(int messageId) |
void |
resetDroppedMessagesMap(java.lang.String scope) |
void |
resetVersion(java.net.InetAddress endpoint) |
void |
sendOneWay(MessageOut message,
java.net.InetAddress to) |
void |
sendOneWay(MessageOut message,
int id,
java.net.InetAddress to)
Send a message to a given endpoint.
|
void |
sendReply(MessageOut message,
int id,
java.net.InetAddress to) |
int |
sendRR(MessageOut<?> message,
java.net.InetAddress to,
AbstractWriteResponseHandler<?> handler,
boolean allowHints)
Send a mutation message or a Paxos Commit to a given endpoint.
|
<T> AsyncOneResponse<T> |
sendRR(MessageOut message,
java.net.InetAddress to) |
int |
sendRR(MessageOut message,
java.net.InetAddress to,
IAsyncCallback cb) |
int |
sendRR(MessageOut message,
java.net.InetAddress to,
IAsyncCallback cb,
long timeout,
boolean failureCallback)
Send a non-mutation message to a given endpoint.
|
int |
sendRRWithFailure(MessageOut message,
java.net.InetAddress to,
IAsyncCallbackWithFailure cb) |
void |
setBackPressureEnabled(boolean enabled)
Enable/Disable back-pressure
|
void |
setCallbackForTests(int messageId,
CallbackInfo callback) |
int |
setVersion(java.net.InetAddress endpoint,
int version) |
void |
shutdown()
Wait for callbacks and don't allow any more to be created (since they could require writing hints)
|
void |
shutdown(boolean gracefully) |
void |
updateBackPressureOnReceive(java.net.InetAddress host,
IAsyncCallback callback,
boolean timeout)
Updates the back-pressure state on reception from the given host if enabled and the given message callback supports it.
|
void |
updateBackPressureOnSend(java.net.InetAddress host,
IAsyncCallback callback,
MessageOut<?> message)
Updates the back-pressure state on sending to the given host if enabled and the given message callback supports it.
|
static void |
validateMagic(int magic) |
static void |
validatePartitioner(AbstractBounds<?> bounds) |
static void |
validatePartitioner(java.util.Collection<? extends AbstractBounds<?>> allBounds) |
void |
waitUntilListening() |
public static final boolean FORCE_3_0_PROTOCOL_VERSION
public static final java.lang.String MBEAN_NAME
public static final int VERSION_12
public static final int VERSION_20
public static final int VERSION_21
public static final int VERSION_22
public static final int VERSION_30
public static final int VERSION_3014
public static final int current_version
public static final java.lang.String FAILURE_CALLBACK_PARAM
public static final byte[] ONE_BYTE
public static final java.lang.String FAILURE_RESPONSE_PARAM
public static final java.lang.String FAILURE_REASON_PARAM
public static final int PROTOCOL_MAGIC
public final MessagingMetrics metrics
public static final MessagingService.Verb[] verbValues
public static final java.util.EnumMap<MessagingService.Verb,Stage> verbStages
public final java.util.EnumMap<MessagingService.Verb,IVersionedSerializer<?>> verbSerializers
public static final java.util.EnumMap<MessagingService.Verb,IVersionedSerializer<?>> callbackDeserializers
public static final java.util.EnumSet<MessagingService.Verb> DROPPABLE_VERBS
public void resetDroppedMessagesMap(java.lang.String scope)
public static MessagingService instance()
public void addMessageSink(IMessageSink sink)
public void removeMessageSink(IMessageSink sink)
public void clearMessageSinks()
public void updateBackPressureOnSend(java.net.InetAddress host, IAsyncCallback callback, MessageOut<?> message)
host
- The replica host the back-pressure state refers to.callback
- The message callback.message
- The actual message.public void updateBackPressureOnReceive(java.net.InetAddress host, IAsyncCallback callback, boolean timeout)
host
- The replica host the back-pressure state refers to.callback
- The message callback.timeout
- True if updated following a timeout, false otherwise.public void applyBackPressure(java.lang.Iterable<java.net.InetAddress> hosts, long timeoutInNanos)
hosts
- The hosts to apply back-pressure to.timeoutInNanos
- The max back-pressure timeout.public void maybeAddLatency(IAsyncCallback cb, java.net.InetAddress address, long latency)
cb
- the callback associated with this message -- this lets us know if it's a message type we're interested inaddress
- the host that replied to the messagelatency
- public void addLatency(java.net.InetAddress address, long latency)
public void convict(java.net.InetAddress ep)
public void listen()
public void waitUntilListening()
public boolean isListening()
public void destroyConnectionPool(java.net.InetAddress to)
public OutboundTcpConnectionPool getConnectionPool(java.net.InetAddress to)
public OutboundTcpConnection getConnection(java.net.InetAddress to, MessageOut msg)
public void registerVerbHandlers(MessagingService.Verb verb, IVerbHandler verbHandler)
verb
- verbHandler
- handler for the specified verbpublic IVerbHandler getVerbHandler(MessagingService.Verb type)
type
- for which the verb handler is soughtpublic int addCallback(IAsyncCallback cb, MessageOut message, java.net.InetAddress to, long timeout, boolean failureCallback)
public int addCallback(IAsyncCallback cb, MessageOut<?> message, java.net.InetAddress to, long timeout, ConsistencyLevel consistencyLevel, boolean allowHints)
public int sendRR(MessageOut message, java.net.InetAddress to, IAsyncCallback cb)
public int sendRRWithFailure(MessageOut message, java.net.InetAddress to, IAsyncCallbackWithFailure cb)
public int sendRR(MessageOut message, java.net.InetAddress to, IAsyncCallback cb, long timeout, boolean failureCallback)
message
- message to be sent.to
- endpoint to which the message needs to be sentcb
- callback interface which is used to pass the responses or
suggest that a timeout occurred to the invoker of the send().timeout
- the timeout used for expirationpublic int sendRR(MessageOut<?> message, java.net.InetAddress to, AbstractWriteResponseHandler<?> handler, boolean allowHints)
message
- message to be sent.to
- endpoint to which the message needs to be senthandler
- callback interface which is used to pass the responses or
suggest that a timeout occurred to the invoker of the send().public void sendOneWay(MessageOut message, java.net.InetAddress to)
public void sendReply(MessageOut message, int id, java.net.InetAddress to)
public void sendOneWay(MessageOut message, int id, java.net.InetAddress to)
message
- messages to be sent.to
- endpoint to which the message needs to be sentpublic <T> AsyncOneResponse<T> sendRR(MessageOut message, java.net.InetAddress to)
public void register(ILatencySubscriber subcriber)
public void clearCallbacksUnsafe()
public void shutdown()
public void shutdown(boolean gracefully)
public void receive(MessageIn message, int id)
public void setCallbackForTests(int messageId, CallbackInfo callback)
public CallbackInfo getRegisteredCallback(int messageId)
public CallbackInfo removeRegisteredCallback(int messageId)
public long getRegisteredCallbackAge(int messageId)
public static void validateMagic(int magic) throws java.io.IOException
java.io.IOException
public static int getBits(int packed, int start, int count)
public boolean areAllNodesAtLeast22()
public boolean areAllNodesAtLeast30()
public int setVersion(java.net.InetAddress endpoint, int version)
public void resetVersion(java.net.InetAddress endpoint)
public int getVersion(java.net.InetAddress endpoint)
current_version
.public int getVersion(java.lang.String endpoint) throws java.net.UnknownHostException
getVersion
in interface MessagingServiceMBean
java.net.UnknownHostException
public int getRawVersion(java.net.InetAddress endpoint)
public boolean knowsVersion(java.net.InetAddress endpoint)
public void incrementDroppedMutations(java.util.Optional<IMutation> mutationOpt, long timeTaken)
public void incrementDroppedMessages(MessagingService.Verb verb)
public void incrementDroppedMessages(MessagingService.Verb verb, long timeTaken)
public void incrementDroppedMessages(MessageIn message, long timeTaken)
public void incrementDroppedMessages(MessagingService.Verb verb, long timeTaken, boolean isCrossNode)
public void incrementDroppedMessages(MessagingService.Verb verb, boolean isCrossNode)
public java.util.Map<java.lang.String,java.lang.Integer> getLargeMessagePendingTasks()
MessagingServiceMBean
getLargeMessagePendingTasks
in interface MessagingServiceMBean
public int getLargeMessagePendingTasks(java.net.InetAddress address)
public java.util.Map<java.lang.String,java.lang.Long> getLargeMessageCompletedTasks()
MessagingServiceMBean
getLargeMessageCompletedTasks
in interface MessagingServiceMBean
public java.util.Map<java.lang.String,java.lang.Long> getLargeMessageDroppedTasks()
MessagingServiceMBean
getLargeMessageDroppedTasks
in interface MessagingServiceMBean
public java.util.Map<java.lang.String,java.lang.Integer> getSmallMessagePendingTasks()
MessagingServiceMBean
getSmallMessagePendingTasks
in interface MessagingServiceMBean
public java.util.Map<java.lang.String,java.lang.Long> getSmallMessageCompletedTasks()
MessagingServiceMBean
getSmallMessageCompletedTasks
in interface MessagingServiceMBean
public java.util.Map<java.lang.String,java.lang.Long> getSmallMessageDroppedTasks()
MessagingServiceMBean
getSmallMessageDroppedTasks
in interface MessagingServiceMBean
public java.util.Map<java.lang.String,java.lang.Integer> getGossipMessagePendingTasks()
MessagingServiceMBean
getGossipMessagePendingTasks
in interface MessagingServiceMBean
public java.util.Map<java.lang.String,java.lang.Long> getGossipMessageCompletedTasks()
MessagingServiceMBean
getGossipMessageCompletedTasks
in interface MessagingServiceMBean
public java.util.Map<java.lang.String,java.lang.Long> getGossipMessageDroppedTasks()
MessagingServiceMBean
getGossipMessageDroppedTasks
in interface MessagingServiceMBean
public java.util.Map<java.lang.String,java.lang.Integer> getDroppedMessages()
MessagingServiceMBean
getDroppedMessages
in interface MessagingServiceMBean
public long getTotalTimeouts()
MessagingServiceMBean
getTotalTimeouts
in interface MessagingServiceMBean
public java.util.Map<java.lang.String,java.lang.Long> getTimeoutsPerHost()
MessagingServiceMBean
getTimeoutsPerHost
in interface MessagingServiceMBean
public java.util.Map<java.lang.String,java.lang.Double> getBackPressurePerHost()
MessagingServiceMBean
getBackPressurePerHost
in interface MessagingServiceMBean
public void setBackPressureEnabled(boolean enabled)
MessagingServiceMBean
setBackPressureEnabled
in interface MessagingServiceMBean
public boolean isBackPressureEnabled()
MessagingServiceMBean
isBackPressureEnabled
in interface MessagingServiceMBean
public static IPartitioner globalPartitioner()
public static void validatePartitioner(java.util.Collection<? extends AbstractBounds<?>> allBounds)
public static void validatePartitioner(AbstractBounds<?> bounds)
public java.util.List<MessagingService.SocketThread> getSocketThreads()
Copyright © 2009-2022 The Apache Software Foundation