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, String msgId)
Instantiate a message
Message(String type, String msgId)
Instantiate a message
Message(ZNRecord record)
Instantiate a message
Message(ZNRecord record, String id)
Instantiate a message with a new id
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 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
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
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
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
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
String getToState()
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 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 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 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 setPartitionName(String partitionName)
Set the name of the partition this message concerns
void setReadTimeStamp(long time)
Set the time that this message was read
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 setStateModelDef(String stateModelDefName)
Set the state model definition name
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(String tgtSessionId)
Set the session identifier of the destination node
void setToState(String state)
Set the "to state" for transition-related messages
[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, String msgId)

Instantiate a message

Parameters
type the message category
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)

Instantiate a message

Parameters
record a ZNRecord corresponding to a message

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 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 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 name, 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 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 String getPartitionName ()

Get the resource partition associated with this message

Returns
  • partition name

public List<String> getPartitionNames ()

Get a list of partitions associated with this message

Returns
  • list of partition names

public long getReadTimeStamp ()

Get the time that this message was read

Returns
  • UNIX timestamp

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 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 String getToState ()

Get the "to state" for transition-related messages

Returns
  • state name, 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 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 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 name

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 setPartitionName (String partitionName)

Set the name 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 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 setStateModelDef (String stateModelDefName)

Set the state model definition name

Parameters
stateModelDefName a reference to the state model definition, e.g. "MasterSlave"

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 (String tgtSessionId)

Set the session identifier of the destination node

Parameters
tgtSessionId session identifier

public void setToState (String state)

Set the "to state" for transition-related messages

Parameters
state the state name