infoservice.agreement.multicast.messages
Class AMessage

java.lang.Object
  extended by infoservice.agreement.multicast.messages.AMessage
All Implemented Interfaces:
IDistributable, IAgreementMessage
Direct Known Subclasses:
CommitMessage, EchoMessage, InitMessage, RejectMessage

public abstract class AMessage
extends java.lang.Object
implements IAgreementMessage


Field Summary
private  byte[] m_compressedData
           
protected  java.lang.String m_consensusId
           
protected  java.lang.String m_initiatorsId
           
protected  java.lang.String m_lastCommonRandom
           
protected  int m_messageType
           
protected  java.lang.String m_proposal
           
protected  java.lang.String m_senderId
           
protected  boolean m_signatureOk
           
protected  org.w3c.dom.Document m_xmlNode
           
 
Fields inherited from interface anon.infoservice.IDistributable
FIELD_HTTP_REQUEST_STRING, FIELD_HTTP_SERIALS_REQUEST_STRING
 
Constructor Summary
protected AMessage(java.lang.String a_consensusId, int a_messageType, java.lang.String a_initiatorsId, java.lang.String p_proposal, java.lang.String lastCommonRandom)
          Creates a new message.
 
Method Summary
protected abstract  void appendCustomNodes(org.w3c.dom.Document a_doc, org.w3c.dom.Node a_rootElem)
          Subclasses can add some extra nodes into the xml representation of this message by implementing this method
private  java.lang.String createConsensusId()
          Creates a unique id for this broadcast
 java.lang.String getConsensusId()
          Returns the unique id of the consensus this message belongs to
 java.lang.String getHashKey()
          Returns a hash key for the message
 java.lang.String getId()
          Returns a ID for this information.
 java.lang.String getInitiatorsId()
          Returns the initiators id
 java.lang.String getLastCommonRandom()
          Returns the last common random used as a round number
 int getMessageType()
          Returns the type of this message.
 byte[] getPostData()
          Returns the data to post to the other infoservice.
 int getPostEncoding()
          Returns the content encoding of the post data.
 java.lang.String getPostFile()
          Returns the filename (InfoService command) to which the data of this entry is posted at the other infoservice.
 java.lang.String getProposal()
          Returns the proposal
 java.lang.String getSenderId()
          Returns the senders id
 boolean isSignatureOK()
          Indicates if the signature of this message has been correct
 void setConsensusId(java.lang.String a_id)
          Sets the consensusId
 void setLastCommonRandom(java.lang.String lcr)
          Sets the round number.
 void setProposal(java.lang.String a_proposal)
          Sets the proposal
 void setSignatureOk(boolean a_ok)
          Sets if the signature of this message has been ok
 void setXmlDocument(org.w3c.dom.Document a_node)
          Sets an XML representation of this message
 java.lang.String toString()
          Returns a string representation of this message
 org.w3c.dom.Document toXML()
          Creates an XML representation of this message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_lastCommonRandom

protected java.lang.String m_lastCommonRandom

m_consensusId

protected java.lang.String m_consensusId

m_initiatorsId

protected java.lang.String m_initiatorsId

m_messageType

protected int m_messageType

m_proposal

protected java.lang.String m_proposal

m_senderId

protected java.lang.String m_senderId

m_signatureOk

protected boolean m_signatureOk

m_xmlNode

protected org.w3c.dom.Document m_xmlNode

m_compressedData

private byte[] m_compressedData
Constructor Detail

AMessage

protected AMessage(java.lang.String a_consensusId,
                   int a_messageType,
                   java.lang.String a_initiatorsId,
                   java.lang.String p_proposal,
                   java.lang.String lastCommonRandom)
Creates a new message. This constructor is used by the subclasses of AMessage

Parameters:
a_consensusId - The unique id of the consensus this message belongs to
a_messageType - The type of the message (see AgreementMessageTypes)
a_initiatorsId - The id of the initiator if the consensus
p_proposal - The proposal (i.e. broadcasted message)
m_lastCommonRandom - The last commonly known random number as a round identifier
Method Detail

