public class

Message

extends HelixProperty
java.lang.Object
   ↳ org.apache.helix.HelixProperty
     ↳ org.apache.helix.model.Message

Class Overview

Messages sent internally among nodes in the system to respond to changes in state.

Summary

Nested Classes
enum Message.Attributes Properties attached to Messages  
enum Message.MessageState The current processed state of the message  
enum Message.MessageType The major categories of messages that are sent  
Fields
public static final Comparator<Message> CREATE_TIME_COMPARATOR Compares the creation time of two Messages
[Expand]
Inherited Fields
From class org.apache.helix.HelixProperty
Public Constructors
Message(Message.MessageType type, MessageId msgId)
Instantiate a message
Message(Message.MessageType type, String msgId)
Instantiate a message
Message(String type, MessageId msgId)
Instantiate a message
Message(String type, String msgId)
Instantiate a message
Message(ZNRecord record, MessageId id)
Instantiate a message with a new id
Message(ZNRecord record, String id)
Instantiate a message with a new id
Message(ZNRecord record)
Instantiate a message
Public Methods
void addPartitionName(String partitionName)
Add a partition to a collection of partitions associated with this message
static Message createReplyMessage(Message srcMessage, String instanceName, Map<StringString> taskResultMap)
Create a reply based on an incoming message
String getAttribute(Message.Attributes attr)
Get the value of an attribute
int getBucketSize()
Get the size of buckets defined
String getClusterEventName()
Get the cluster event name generating this message
String getControllerMessageId()
Get controller message id, used for scheduler-task-queue state model only
String getCorrelationId()
Get the unique identifier attached to this message for reply matching
long getCreateTimeStamp()
Get the time that this message was created
Boolean getDebug()
Check for debug mode
long getExecuteStartTimeStamp()
Get the time that execution occurred as a result of this message
String getExecutionSessionId()
Get the session identifier of the node that executes the message
int getExecutionTimeout()
Get the time to wait before stopping execution of this message
String getFromState()
Get the "from-state" for transition-related messages
Integer getGeneration()
Get the generation that this message corresponds to
PropertyKey getKey(PropertyKey.Builder keyBuilder, String instanceName)
Get the PropertyKey for this message
MessageId getMessageId()
Get the unique identifier of this message
String getMsgId()
Get the unique identifier of this message
String getMsgSrc()
Get the instance from which the message originated
Message.MessageState getMsgState()
Get the current state of the message
String getMsgSubType()
Get the subtype of the message
String getMsgType()
Get the type of this message
PartitionId getPartitionId()
Get the resource partition associated with this message
List<PartitionId> getPartitionIds()
Get a list of partitions associated with this message
String getPartitionName()
Get the resource partition associated with this message
List<String> getPartitionNames()
Get a list of partitions associated with this message
long getReadTimeStamp()
Get the time that this message was read
ResourceId getResourceId()
Get the resource associated with this message
String getResourceName()
Get the resource associated with this message
Map<StringString> getResultMap()
Get the results of message execution
int getRetryCount()
Get the number of times to retry message handling on timeouts
InstanceType getSrcInstanceType()
Get the type of instance that the source is
String getSrcSessionId()
Get the session identifier of the source node
String getStateModelDef()
Get the state model definition name
StateModelDefId getStateModelDefId()
Get the state model definition id
String getStateModelFactoryName()
Get the state model factory associated with this message
String getTgtName()
Get the name of the target instance
String getTgtSessionId()
Get the session identifier of the destination node
int getTimeout()
Get timeout
String getToState()
Get the "to state" for transition-related messages
SessionId getTypedExecutionSessionId()
Get the session identifier of the node that executes the message
State getTypedFromState()
Get the "from-state" for transition-related messages
SessionId getTypedSrcSessionId()
Get the session identifier of the source node
SessionId getTypedTgtSessionId()
Get the session identifier of the destination node
State getTypedToState()
Get the "to state" for transition-related messages
boolean isControlerMsg()
Check if this message is targetted for a controller
boolean isValid()
Get property validity
void setAttribute(Message.Attributes attr, String val)
Add or change a message attribute
void setBucketSize(int bucketSize)
Set the size of buckets defined
void setClusterEvent(ClusterEvent event)
Set the cluster event generating this message
void setCorrelationId(String correlationId)
Set a unique identifier that others can use to refer to this message in replies
void setCreateTimeStamp(long timestamp)
Set the time that the message was created
void setExecuteSessionId(String exeSessionId)
Set the session identifier of the node that executes the message
void setExecuteSessionId(SessionId exeSessionId)
Set the session identifier of the node that executes the message
void setExecuteStartTimeStamp(long time)
Set the time that the instance executes tasks as instructed by this message
void setExecutionTimeout(int timeout)
Set the time to wait before stopping execution of this message
void setFromState(String state)
Set the "from state" for transition-related messages
void setFromState(State state)
Set the "from state" for transition-related messages
void setInnerMessage(Message message)
Set an inner message
void setMessageId(MessageId msgId)
Set the unique identifier of this message
void setMsgId(String msgId)
Set the unique identifier of this message
void setMsgState(Message.MessageState msgState)
Set the current state of the message
void setMsgSubType(String subType)
Set a subtype of the message
void setPartitionId(PartitionId partitionId)
Set the id of the partition this message concerns
void setPartitionName(String partitionName)
Set the id of the partition this message concerns
void setReadTimeStamp(long time)
Set the time that this message was read
void setResourceId(ResourceId resourceId)
Set the resource associated with this message
void setResourceName(String resourceName)
Set the resource associated with this message
void setResultMap(Map<StringString> resultMap)
Set the results of message execution
void setRetryCount(int retryCount)
Set the number of times to retry message handling on timeouts
void setSrcInstanceType(InstanceType type)
Set the type of instance that the source node is
void setSrcName(String msgSrc)
Set the name of the source instance
void setSrcSessionId(String srcSessionId)
Set the session identifier of the source node
void setSrcSessionId(SessionId srcSessionId)
Set the session identifier of the source node
void setStateModelDef(StateModelDefId stateModelDefId)
Set the state model definition
void setStateModelDef(String stateModelDefId)
Set the state model definition
void setStateModelFactoryId(StateModelFactoryId factoryId)
Set the state model factory associated with this message
void setStateModelFactoryName(String factoryName)
Set the state model factory associated with this message
void setTgtName(String msgTgt)
Set the instance for which this message is targeted
void setTgtSessionId(SessionId tgtSessionId)
Set the session identifier of the destination node
void setTgtSessionId(String tgtSessionId)
Set the session identifier of the destination node
void setToState(State state)
Set the "to state" for transition-related messages
void setToState(String state)
Set the "to state" for transition-related messages
static Message toMessage(Map<StringString> msgStrMap)
Convert a string map to a message
[Expand]
Inherited Methods
From class org.apache.helix.HelixProperty
From class java.lang.Object

