|
||||||||||
| 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.WatchdogServiceImpl
public final class WatchdogServiceImpl
The WatchdogService implementation.
The constructor supports the following
properties:
com.sun.sgs.impl.service.watchdog.server.host
com.sun.sgs.server.host
property, if present, or localhost if this node is starting the
server com.sun.sgs.node.type property is not appNode, then this
property's default is used (since the watchdog server to contact will
be the one started on the local host).
com.sun.sgs.impl.service.watchdog.server.port
44533 com.sun.sgs.node.type property is not singleNode, then the
value must be greater than or equal to 0 and no greater than
65535, otherwise the value must be greater than 0,
and no greater than 65535.
com.sun.sgs.impl.service.watchdog.client.host
com.sun.sgs.impl.service.watchdog.client.port
0 (anonymous port) 0 and no greater than
65535.
com.sun.sgs.impl.service.watchdog.timesync.interval
300000 (five minutes) WatchdogServer. The value must be greater than or
equal to 1000 and no greater than Long.MAX_VALUE.
com.sun.management.jmxremote.port
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.sun.sgs.impl.util.AbstractService |
|---|
AbstractService.State, AbstractService.Version |
| Field Summary | |
|---|---|
(package private) WatchdogClient |
clientProxy
The watchdog client proxy. |
(package private) String |
localHost
The name of the local host. |
(package private) Thread |
renewThread
The thread that renews the node with the watchdog server. |
(package private) WatchdogServer |
serverProxy
The watchdog server proxy, or null. |
| 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 | |
|---|---|
WatchdogServiceImpl(Properties properties,
ComponentRegistry systemRegistry,
TransactionProxy txnProxy,
KernelShutdownController ctrl)
Constructs an instance of this class with the specified properties. |
|
| Method Summary | |
|---|---|
void |
addNodeListener(NodeListener listener)
Registers a listener to be notified when any node that
this service monitors starts or fails. |
void |
addRecoveryListener(RecoveryListener listener)
Adds the specified recovery listener for the local
node. |
long |
currentAppTimeMillis()
Returns the current global application time in milliseconds. |
protected void |
doReady()
Performs ready operations. |
protected void |
doShutdown()
Performs shutdown operations. |
long |
getAppTimeMillis(long systemTimeMillis)
Converts a system time value representing the total elapsed time in milliseconds since midnight, January 1, 1970 UTC to an "application time" value. |
Node |
getBackup(long nodeId)
Returns the node that is designated as the backup for the node with the specified nodeId, or null if no backup
is currently designated. |
Node.Health |
getLocalNodeHealth()
Returns the health of the local node. |
Node.Health |
getLocalNodeHealthNonTransactional()
Returns the health of the local node. |
Node |
getNode(long nodeId)
Returns node status information for the node with the specified nodeId, or null if the node is unknown. |
Iterator<Node> |
getNodes()
Returns an iterator for the set of nodes that this service monitors. |
(package private) NodeInfo |
getNodeStatusInfo()
Retrieves information about the current node. |
WatchdogServerImpl |
getServer()
Returns the server. |
long |
getSystemTimeMillis(long appTimeMillis)
Converts an "application time" value representing the total amount of time in milliseconds that the current application has been running since the initialize
method was called on its AppListener object to a system time
value. |
protected void |
handleServiceVersionMismatch(AbstractService.Version oldVersion,
AbstractService.Version currentVersion)
Handles conversion from the oldVersion to the currentVersion. |
boolean |
isLocalNodeAlive()
Returns true if the local node is considered alive,
otherwise returns false. |
boolean |
isLocalNodeAliveNonTransactional()
Returns true if the local node is considered alive,
otherwise returns false. |
void |
reportFailure(long nodeId,
String component)
Informs the watchdog that a problem has occurred in a service or component. |
void |
reportHealth(long nodeId,
Node.Health nodeHealth,
String component)
Informs the watchdog of a node's health. |
void |
reportHealth(Node.Health nodeHealth,
String component)
Informs the watchdog of this node's health. |
| 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 |
| Methods inherited from interface com.sun.sgs.service.Service |
|---|
getName, ready, shutdown |
| Field Detail |
|---|
final WatchdogServer serverProxy
null.
final WatchdogClient clientProxy
final String localHost
final Thread renewThread
| Constructor Detail |
|---|
public WatchdogServiceImpl(Properties properties,
ComponentRegistry systemRegistry,
TransactionProxy txnProxy,
KernelShutdownController ctrl)
throws Exception
class documentation for a list
of supported properties. The Watchdog service is given the ability to
shutdown a node with the KernelShutdownController.
properties - service (and server) propertiessystemRegistry - system registrytxnProxy - transaction proxyctrl - shutdown controller
Exception - if a problem occurs constructing the service/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.
A health update will be sent to listeners.
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 AbstractServicepublic Node.Health getLocalNodeHealth()
getLocalNodeHealth in interface WatchdogServicepublic boolean isLocalNodeAlive()
true if the local node is considered alive,
otherwise returns false. This method should only be
called from within a transaction.
isLocalNodeAlive in interface WatchdogServicetrue if the local node is considered alive, and
false otherwisepublic Node.Health getLocalNodeHealthNonTransactional()
getLocalNodeHealth method. This method may be invoked any time after this service is initialized, whether or not the calling context is inside or outside of a transaction.
getLocalNodeHealthNonTransactional in interface WatchdogServicepublic boolean isLocalNodeAliveNonTransactional()
true if the local node is considered alive,
otherwise returns false. This method returns the most
recent information known to this service and may not be
definitive. For definitive information, use the isLocalNodeAlive method. This method may be invoked any time after this service is initialized, whether or not the calling context is inside or outside of a transaction.
isLocalNodeAliveNonTransactional in interface WatchdogServicetrue if the local node is considered alive, and
false otherwisepublic Iterator<Node> getNodes()
remove operation of the returned
iterator is not supported and will throw UnsupportedOperationException if invoked. This method must
be called within a transaction, and the returned iterator
must only be used within that transaction.
getNodes in interface WatchdogServicepublic Node getNode(long nodeId)
nodeId, or null if the node is unknown. This
method should only be called within a transaction.
getNode in interface WatchdogServicenodeId - a node ID
nodeId,
or nullpublic void addNodeListener(NodeListener listener)
listener to be notified when any node that
this service monitors starts or fails. Registered listeners
are notified outside of a transaction. This method must be invoked outside of a transaction.
addNodeListener in interface WatchdogServicelistener - a node listenerpublic Node getBackup(long nodeId)
nodeId, or null if no backup
is currently designated. This method must be called within a
transaction.
Note: this method should probably be moved to the Node
interface, or it should throw an exception in the case where
there is no existing node corresponding to nodeId.
getBackup in interface WatchdogServicenodeId - a node ID
nullpublic void addRecoveryListener(RecoveryListener listener)
listener for the local
node. If the local node is designated as a backup for a node
that fails, the specified listener will be notified
(outside of a transaction) by having its recover method invoked, passing the
failed node and a SimpleCompletionHandler whose completed method must be invoked
when the recovery operations initiated by the listener are
complete. This method must be invoked outside of a transaction.
addRecoveryListener in interface WatchdogServicelistener - a recovery listener
public void reportFailure(long nodeId,
String component)
nodeId can be the local node or a remote node. The
component parameter may be any identifying string, but is
typically the class name of the component.
Once reportFailure has been called, the health of the
specified node can not be changed.
This method must be invoked outside of a transaction.
reportFailure in interface WatchdogServicenodeId - the id of the node to shutdowncomponent - the name of the component that failed
public void reportHealth(Node.Health nodeHealth,
String component)
component parameter may be
any identifying string, but is typically the class name of the component.
Once reportLocalHealth has been called with a health that returns
false from its Health.isAlive method, the health
of the local node can not be changed.
This method must be invoked outside of a transaction.
reportHealth in interface WatchdogServicenodeHealth - the healthcomponent - the name of the component reporting health
public void reportHealth(long nodeId,
Node.Health nodeHealth,
String component)
nodeId can be
the local node or a remote node. The component parameter may be
any identifying string, but is typically the class name of the component.
Once reportHealth has been called with a health that returns
false from its Health.isAlive method, the health
of the specified node can not be changed.
This method must be invoked outside of a transaction.
reportHealth in interface WatchdogServicenodeId - the id of the nodenodeHealth - the healthcomponent - the name of the component reporting healthpublic long currentAppTimeMillis()
initialize method
was called on the application's AppListener object. Any time
that passes while the application is not running does not affect this
value. This means that this method can effectively be used to
measure the global wall clock time of the current application's
running state.
Note: This method cannot be reliably used to make fine-grained time comparisons across task boundaries. Unpredictable conditions such as network latency mean that the resulting value may be subject to some skew. Additionally, the global accuracy of the clock time may drift as much as a few seconds in either direction due to inherent inaccuracies recovering application time after a system crash.
currentAppTimeMillis in interface WatchdogServicepublic long getAppTimeMillis(long systemTimeMillis)
initialize method
was called on its AppListener object.
getAppTimeMillis in interface WatchdogServicesystemTimeMillis - a system time value
public long getSystemTimeMillis(long appTimeMillis)
initialize
method was called on its AppListener object to a system time
value. A system time value is the total elapsed time in milliseconds
since midnight, January 1, 1970 UTC.
getSystemTimeMillis in interface WatchdogServiceappTimeMillis - an application time value
public WatchdogServerImpl getServer()
NodeInfo getNodeStatusInfo()
|
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 | |||||||||