|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.util.AbstractService
com.sun.sgs.impl.service.watchdog.WatchdogServerImpl
public final class WatchdogServerImpl
The WatchdogServer implementation.
The constructor supports the following
properties:
com.sun.sgs.impl.service.watchdog.server.port
44533
0 and no greater
than 65535. If the value specified is 0, then an
anonymous port will be chosen. The value chosen will be logged, and
can also be accessed with the getPort method.
com.sun.sgs.impl.service.watchdog.server.renew.interval
1000 (one second)renewNode method). The interval must be greater
than or equal to 5 milliseconds and less than or equal to
10000 milliseconds (10 seconds).
com.sun.sgs.impl.service.watchdog.server.timeflush.interval
5000 (five seconds)
100 milliseconds and
less than or equal to 300000 milliseconds.
Note that this server caches NodeImpls outside the data service to maintain state.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.sun.sgs.impl.util.AbstractService |
|---|
AbstractService.State, AbstractService.Version |
| Field Summary | |
|---|---|
(package private) static int |
DEFAULT_PORT
The default value of the server port. |
(package private) SortedSet<NodeImpl> |
expirationSet
The set of alive nodes, sorted by renew expiration time. |
(package private) long |
localNodeId
The node ID for this server. |
(package private) Object |
notifyClientsLock
The lock for notifying the NotifyClientsThread. |
(package private) static String |
PORT_PROPERTY
The property name for the server port. |
(package private) long |
renewInterval
The renew interval. |
(package private) Queue<NodeImpl> |
statusChangedNodes
The queue of nodes whose status has changed. |
(package private) long |
timeflushInterval
The timeflush interval. |
(package private) static String |
WATCHDOG_SERVER_NAME
The server name in the registry. |
| Fields inherited from class com.sun.sgs.impl.util.AbstractService |
|---|
appName, dataService, IO_TASK_PROPERTY_PREFIX, IO_TASK_RETRIES_PROPERTY, IO_TASK_WAIT_TIME_PROPERTY, maxIoAttempts, retryWaitTime, taskOwner, taskScheduler, transactionScheduler, txnProxy |
| Constructor Summary | |
|---|---|
WatchdogServerImpl(Properties properties,
ComponentRegistry systemRegistry,
TransactionProxy txnProxy,
String host,
WatchdogClient client,
boolean fullStack)
Constructs an instance of this class with the specified properties. |
|
| Method Summary | |
|---|---|
long |
currentAppTimeMillis()
Returns the global application time in milliseconds as it is maintained by the central node. |
protected void |
doReady()
Performs ready operations. |
protected void |
doShutdown()
Performs shutdown operations. |
int |
getPort()
Returns the port being used for this server. |
(package private) long |
getTimeOffset()
Returns the offset being used by this server to report global application time with the currentAppTimeMillis() method. |
protected void |
handleServiceVersionMismatch(AbstractService.Version oldVersion,
AbstractService.Version currentVersion)
Handles conversion from the oldVersion to the currentVersion. |
(package private) Collection<NodeImpl> |
processNodeFailures(Collection<NodeImpl> nodesToFail)
Processes the nodes which have failed by calling the failure methods for each node in the collection. |
void |
recoveredNode(long nodeId,
long backupId)
Notifies this watchdog that the node with the specified nodeId has been recovered by the node with the specified
backupId. |
long |
registerNode(long nodeId,
String host,
WatchdogClient client,
int jmxPort)
Registers a node with the corresponding nodeId, host,
and client, and returns the interval (in milliseconds) that this
watchdog must be notified, via the renewNode method,
in order for the specified node to be considered alive. |
boolean |
renewNode(long nodeId)
Notifies this watchdog that the node with the specified nodeId is alive. |
void |
setNodeHealth(long nodeId,
boolean isLocal,
Node.Health health,
String component,
int maxNumberOfAttempts)
Notifies the node with the given ID that its health has been set. |
| Methods inherited from class com.sun.sgs.impl.util.AbstractService |
|---|
callFinished, callStarted, checkNonTransactionalContext, checkServiceVersion, createTaskQueue, getDataService, getName, getState, isAlive, isInInitializedState, isRetryableException, ready, runIoTask, shutdown, shuttingDown |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final String WATCHDOG_SERVER_NAME
static final String PORT_PROPERTY
static final int DEFAULT_PORT
final long renewInterval
final long timeflushInterval
final long localNodeId
final Object notifyClientsLock
NotifyClientsThread.
final Queue<NodeImpl> statusChangedNodes
final SortedSet<NodeImpl> expirationSet
| Constructor Detail |
|---|
public WatchdogServerImpl(Properties properties,
ComponentRegistry systemRegistry,
TransactionProxy txnProxy,
String host,
WatchdogClient client,
boolean fullStack)
throws Exception
class documentation for a list
of supported properties.
properties - server propertiessystemRegistry - the system registrytxnProxy - the transaction proxyhost - the local host nameclient - the local watchdog clientfullStack - true if this server is running on a full
stack
Exception - if there is a problem starting the server| Method Detail |
|---|
protected void handleServiceVersionMismatch(AbstractService.Version oldVersion,
AbstractService.Version currentVersion)
oldVersion to the currentVersion. This method is invoked by checkServiceVersion if a version mismatch is detected and is invoked
from within a transaction.
handleServiceVersionMismatch in class AbstractServiceoldVersion - the old versioncurrentVersion - the current version
protected void doReady()
throws Exception
ready method only once so that the subclass can
perform any operations necessary during the "ready" phase.
doReady in class AbstractServiceException - if a problem occursprotected void doShutdown()
shutdown method only once so that the
subclass can perform any operations necessary to shutdown the
service.
doShutdown in class AbstractService
public long registerNode(long nodeId,
String host,
WatchdogClient client,
int jmxPort)
throws NodeRegistrationFailedException
nodeId, host,
and client, and returns the interval (in milliseconds) that this
watchdog must be notified, via the renewNode method,
in order for the specified node to be considered alive.
If this method throws NodeRegistrationFailedException,
the caller should not retry as this indicates a fatal error.
When a node fails or a new node starts, the given client will be notified of these status changes via its nodeStatusChanges method.
registerNode in interface WatchdogServernodeId - the node ID of the nodehost - a host nameclient - a watchdog clientjmxPort - the port JMX is listening on, or -1 if JMX is not
enabled for remote listening on the node
NodeRegistrationFailedException - if there is a problem
registering the nodepublic boolean renewNode(long nodeId)
nodeId is alive. This method returns true if this
watchdog still considers the node alive, and returns false otherwise. This watchdog considers the node to have
failed if a renew request is not received from the node before
the assigned interval, returned from registerNode, expires. If this method returns false
for a given nodeId, the caller should not retry this
method because the node is considered to have failed.
renewNode in interface WatchdogServernodeId - a node ID
true if the node is considered alive,
false otherwise
public void recoveredNode(long nodeId,
long backupId)
nodeId has been recovered by the node with the specified
backupId.
recoveredNode in interface WatchdogServernodeId - the recovered node's IDbackupId - the backup node's ID
public void setNodeHealth(long nodeId,
boolean isLocal,
Node.Health health,
String component,
int maxNumberOfAttempts)
health is RED it indicates that the
node has failed and should be shutdown. In this case, if the given node
is a remote node, this notification is a
result of a server running into difficulty communicating with a remote
node, so the server's watchdog service is responsible for notifying the
watchdog service in order to issue the shutdown. The component
parameter may be any identifying string, but is typically the class
name of the component that reported the specified health.
setNodeHealth in interface WatchdogServernodeId - the node's IDisLocal - specifies if the node is reporting health on itself or
a remote nodehealth - the node's healthcomponent - the component reported the specified healthmaxNumberOfAttempts - the maximum number of attempts to try and
resolve an IOExceptionpublic long currentAppTimeMillis()
initialize method
was called on the application's AppListener object.
Note: Since this method is typically called as part of a Remote
interface, appropriate measures should be taken to account for possible
network latency.
currentAppTimeMillis in interface WatchdogServerlong getTimeOffset()
currentAppTimeMillis() method.
Collection<NodeImpl> processNodeFailures(Collection<NodeImpl> nodesToFail)
nodesToFail - the collection of failed nodes
nodesToFail that were marked as failed from
this methodpublic int getPort()
|
RedDwarf, Version 0.10.1 2010-03-14 10:56:12 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||