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

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

public final class FeederManager
extends Object

FeedManager is responsible for the creation and management of the Feeders used to respond to connections initiated by a Replica. runfeeders() is the central loop that listens for replica connections and manages the lifecycle of individual Feeders. It's re-entered each time the node becomes a Master and is exited when its status changes. There is a single instance of FeederManager that is created for a replication node. There are many instances of Feeders per FeederManager. Each Feeder instance represents an instance of a connection between the node serving as the feeder and the replica. Note that the FeederManager and the Replica currently reuse the Replication node's thread of control. When we implement r2r we will need to revisit the thread management to provide for concurrent operation of the FeederManger and the Replica.


Field Summary
static String FEEDER_SERVICE
           
static int MASTER_CHANGE_CHECK_TIMEOUT
           
(package private)  AtomicBoolean shutdown
           
 
Constructor Summary
FeederManager(RepNode repNode)
           
 
Method Summary
(package private)  void activateFeeder(Feeder feeder)
          Transitions a Feeder to being active, so that it can be used in considerations relating to commit acknowledgments.
 int activeReplicaCount()
          The numbers of Replicas currently "active" with this feeder.
 Set<String> activeReplicas()
          Returns the set of Replicas that are currently active with this feeder.
 Map<String,Feeder> activeReplicasMap()
           
 String dumpState()
           
 void ensureReplicasForCommit(MasterTxn txn, Durability.ReplicaAckPolicy ackPolicy, int requiredReplicaCount, int insufficientReplicasTimeout)
          Ensures that the required number of replicas are active if the node is currently the master.
 Feeder getFeeder(String nodeName)
          Returns the Feeder associated with the node, if such a feeder is currently active.
 StatGroup getFeederManagerStats(StatsConfig config)
          Returns the statistics associated with the FeederManager.
 LongMaxZeroStat getnMaxReplicaLag()
           
 StringStat getnMaxReplicaLagName()
           
 int getNumCurrentAckFeeders(VLSN commitVLSN)
          Returns a count of the number of feeders whose replicas have acknowledged txn-end VLSNs >= the commitVLSN argument.
 StatGroup getProtocolStats(StatsConfig config)
           
 int getTestDelayMs()
           
(package private)  void incStats(StatGroup feederStats)
          Accumulates statistics from a terminating feeder.
 Feeder putFeeder(String nodeName, Feeder feeder)
           
(package private)  void removeFeeder(Feeder feeder)
          Remove the feeder from the sets used to track it.
(package private)  RepNode repNode()
          Returns the RepNode associated with the FeederManager
 void resetStats()
           
(package private)  void runFeeders()
          The core feeder listener loop that is run either in a Master node, or in a Replica that is serving as a Feeder to other Replica nodes.
(package private)  void setRepNodeShutdownException(RuntimeException rNSE)
           
 void setTestDelayMs(int testDelayMs)
           
 void shutdownFeeder(RepNodeImpl node)
          Shuts down a specific feeder.
(package private)  void shutdownQueue()
          Clears and shuts down the runFeeders by inserting a special EOF marker value into the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shutdown

AtomicBoolean shutdown

MASTER_CHANGE_CHECK_TIMEOUT

public static final int MASTER_CHANGE_CHECK_TIMEOUT
See Also:
Constant Field Values

FEEDER_SERVICE

public static final String FEEDER_SERVICE
See Also:
Constant Field Values
Constructor Detail

FeederManager

FeederManager(RepNode repNode)
Method Detail

getFeederManagerStats

public StatGroup getFeederManagerStats(StatsConfig config)
Returns the statistics associated with the FeederManager.

Returns:
the statistics

getProtocolStats

public StatGroup getProtocolStats(StatsConfig config)

resetStats

public void resetStats()

incStats

void incStats(StatGroup feederStats)
Accumulates statistics from a terminating feeder.

Parameters:
stats -

getTestDelayMs

public int getTestDelayMs()

setTestDelayMs

public void setTestDelayMs(int testDelayMs)

repNode

RepNode repNode()
Returns the RepNode associated with the FeederManager

Returns:

getFeeder

public Feeder getFeeder(String nodeName)
Returns the Feeder associated with the node, if such a feeder is currently active.


putFeeder

public Feeder putFeeder(String nodeName,
                        Feeder feeder)

getnMaxReplicaLag

public LongMaxZeroStat getnMaxReplicaLag()

getnMaxReplicaLagName

public StringStat getnMaxReplicaLagName()

setRepNodeShutdownException

void setRepNodeShutdownException(RuntimeException rNSE)

activeReplicaCount

public int activeReplicaCount()
The numbers of Replicas currently "active" with this feeder. Active currently means they are connected. It does not make any guarantees about where they are in the replication stream. They may, for example, be too far behind to participate in timely acks.

Returns:
the active replica count

activeReplicas

public Set<String> activeReplicas()
Returns the set of Replicas that are currently active with this feeder. A replica is active if it has completed the handshake sequence.

Returns:
the set of replica node IDs.

activeReplicasMap

public Map<String,Feeder> activeReplicasMap()

activateFeeder

void activateFeeder(Feeder feeder)
              throws InterruptedException
Transitions a Feeder to being active, so that it can be used in considerations relating to commit acknowledgments.

Parameters:
feeder - the feeder being transitioned.
Throws:
DuplicateReplicaException - if the Feeder is already active.
InterruptedException

removeFeeder

void removeFeeder(Feeder feeder)
Remove the feeder from the sets used to track it. Invoked when a feeder is shutdown.

Parameters:
feeder -

shutdownQueue

void shutdownQueue()
Clears and shuts down the runFeeders by inserting a special EOF marker value into the queue.


runFeeders

void runFeeders()
          throws DatabaseException
The core feeder listener loop that is run either in a Master node, or in a Replica that is serving as a Feeder to other Replica nodes. The core loop accepts connections from Replicas as they come in and establishes a Feeder on that connection. The loop can be terminated for one of the following reasons: 1) A change in Masters. 2) A forced shutdown, via a thread interrupt. 3) A server socket level exception. The timeout on the accept is used to ensure that the check is done at least once per timeout period.

Throws:
DatabaseException

shutdownFeeder

public void shutdownFeeder(RepNodeImpl node)
Shuts down a specific feeder. It's typically done in response to the removal of a member from the group.


ensureReplicasForCommit

public void ensureReplicasForCommit(MasterTxn txn,
                                    Durability.ReplicaAckPolicy ackPolicy,
                                    int requiredReplicaCount,
                                    int insufficientReplicasTimeout)
                             throws InterruptedException,
                                    DatabaseException
Ensures that the required number of replicas are active if the node is currently the master. If the node is not the master it simply returns.

Parameters:
requiredReplicaCount - the total nodes required by the transaction
insufficientReplicasTimeout - the amount of time (in ms) that the Feeder will wait for the requiredReplicaCount
Throws:
InterruptedException
DatabaseException - if the wait timed out.

dumpState

public String dumpState()

getNumCurrentAckFeeders

public int getNumCurrentAckFeeders(VLSN commitVLSN)
Returns a count of the number of feeders whose replicas have acknowledged txn-end VLSNs >= the commitVLSN argument.

Parameters:
commitVLSN - the commitVLSN being checked


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