public abstract class Message
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
MessageDispatcher
for communication with other network nodes.
Every message is assigned a per-host unique ID that together with the sender's NetworkNode
is univerlally unique
identifier. Every message also stores its navigation path, i.e. the list of network nodes it was sent through.
An algorithm usually uses descendants of the Message
to perform specific tasks.
ReplyMessage
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected long |
messageID
The message ID
|
protected java.util.List<NavigationElement> |
navigationPath
Navigation path this message has gone through
|
Modifier | Constructor and Description |
---|---|
protected |
Message()
Creates a new instance of Message.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a clone of this message.
|
void |
deregisterOperStats()
Deregisters all operation statistics in this thread.
|
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this message.
|
NetworkNode |
getDestination()
Returns the network node to which this message arrived.
|
long |
getMessageID()
Returns the identifier of this message.
|
int |
getNavigationPathLength()
Returns the length of the navigation path.
|
NetworkNode |
getOriginalSender()
Returns the network node, on which this message was created and from which it was sent in the begining.
|
java.util.Iterator<NavigationElement> |
getPathElements()
Returns an iterator through all navigation path elements
|
NetworkNode |
getSender()
Returns the network node from which this message arrived.
|
java.util.List<NetworkNode> |
getSenderList()
Returns the list of senders stored in the navigation path and the actual sender.
|
int |
hashCode()
Returns a hash code value for this message.
|
Statistics<?> |
registerBoundStat(java.lang.String name)
Add a statistic to the actual navigation element and bind it to some global statistic.
|
Statistics<?> |
registerBoundStat(java.lang.String name,
java.lang.String asName)
Add a statistic to the actual navigation element and bind it to some global statistic.
|
protected OperationStatistics |
setNavigationPathStatistics()
Set statistics in actual navigation element.
|
java.lang.String |
toString()
Returns a string representation of this message.
|
protected final long messageID
protected final java.util.List<NavigationElement> navigationPath
protected Message()
public long getMessageID()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
This method must be overridden whenever not-immutable attributes are added to subclasses. The CloneNotSupportedException is never thrown by this class, but might not be true for its subclasses.
WARNING: The navigation path of this message is not cloned, it rather holds the same reference for all the clones! Therefore, adding a path element to one message adds it to all of them. This is a correct behavior (used by forwarding).
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if this instance cannot be clonedprotected OperationStatistics setNavigationPathStatistics()
public Statistics<?> registerBoundStat(java.lang.String name, java.lang.String asName) throws java.lang.InstantiationException
name
- the name of a global statisticasName
- the name of the new bound statisticjava.lang.InstantiationException
- if the statistic with the specified name was not found in global statisticspublic Statistics<?> registerBoundStat(java.lang.String name) throws java.lang.InstantiationException
name
" will be used as a name for the bound statistic.name
- the name of a global statisticjava.lang.InstantiationException
- if the statistic with the specified name was not found in global statisticspublic void deregisterOperStats()
public NetworkNode getSender()
public NetworkNode getOriginalSender()
public NetworkNode getDestination()
public java.util.Iterator<NavigationElement> getPathElements()
public int getNavigationPathLength()
public java.util.List<NetworkNode> getSenderList()
public final boolean equals(java.lang.Object obj)
obj
is equal to this message if and only if it is an instance of Message
that has the same ID and the same original sender.
The equals
method cannot be overridden to avoid bugs while
receiving reply messages. If you need to use a different hashing on messages,
use a wrapper class.
equals
in class java.lang.Object
obj
- the reference object with which to comparetrue
if this message is the same as the obj
argument; false
otherwisepublic final int hashCode()
The hashCode
method cannot be overridden to avoid bugs while
receiving reply messages. If you need to use a different hashing on messages,
use a wrapper class.
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object