public class Learner extends ElectionAgentThread
| Modifier and Type | Class and Description |
|---|---|
static interface |
Learner.Listener |
Thread.State, Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
static String |
SERVICE_NAME |
channelQueue, formatter, logger, protocolenvImplMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
Learner(Protocol protocol,
ServiceDispatcher serviceDispatcher)
Creates an instance of a Learner which will listen for election results
to propagate to local listeners, and for requests asking for election
results.
|
Learner(RepImpl repImpl,
Protocol protocol,
ServiceDispatcher serviceDispatcher) |
| Modifier and Type | Method and Description |
|---|---|
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, in parallel, to determine whether they know of
an existing master in the group.
|
void |
reinformLearners(Set<InetSocketAddress> learners,
ExecutorService threadPool)
A method to re-broadcast this Learner's notion of the master.
|
void |
run()
The main Learner loop.
|
initiateSoftShutdown, shutdowncleanup, getSavedShutdownException, getTotalCpuTime, getTotalUserTime, handleUncaughtException, isShutdown, saveShutdownException, shutdownDone, shutdownThreadactiveCount, checkAccess, clone, 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, yieldpublic static final String SERVICE_NAME
public Learner(Protocol protocol, ServiceDispatcher serviceDispatcher)
Note that this constructor does not take a repNode as an argument, so that it can be used as the basis for the standalone Monitor.
protocol - the protocol used for message exchangeserviceDispatcher - the service dispatcher used by the agentpublic Learner(RepImpl repImpl, Protocol protocol, ServiceDispatcher serviceDispatcher)
public void addListener(Learner.Listener listener)
listener - the new listener to be addedpublic void processResult(Proposer.Proposal proposal, Protocol.Value value)
proposal - the winning proposalvalue - the winning valuepublic void run()
public void queryForMaster(Set<InetSocketAddress> learnerSockets)
processResult(com.sleepycat.je.rep.elections.Proposer.Proposal, com.sleepycat.je.rep.elections.Protocol.Value) as though it were an election
result that was sent to the Learner, resulting in the node transitioning
to the master or replica state as appropriate.
Note that this node itself is not allowed to become a master as a result of such a query. It must only do so via an election.
learnerSockets - the sockets associated with learners at other
nodes. The nodes are queried on these sockets.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 messagesUnknownMasterException - 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 ElectionAgentThreadStoppableThread.getLogger()Copyright © 2024. All rights reserved.