Package org.jgroups.blocks
Class TwoPhaseVotingAdapter
- java.lang.Object
-
- org.jgroups.blocks.TwoPhaseVotingAdapter
-
public class TwoPhaseVotingAdapter extends java.lang.ObjectThis adapter introduces simple two-phase voting on a specified decree. All nodes in the group receive a decree in "prepare" phase where they expres their opinion on the decree. If all nodes voted positively on decree, next phase "commit" fixes changes that were made in "prepare" phase, otherwise changes are canceled in "abort" phase.- Version:
- $Id: TwoPhaseVotingAdapter.java,v 1.4 2005/06/08 15:56:54 publicnmi Exp $
- Author:
- Roman Rokytskyy (rrokytskyy@acm.org), Robert Schaffar-Taurok (robert@fusion.at)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTwoPhaseVotingAdapter.TwoPhaseVoteWrapperstatic classTwoPhaseVotingAdapter.TwoPhaseWrapperWrapper of the decree to voting decree.
-
Constructor Summary
Constructors Constructor Description TwoPhaseVotingAdapter(VotingAdapter voteChannel)Creats an instance of the class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(TwoPhaseVotingListener listener)Wraps actual listener with the VoteChannelListener and adds to the voteChannelVotingAdaptergetVoteChannel()voidremoveListener(TwoPhaseVotingListener listener)Removes the listener from the voteChannelbooleanvote(java.lang.Object decree, long timeout)Performs the two-phase voting on the decree.booleanvote(java.lang.Object decree, long timeout, VoteResponseProcessor voteResponseProcessor)Performs the two-phase voting on the decree.
-
-
-
Constructor Detail
-
TwoPhaseVotingAdapter
public TwoPhaseVotingAdapter(VotingAdapter voteChannel)
Creats an instance of the class.- Parameters:
voteChannel- the channel that will be used for voting.
-
-
Method Detail
-
addListener
public void addListener(TwoPhaseVotingListener listener)
Wraps actual listener with the VoteChannelListener and adds to the voteChannel
-
removeListener
public void removeListener(TwoPhaseVotingListener listener)
Removes the listener from the voteChannel
-
vote
public boolean vote(java.lang.Object decree, long timeout) throws ChannelExceptionPerforms the two-phase voting on the decree. After the voting each group member remains in the same state as others.- Throws:
ChannelException
-
vote
public boolean vote(java.lang.Object decree, long timeout, VoteResponseProcessor voteResponseProcessor) throws ChannelExceptionPerforms the two-phase voting on the decree. After the voting each group member remains in the same state as others.- Throws:
ChannelException
-
getVoteChannel
public VotingAdapter getVoteChannel()
- Returns:
- Returns the voteChannel.
-
-