org.apache.cassandra.net

## Class MessageOut<T>

- java.lang.Object
- - org.apache.cassandra.net.MessageOut<T>

-     public class MessageOut<T>
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `java.net.InetAddress` | `from`
    `java.util.Map<java.lang.String,byte[]>` | `parameters`
    `T` | `payload`
    `IVersionedSerializer<T>` | `serializer`
    `MessagingService.Verb` | `verb`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MessageOut(java.net.InetAddress from, MessagingService.Verb verb, T payload, IVersionedSerializer<T> serializer, java.util.Map<java.lang.String,byte[]> parameters)`
    `MessageOut(MessagingService.Verb verb)`
    `MessageOut(MessagingService.Verb verb, T payload, IVersionedSerializer<T> serializer)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Stage` | `getStage()`
    `long` | `getTimeout()`
    `long` | `payloadSize(int version)` Calculate the size of the payload of this message for the specified protocol version and memoize the result for the specified protocol version.
    `void` | `serialize(DataOutputPlus out, int version)`
    `int` | `serializedSize(int version)`
    `java.lang.String` | `toString()`
    `MessageOut<T>` | `withParameter(java.lang.String key, byte[] value)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### from

          public final java.net.InetAddress from

    - #### verb

          public final MessagingService.Verb verb

    - #### payload

          public final T payload

    - #### serializer

          public final IVersionedSerializer<T> serializer

    - #### parameters

          public final java.util.Map<java.lang.String,byte[]> parameters

  - ### Constructor Detail

    - #### MessageOut

          public MessageOut(MessagingService.Verb verb)

    - #### MessageOut

          public MessageOut(MessagingService.Verb verb,
                            T payload,
                            IVersionedSerializer<T> serializer)

    - #### MessageOut

          public MessageOut(java.net.InetAddress from,
                            MessagingService.Verb verb,
                            T payload,
                            IVersionedSerializer<T> serializer,
                            java.util.Map<java.lang.String,byte[]> parameters)

  - ### Method Detail

    - #### withParameter

          public MessageOut<T> withParameter(java.lang.String key,
                                             byte[] value)

    - #### getStage

          public Stage getStage()

    - #### getTimeout

          public long getTimeout()

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### serialize

          public void serialize(DataOutputPlus out,
                                int version)
                         throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### serializedSize

          public int serializedSize(int version)

    - #### payloadSize

          public long payloadSize(int version)

      Calculate the size of the payload of this message for the specified protocol version and memoize the result for the specified protocol version. Memoization only covers the protocol version of the first invocation. It is not safe to call payloadSize concurrently from multiple threads unless it has already been invoked once from a single thread and there is a happens before relationship between that invocation and other threads concurrently invoking payloadSize. For instance it would be safe to invokePayload size to make a decision in the thread that created the message and then hand it off to other threads via a thread-safe queue, volatile write, or synchronized/ReentrantLock.
      Parameters:
        `version` - Protocol version to use when calculating payload size
      Returns:
        Size of the payload of this message in bytes

Copyright © 2018 The Apache Software Foundation