Fields

public static final Comparator<Message> CREATE_TIME_COMPARATOR

Compares the creation time of two Messages

Public Constructors

public Message (Message.MessageType type, MessageId msgId)

Instantiate a message

Parameters
type the message category
msgId unique message identifier

public Message (Message.MessageType type, String msgId)

Instantiate a message

Parameters
type the message category
msgId unique message identifier

public Message (String type, MessageId msgId)

Instantiate a message

Parameters
type Message.MessageType as a string or a custom message type
msgId unique message identifier

public Message (String type, String msgId)

Instantiate a message

Parameters
type Message.MessageType as a string or a custom message type
msgId unique message identifier

public Message (ZNRecord record, MessageId id)

Instantiate a message with a new id

Parameters
record a ZNRecord corresponding to a message
id unique message identifier

public Message (ZNRecord record, String id)

Instantiate a message with a new id

Parameters
record a ZNRecord corresponding to a message
id unique message identifier

public Message (ZNRecord record)

Instantiate a message

Parameters
record a ZNRecord corresponding to a message

Public Methods

public void addPartitionName (String partitionName)

Add a partition to a collection of partitions associated with this message

Parameters
partitionName the partition name to add

public static Message createReplyMessage (Message srcMessage, String instanceName, Map<StringString> taskResultMap)

Create a reply based on an incoming message

Parameters
srcMessage the incoming message
instanceName the instance that is the source of the reply
taskResultMap the result of executing the incoming message
Returns
  • the reply Message

public String getAttribute (Message.Attributes attr)

Get the value of an attribute

