infoservice.agreement.paxos.integration
Class PaxosAdapter

java.lang.Object
  extended by infoservice.agreement.paxos.PaxosObject
      extended by infoservice.agreement.paxos.PaxosCommunicator
          extended by infoservice.agreement.paxos.PaxosProposer
              extended by infoservice.agreement.paxos.PaxosAcceptor
                  extended by infoservice.agreement.paxos.integration.PaxosAdapter
All Implemented Interfaces:
TimeoutListener
Direct Known Subclasses:
InfoServicePaxosAdapter

public abstract class PaxosAdapter
extends PaxosAcceptor


Nested Class Summary
(package private)  class PaxosAdapter.AgreementStarterThread
          The AgreementStarterThread looks from time to time if the next agreement has to be startet.
 
Field Summary
protected  java.util.Hashtable m_commitments
           
protected  int m_currentState
           
protected  Commitment m_ownCommitment
           
protected  java.util.Vector m_passivelyReceivedMessages
           
protected  java.util.Vector m_potentialyCorrectMessage
           
(package private)  PaxosAdapter.AgreementStarterThread m_starterThread
           
private static int STATE_COMMITMENT
           
private static int STATE_INACTIVE
           
private static int STATE_PASSIVE
           
private static int STATE_PHASE_GAP
           
private static int STATE_REVEAL
           
 
Fields inherited from class infoservice.agreement.paxos.PaxosAcceptor
m_paxosInstances
 
Fields inherited from class infoservice.agreement.paxos.PaxosProposer
m_lastRandom
 
Fields inherited from class infoservice.agreement.paxos.PaxosCommunicator
m_targets
 
Constructor Summary
protected PaxosAdapter()
          Creates a new PaxosAdapter and starts the AgreementStarterThread for starting agreement at a specific time
 
Method Summary
private  void babylonianConfusion()
          If something went terribly wrong, this gets called.
 void handleIncommingMessage(PaxosMessage a_msg)
          Handles an incomming message.
 void handleMessage(PaxosMessage a_msg)
          Handles the message by passing it to the underlying PaxosAcceptor
protected  void notifyAgreement(java.util.Hashtable a_agreements)
          This gets called when an agreement has been reached, i.e.
 void notifyReject(java.lang.String a_newRound)
          Callback for the RejectManager.
protected abstract  void prepareTargets()
           
protected  boolean roundNrAcceptable(PaxosMessage a_msg)
          Tests if the PaxosInstance-identifier in this messages is acceptable, i.e.
protected  boolean senderNotInSnapshot(PaxosMessage a_msg)
          Tests if the sender of this message is in the snapshot for the current PaxosInstance.
protected  void sendReject(PaxosMessage a_msg)
          Sends a RejectMessage to the sender of the given message.
 void startAgreement()
          Starts the protocol by proposing a value to the others
 void startPassivePhase()
          Starts the passive phase of the protocol.
 void startProtocolByOperator()
          Manually start an agreement
 void startRound()
          Starts a PaxosExection for all known IPaxosTargets so that timeouts are synchronized
protected abstract  void useAgreement(long a_agreement)
          What shall we do with an agreement? You can define it here
 
Methods inherited from class infoservice.agreement.paxos.PaxosAcceptor
addMessage, getPaxosInstance, getRoundLeaders, timeout
 
Methods inherited from class infoservice.agreement.paxos.PaxosProposer
propose, setRound
 
Methods inherited from class infoservice.agreement.paxos.PaxosCommunicator
getF, getIdentifier, getN, getQuorumDecideStrong, getQuorumDecideWeak, getQuorumStrong, getQuorumTwoThird, getTargets, multicast, sendMessage, sendMessage, setTargets
 
Methods inherited from class infoservice.agreement.paxos.PaxosObject
debug, error, fatal, getLog, info, setLog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_INACTIVE

private static final int STATE_INACTIVE
See Also:
Constant Field Values

STATE_PASSIVE

private static final int STATE_PASSIVE
See Also:
Constant Field Values

STATE_COMMITMENT

private static final int STATE_COMMITMENT
See Also:
Constant Field Values

STATE_PHASE_GAP

private static final int STATE_PHASE_GAP
See Also:
Constant Field Values

STATE_REVEAL

private static final int STATE_REVEAL
See Also:
Constant Field Values

m_commitments

protected java.util.Hashtable m_commitments

m_ownCommitment

protected Commitment m_ownCommitment

m_passivelyReceivedMessages

protected java.util.Vector m_passivelyReceivedMessages

m_potentialyCorrectMessage

protected java.util.Vector m_potentialyCorrectMessage

m_starterThread

PaxosAdapter.AgreementStarterThread m_starterThread

m_currentState

protected int m_currentState
Constructor Detail

PaxosAdapter

protected PaxosAdapter()
Creates a new PaxosAdapter and starts the AgreementStarterThread for starting agreement at a specific time

Method Detail

prepareTargets

protected abstract void prepareTargets()

startProtocolByOperator

public void startProtocolByOperator()
Manually start an agreement


startAgreement

public void startAgreement()
Starts the protocol by proposing a value to the others


startRound

public void startRound()
Starts a PaxosExection for all known IPaxosTargets so that timeouts are synchronized


roundNrAcceptable

protected boolean roundNrAcceptable(PaxosMessage a_msg)
Tests if the PaxosInstance-identifier in this messages is acceptable, i.e. is the same as our own

Parameters:
a_msg - The message to be tested
Returns:
true if the identifier is ok, false otherwise

senderNotInSnapshot

protected boolean senderNotInSnapshot(PaxosMessage a_msg)
Tests if the sender of this message is in the snapshot for the current PaxosInstance.

Parameters:
a_msg - The message whose sender should be checked
Returns:
true if the sender is not in the snapshot, false otherwise

sendReject

protected void sendReject(PaxosMessage a_msg)
Sends a RejectMessage to the sender of the given message. This happens if the PaxosInstance-identifier of the given message doesn't match our own one

Parameters:
a_msg - The message whose sender will receive a RejectMessage

handleIncommingMessage

public void handleIncommingMessage(PaxosMessage a_msg)
Handles an incomming message. A new agreement is startet if none is running and the PaxosIdenifier of the incomming message is correct. otherwise a RejectMessage will be sent

Parameters:
a_msg - The message to be handled

handleMessage

public void handleMessage(PaxosMessage a_msg)
Handles the message by passing it to the underlying PaxosAcceptor

Parameters:
a_msg - The message to be handled

notifyReject

public void notifyReject(java.lang.String a_newRound)
Callback for the RejectManager. If this gets called, our last common random is not correct. All executions with the old identifier will be canceled and a new PaxosInstance with the correct identifier will be started

Parameters:
a_newRound -

babylonianConfusion

private void babylonianConfusion()
If something went terribly wrong, this gets called. Should never happen but who knows ;-)


notifyAgreement

protected void notifyAgreement(java.util.Hashtable a_agreements)
This gets called when an agreement has been reached, i.e. we decided on a value for all known IPaxosTargets. If the currect execution has been a commitment-phase, the corresponding reveal-phase will be started. Otherwise the agreements will be combined and new cascades will be built

Specified by:
notifyAgreement in class PaxosAcceptor
Parameters:
a_agreements - Map of execution-identifier to decission

startPassivePhase

public void startPassivePhase()
Starts the passive phase of the protocol. Incomming messages will be queued and handled when we enter the active phase


useAgreement

protected abstract void useAgreement(long a_agreement)
What shall we do with an agreement? You can define it here

Parameters:
a_agreement -