appendCustomNodes

protected abstract void appendCustomNodes(org.w3c.dom.Document a_doc,
                                          org.w3c.dom.Node a_rootElem)
Subclasses can add some extra nodes into the xml representation of this message by implementing this method

Parameters:
a_doc - The owner document
a_rootElem - The node to which the extra nodes should be added

createConsensusId

private java.lang.String createConsensusId()
Creates a unique id for this broadcast

Returns:
The id for the broadcast

getConsensusId

public java.lang.String getConsensusId()
Description copied from interface: IAgreementMessage
Returns the unique id of the consensus this message belongs to

Specified by:
getConsensusId in interface IAgreementMessage
Returns:
The unique id of the consensus this message belongs to

getHashKey

public java.lang.String getHashKey()
Returns a hash key for the message

Specified by:
getHashKey in interface IAgreementMessage
Returns:
The hash key

getId

public java.lang.String getId()
Description copied from interface: IDistributable
Returns a ID for this information. It is used as an identifier for logging status information.

Specified by:
getId in interface IDistributable
Returns:
The ID of this information.

getInitiatorsId

public java.lang.String getInitiatorsId()
Returns the initiators id

Returns:
The initiators id

getLastCommonRandom

public java.lang.String getLastCommonRandom()
Returns the last common random used as a round number

Returns:
The last common random

getMessageType

public int getMessageType()
Description copied from interface: IAgreementMessage
Returns the type of this message.

Specified by:
getMessageType in interface IAgreementMessage
Returns:
The type of this message
See Also:
AgreementMessageTypes

getPostData

public byte[] getPostData()
Description copied from interface: IDistributable
Returns the data to post to the other infoservice. In general this should be an XML structure with the data of this entry.

Specified by:
getPostData in interface IDistributable
Returns:
The data to post to the other infoservice when this entry is forwarded.

getPostFile

public java.lang.String getPostFile()
Description copied from interface: IDistributable
Returns the filename (InfoService command) to which the data of this entry is posted at the other infoservice.

Specified by:
getPostFile in interface IDistributable
Returns:
The filename, where the data is posted when this entry is forwarded.

getPostEncoding

public int getPostEncoding()
Description copied from interface: IDistributable
Returns the content encoding of the post data.

Specified by:
getPostEncoding in interface IDistributable
Returns:
the content encoding of the post data

getProposal

public java.lang.String getProposal()
Returns the proposal

Returns:
The proposal

getSenderId

public java.lang.String getSenderId()
Returns the senders id

Returns:
The senders id

isSignatureOK

public boolean isSignatureOK()
Description copied from interface: IAgreementMessage
Indicates if the signature of this message has been correct

Specified by:
isSignatureOK in interface IAgreementMessage
Returns:
true if the signature has been correct, false otherwise

setConsensusId

public void setConsensusId(java.lang.String a_id)
Sets the consensusId

Parameters:
a_id -

setProposal

public void setProposal(java.lang.String a_proposal)
Sets the proposal

Parameters:
a_proposal - The proposal

setSignatureOk

public void setSignatureOk(boolean a_ok)
Description copied from interface: IAgreementMessage
Sets if the signature of this message has been ok

Specified by:
setSignatureOk in interface IAgreementMessage

setXmlDocument

public void setXmlDocument(org.w3c.dom.Document a_node)
Description copied from interface: IAgreementMessage
Sets an XML representation of this message

Specified by:
setXmlDocument in interface IAgreementMessage

toString

public java.lang.String toString()
Returns a string representation of this message

Overrides:
toString in class java.lang.Object
Returns:
The string represenation.

toXML

public org.w3c.dom.Document toXML()
Description copied from interface: IAgreementMessage
Creates an XML representation of this message.

Specified by:
toXML in interface IAgreementMessage
Returns:
The Docunment:

setLastCommonRandom

public void setLastCommonRandom(java.lang.String lcr)
Description copied from interface: IAgreementMessage
Sets the round number. This is for simulation purposes only (I think...)

Specified by:
setLastCommonRandom in interface IAgreementMessage