Parameters
attr Attribute
Returns
  • attribute value

public int getBucketSize ()

Get the size of buckets defined

Returns
  • the bucket size, or 0 if not defined

public String getClusterEventName ()

Get the cluster event name generating this message

public String getControllerMessageId ()

Get controller message id, used for scheduler-task-queue state model only

Returns
  • controller message id

public String getCorrelationId ()

Get the unique identifier attached to this message for reply matching

Returns
  • the correlation identifier

public long getCreateTimeStamp ()

Get the time that this message was created

Returns
  • UNIX timestamp

public Boolean getDebug ()

Check for debug mode

Returns
  • true if enabled, false if disabled

public long getExecuteStartTimeStamp ()

Get the time that execution occurred as a result of this message

Returns
  • UNIX timestamp

public String getExecutionSessionId ()

Get the session identifier of the node that executes the message

Returns
  • session identifier

public int getExecutionTimeout ()

Get the time to wait before stopping execution of this message

Returns
  • the timeout in ms, or -1 indicating no timeout

public String getFromState ()

Get the "from-state" for transition-related messages

Returns
  • state, or null for other message types

public Integer getGeneration ()

Get the generation that this message corresponds to

Returns
  • generation number

public PropertyKey getKey (PropertyKey.Builder keyBuilder, String instanceName)

Get the PropertyKey for this message

Parameters
keyBuilder PropertyKey Builder
instanceName target instance
Returns
  • message PropertyKey

public MessageId getMessageId ()

Get the unique identifier of this message

Returns
  • message identifier

public String getMsgId ()

Get the unique identifier of this message

Returns
  • message identifier

public String getMsgSrc ()

Get the instance from which the message originated

Returns
  • the instance name

public Message.MessageState getMsgState ()

Get the current state of the message

public String getMsgSubType ()

Get the subtype of the message

Returns
  • the subtype name, or null

public String getMsgType ()

Get the type of this message

Returns

public PartitionId getPartitionId ()

Get the resource partition associated with this message

Returns
  • partition id

public List<PartitionId> getPartitionIds ()

Get a list of partitions associated with this message

Returns
  • list of partition ids

public String getPartitionName ()

Get the resource partition associated with this message

Returns
  • partition id

public List<String> getPartitionNames ()

Get a list of partitions associated with this message

Returns
  • list of partition ids

public long getReadTimeStamp ()

Get the time that this message was read

Returns
  • UNIX timestamp

public ResourceId getResourceId ()

Get the resource associated with this message

Returns
  • resource name

public String getResourceName ()

Get the resource associated with this message

Returns
  • resource name

public Map<StringString> getResultMap ()

Get the results of message execution

Returns
  • map of result property and value pairs

public int getRetryCount ()

Get the number of times to retry message handling on timeouts

Returns
  • maximum number of retries

public InstanceType getSrcInstanceType ()

Get the type of instance that the source is

Returns

public String getSrcSessionId ()

Get the session identifier of the source node

Returns
  • session identifier

public String getStateModelDef ()

Get the state model definition name

Returns
  • a String reference to the state model definition, e.g. "MasterSlave"

public StateModelDefId getStateModelDefId ()

Get the state model definition id

Returns
  • a reference to the state model definition

public String getStateModelFactoryName ()

Get the state model factory associated with this message

Returns
  • the name of the factory

public String getTgtName ()

Get the name of the target instance

Returns
  • instance name

public String getTgtSessionId ()

Get the session identifier of the destination node

Returns
  • session identifier

public int getTimeout ()

Get timeout

Returns
  • timeout or -1 if not available

public String getToState ()

Get the "to state" for transition-related messages

Returns
  • state, or null for other message types

public SessionId getTypedExecutionSessionId ()

Get the session identifier of the node that executes the message

Returns
  • session identifier

public State getTypedFromState ()

Get the "from-state" for transition-related messages

Returns
  • state, or null for other message types

public SessionId getTypedSrcSessionId ()

Get the session identifier of the source node

Returns
  • session identifier

public SessionId getTypedTgtSessionId ()

Get the session identifier of the destination node

Returns
  • session identifier

public State getTypedToState ()

Get the "to state" for transition-related messages

Returns
  • state, or null for other message types

public boolean isControlerMsg ()

Check if this message is targetted for a controller

