com.sleepycat.je.rep.impl.node
Class CommitFreezeLatch

java.lang.Object
  extended by com.sleepycat.je.rep.impl.node.CommitFreezeLatch

public class CommitFreezeLatch
extends Object

Ensures that a VLSN is not advanced at this node while an election is in progress. Note that this is difficult, if not impossible to achieve efficiently in a distributed environment across the entire group, when communications may not always be reliable. So, the implementation really represents a good faith effort to freeze the VLSN. JE HA itself should be able to make forward progress in the event of such a failure. The class coordinates three threads: the acceptor, the learner, and the replay thread. There is exactly one instance of each thread per replication node, so it coordinates the activity of these three threads. The typical serialized sequence of calls is therefore: latch.freeze() -- invoked in response to a Promise by an Acceptor latch.vlsnEvent() -- one or more of them in response to ongoing election latch.awaitThaw() -- by the replica thread waiting for the freeze to lift Both vlsnEvent() and awaitThaw() are NOPs in the absence of a freeze.

See Also:
Freezing VLSNs

Constructor Summary
CommitFreezeLatch()
           
 
Method Summary
 boolean awaitThaw()
          Used to wait for an event that unfreezes the VLSN.
 void clearLatch()
          Clears the latch freeing any waiters.
 void freeze(Proposer.Proposal freezeProposal)
          Initiates or extends a freeze on a VLSN in response to a new election that is in progress.
 int getAwaitElectionCount()
           
 int getAwaitTimeoutCount()
           
 int getFreezeCount()
           
 long getTimeOut()
           
 void setTimeOut(long timeOut)
           
 void vlsnEvent(Proposer.Proposal listenerProposal)
          Invoked by the Learner thread whenever it receives an election result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommitFreezeLatch

public CommitFreezeLatch()
Method Detail

getAwaitTimeoutCount

public int getAwaitTimeoutCount()

getAwaitElectionCount

public int getAwaitElectionCount()

getFreezeCount

public int getFreezeCount()

getTimeOut

public long getTimeOut()

setTimeOut

public void setTimeOut(long timeOut)

freeze

public void freeze(Proposer.Proposal freezeProposal)
Initiates or extends a freeze on a VLSN in response to a new election that is in progress. It's invoked by the Acceptor thread.

Parameters:
freezeProposal - identifies the election that is provoking the freeze

vlsnEvent

public void vlsnEvent(Proposer.Proposal listenerProposal)
Invoked by the Learner thread whenever it receives an election result. The freeze on the VLSN is only lifted if the proposal associated with the event is current, that is, it represents a proposal that is newer than the one used to establish the freeze.

Parameters:
listenerProposal - identifies the election that just concluded

clearLatch

public void clearLatch()
Clears the latch freeing any waiters.


awaitThaw

public boolean awaitThaw()
                  throws InterruptedException
Used to wait for an event that unfreezes the VLSN. In our case this event is a message to the Learner agent announcing the result of an election. Note that the latch must be re-initialized after a return from this await method. This method is invoked by the Replay thread. Completion of an awaitThaw always results in the freeze being lifted.

Returns:
true if the await was satisfied due to completion of an election, false if no freeze was in effect, or the latch was timed out.
Throws:
InterruptedException


Copyright (c) 2004-2012 Oracle. All rights reserved.