|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
com.sleepycat.je.utilint.StoppableThread
com.sleepycat.je.rep.elections.ElectionAgentThread
com.sleepycat.je.rep.elections.Learner
public class Learner
The Learner agent. It runs in its own dedicated thread, listening for messages announcing the results of elections. The Learner in turn invokes Listeners within the process to propagate the result.
Nested Class Summary | |
---|---|
static interface |
Learner.Listener
|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
static String |
SERVICE_NAME
|
Fields inherited from class com.sleepycat.je.rep.elections.ElectionAgentThread |
---|
channelQueue, formatter, logger, protocol |
Fields inherited from class com.sleepycat.je.utilint.StoppableThread |
---|
envImpl |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
Learner(Protocol protocol,
RepNode repNode)
|
|
Learner(Protocol protocol,
ServiceDispatcher serviceDispatcher,
NameIdPair nameIdPair)
Creates an instance of a Learner which will listen for and propagate messages to local Listeners. |
Method Summary | |
---|---|
void |
addListener(Learner.Listener listener)
Adds a Listener to the existing set of listeners, so that it can be informed of the outcome of election results. |
static MasterValue |
findMaster(Protocol protocol,
Set<InetSocketAddress> learnerSockets,
Logger logger,
RepImpl repImpl,
Formatter formatter)
Returns the socket address for the current master, or null if one could not be determined from the available set of learners. |
protected Logger |
getLogger()
|
static void |
informLearners(Set<InetSocketAddress> learners,
Proposer.WinningProposal winningProposal,
Protocol protocol,
ExecutorService threadPool,
Logger logger,
RepImpl repImpl,
Formatter formatter)
A utility method used to broadcast the results of an election to Listeners. |
void |
processResult(Proposer.Proposal proposal,
Protocol.Value value)
Processes a result message |
void |
queryForMaster(Set<InetSocketAddress> learnerSockets)
Queries other learners to determine whether they know of a master in the group. |
void |
reinformLearners(Set<InetSocketAddress> learners,
ExecutorService threadPool)
A method to re-broadcast this Learner's notion of the master. |
(package private) void |
removeListener(Learner.Listener listener)
Removes a Listeners from the existing set of listeners. |
void |
run()
The main Learner loop. |
Methods inherited from class com.sleepycat.je.rep.elections.ElectionAgentThread |
---|
initiateSoftShutdown, shutdown |
Methods inherited from class com.sleepycat.je.utilint.StoppableThread |
---|
cleanup, getSavedShutdownException, getTotalCpuTime, getTotalUserTime, isShutdown, saveShutdownException, setExceptionListener, shutdownDone, shutdownThread |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String SERVICE_NAME
Constructor Detail |
---|
public Learner(Protocol protocol, ServiceDispatcher serviceDispatcher, NameIdPair nameIdPair) throws IOException
protocol
- the protocol used for message exchange.nameIdPair
- a unique identifier for this election module
IOException
- if the listener socket could not be established.public Learner(Protocol protocol, RepNode repNode)
Method Detail |
---|
public void addListener(Learner.Listener listener)
listener
- the new listener to be addedvoid removeListener(Learner.Listener listener)
listener
- the listener to be removed.public void processResult(Proposer.Proposal proposal, Protocol.Value value)
proposal
- the winning proposalvalue
- the winning valuepublic void run()
run
in interface Runnable
run
in class Thread
public void queryForMaster(Set<InetSocketAddress> learnerSockets)
learnerSockets
- public static MasterValue findMaster(Protocol protocol, Set<InetSocketAddress> learnerSockets, Logger logger, RepImpl repImpl, Formatter formatter) throws UnknownMasterException
protocol
- the protocol to be used when determining the masterlearnerSockets
- the learner to be queried for the masterlogger
- for log messages
UnknownMasterException
- if no master could be establishedpublic void reinformLearners(Set<InetSocketAddress> learners, ExecutorService threadPool)
learners
- the learners that must be informedthreadPool
- the pool used to dispatch broadcast requests in
in parallelpublic static void informLearners(Set<InetSocketAddress> learners, Proposer.WinningProposal winningProposal, Protocol protocol, ExecutorService threadPool, Logger logger, RepImpl repImpl, Formatter formatter)
learners
- that need to be informed.winningProposal
- the result that needs to be propagatedprotocol
- to be used for communicationthreadPool
- used to supply threads for the broadcastprotected Logger getLogger()
getLogger
in class ElectionAgentThread
StoppableThread.getLogger()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |