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

java.lang.Object
  extended by java.lang.Thread
      extended by com.sleepycat.je.utilint.StoppableThread
          extended by com.sleepycat.je.rep.impl.networkRestore.FeederManager
All Implemented Interfaces:
ExceptionListenerUser, Runnable

public class FeederManager
extends StoppableThread

Manages the multiple log file feeders that may be servicing requests from multiple clients requesting log files.


Nested Class Summary
(package private)  class FeederManager.Lease
          Provides the lease mechanism used to maintain a handle to the DbBackup object across Server client disconnects.
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static String FEEDER_SERVICE
           
(package private)  Map<Integer,LogFileFeeder> feeders
           
(package private)  long leaseDuration
           
 int leaseRenewalCount
           
(package private)  Map<Integer,FeederManager.Lease> leases
           
(package private)  Timer leaseTimer
           
(package private)  Logger logger
           
(package private)  NameIdPair nameIdPair
           
(package private)  ServiceDispatcher serviceDispatcher
           
(package private)  AtomicBoolean shutdown
           
(package private)  Map<String,Protocol.FileInfoResp> statResponses
           
 
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
FeederManager(ServiceDispatcher serviceDispatcher, EnvironmentImpl envImpl, NameIdPair nameIdPair)
          Creates a FeederManager but does not start it.
 
Method Summary
 int getActiveFeederCount()
          Returns the number of feeders that are currently active with this node.
(package private)  EnvironmentImpl getEnvImpl()
           
 int getLeaseCount()
          Returns the number of leases that are currently outstanding.
 long getLeaseDuration()
           
 int getLeaseRenewalCount()
          Returns the number of times the lease was actually renewed.
protected  Logger getLogger()
           
protected  int initiateSoftShutdown()
          Threads that use shutdownThread() must define this method.
 void run()
          The dispatcher method that starts up new log file feeders.
 void setLeaseDuration(long leaseDuration)
           
 void 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, 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, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

feeders

final Map<Integer,LogFileFeeder> feeders

leases

final Map<Integer,FeederManager.Lease> leases

statResponses

final Map<String,Protocol.FileInfoResp> statResponses

leaseTimer

final Timer leaseTimer

nameIdPair

final NameIdPair nameIdPair

leaseRenewalCount

public int leaseRenewalCount

leaseDuration

long leaseDuration

serviceDispatcher

final ServiceDispatcher serviceDispatcher

shutdown

final AtomicBoolean shutdown

logger

final Logger logger

FEEDER_SERVICE

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

FeederManager

public FeederManager(ServiceDispatcher serviceDispatcher,
                     EnvironmentImpl envImpl,
                     NameIdPair nameIdPair)
Creates a FeederManager but does not start it.

Parameters:
serviceDispatcher - The service dispatcher with which the FeederManager must register itself. It's null only in a test environment.
nameIdPair - The node name and id associated with the feeder
envImpl - the environment that will provide the log files
Method Detail

getEnvImpl

EnvironmentImpl getEnvImpl()

getLeaseRenewalCount

public int getLeaseRenewalCount()
Returns the number of times the lease was actually renewed.


getLeaseCount

public int getLeaseCount()
Returns the number of leases that are currently outstanding.


getActiveFeederCount

public int getActiveFeederCount()
Returns the number of feeders that are currently active with this node. Note that active leases are included in this count, since it's expected that the clients will try to reconnect.


getLeaseDuration

public long getLeaseDuration()

setLeaseDuration

public void setLeaseDuration(long leaseDuration)

run

public void run()
The dispatcher method that starts up new log file feeders.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

shutdown

public void shutdown()

initiateSoftShutdown

protected int initiateSoftShutdown()
Description copied from class: StoppableThread
Threads that use shutdownThread() must define this method. It's invoked by shutdownThread as an attempt at a soft shutdown. This method makes provisions for this thread to exit on its own. The technique used to make the thread exit can vary based upon the nature of the service being provided by the thread. For example, the thread may be known to poll some shutdown flag on a periodic basis, or it may detect that a channel that it waits on has been closed by this method.

Overrides:
initiateSoftShutdown in class StoppableThread
Returns:
the amount of time in ms that the shutdownThread method will wait for the thread to exit. A -ve value means that the method will not wait. A zero value means it will wait indefinitely.

getLogger

protected Logger getLogger()
Specified by:
getLogger in class StoppableThread
Returns:
a logger to use when logging uncaught exceptions.
See Also:
StoppableThread.getLogger()


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