Returns
  • true if this is a controller message, false otherwise

public boolean isValid ()

Get property validity

Returns
  • true if valid, false if invalid

public void setAttribute (Message.Attributes attr, String val)

Add or change a message attribute

Parameters
attr Message.Attributes attribute name
val attribute value

public void setBucketSize (int bucketSize)

Set the size of buckets defined

Parameters
bucketSize the bucket size (will default to 0 if negative)

public void setClusterEvent (ClusterEvent event)

Set the cluster event generating this message

Parameters
event cluster event

public void setCorrelationId (String correlationId)

Set a unique identifier that others can use to refer to this message in replies

Parameters
correlationId a unique identifier, usually randomly generated

public void setCreateTimeStamp (long timestamp)

Set the time that the message was created

Parameters
timestamp a UNIX timestamp

public void setExecuteSessionId (String exeSessionId)

Set the session identifier of the node that executes the message

Parameters
exeSessionId session identifier

public void setExecuteSessionId (SessionId exeSessionId)

Set the session identifier of the node that executes the message

Parameters
exeSessionId session identifier

public void setExecuteStartTimeStamp (long time)

Set the time that the instance executes tasks as instructed by this message

Parameters
time UNIX timestamp

public void setExecutionTimeout (int timeout)

Set the time to wait before stopping execution of this message

Parameters
timeout the timeout in ms, or -1 indicating no timeout

public void setFromState (String state)

Set the "from state" for transition-related messages

Parameters
state the state

public void setFromState (State state)

Set the "from state" for transition-related messages

Parameters
state the state

public void setInnerMessage (Message message)

Set an inner message

public void setMessageId (MessageId msgId)

Set the unique identifier of this message

Parameters
msgId message identifier

public void setMsgId (String msgId)

Set the unique identifier of this message

Parameters
msgId message identifier

public void setMsgState (Message.MessageState msgState)

Set the current state of the message

Parameters
msgState Message.MessageState

public void setMsgSubType (String subType)

Set a subtype of the message

Parameters
subType name of the subtype

public void setPartitionId (PartitionId partitionId)

Set the id of the partition this message concerns

public void setPartitionName (String partitionName)

Set the id of the partition this message concerns

public void setReadTimeStamp (long time)

Set the time that this message was read

Parameters
time UNIX timestamp

public void setResourceId (ResourceId resourceId)

Set the resource associated with this message

Parameters
resourceId resource name to set

public void setResourceName (String resourceName)

Set the resource associated with this message

Parameters
resourceName resource name to set

public void setResultMap (Map<StringString> resultMap)

Set the results of message execution

Parameters
resultMap map of result property and value pairs

public void setRetryCount (int retryCount)

Set the number of times to retry message handling on timeouts

Parameters
retryCount maximum number of retries

public void setSrcInstanceType (InstanceType type)

Set the type of instance that the source node is

Parameters
type InstanceType

public void setSrcName (String msgSrc)

Set the name of the source instance

Parameters
msgSrc instance name

public void setSrcSessionId (String srcSessionId)

Set the session identifier of the source node

Parameters
srcSessionId session identifier

public void setSrcSessionId (SessionId srcSessionId)

Set the session identifier of the source node

Parameters
srcSessionId session identifier

public void setStateModelDef (StateModelDefId stateModelDefId)

Set the state model definition

public void setStateModelDef (String stateModelDefId)

Set the state model definition

public void setStateModelFactoryId (StateModelFactoryId factoryId)

Set the state model factory associated with this message

public void setStateModelFactoryName (String factoryName)

Set the state model factory associated with this message

Parameters
factoryName the name of the factory

public void setTgtName (String msgTgt)

Set the instance for which this message is targeted

Parameters
msgTgt instance name

public void setTgtSessionId (SessionId tgtSessionId)

Set the session identifier of the destination node

Parameters
tgtSessionId session identifier

public void setTgtSessionId (String tgtSessionId)

Set the session identifier of the destination node

Parameters
tgtSessionId session identifier

public void setToState (State state)

Set the "to state" for transition-related messages

Parameters
state the state

public void setToState (String state)

Set the "to state" for transition-related messages

Parameters
state the state

public static Message toMessage (Map<StringString> msgStrMap)

Convert a string map to a message

Returns
  • message