public class Node extends Object implements NodeInterface, IfsEventHandler, TimerContext
A Node manages a set of Servers and typically one Service (although a set of Services can be defined).
Modifier and Type | Class and Description |
---|---|
class |
Node.NodeRequest
A NodeRequest is structure holding a Node request.
|
NODESTATUS_DISPOSED, NODESTATUS_RUNNING, NODESTATUS_STARTING, NODESTATUS_STOPPED, NODESTATUS_STOPPING, NODESTATUS_UNKNOWN
Constructor and Description |
---|
Node()
Constructs a Node.
|
Modifier and Type | Method and Description |
---|---|
protected LibrarySession |
acquireSession()
Acquires a LibrarySession from the session pool.
|
protected void |
checkNodeState()
Check if NodeState has been disposed or finalized.
|
protected void |
checkTimer()
Check the timer, and reset if needed.
|
void |
configure(String ncName,
String svcName,
AttributeValueTable ncOverrides)
Configure this Node.
|
void |
configure(String ncName,
String svcName,
AttributeValueTable ncOverrides,
DataSource ds)
Configure this Node, including a DataSource.
|
protected LibrarySessionPool |
constructLibrarySessionPool(int maxSessCount,
String serviceName,
String appName,
SystemUserCredential cred)
Constructs a LibrarySessionPool.
|
protected TimerInterface |
createTimer()
Creates a Timer.
|
protected void |
disableEventListening()
Disable listening for events on RuntimeState instances.
|
void |
dispose()
Deprecated.
9.3.4.0: use ControllerJob to request Node to dispose
|
protected void |
disposeNode()
Disposes this Node.
|
protected void |
disposeService()
Disposes the Service managed by this Node.
|
protected void |
enableEventListening()
Enable listening events on any RuntimeState.
|
AttributeValueTable |
getConfigurationTable()
Gets the Configuration Table for this Node.
|
AttributeValue |
getConfigurationValue(String key)
Gets a Configuration value from the Configuration Table for this Node.
|
int |
getDesiredStatus()
Gets the desired status of this Node.
|
String |
getIfsHome()
Gets the CM SDK home directory for this Node.
|
String |
getNodeConfigurationName()
Gets the name of the NodeConfiguration.
|
String |
getNodeName()
Gets the name of this Node.
|
NodeState |
getNodeState(LibrarySession session)
Gets the NodeState for this Node.
|
String |
getOracleHome()
Deprecated.
9.3.4.0: no longer a property that the Node makes available
|
AttributeValueTable |
getOverridesTable()
Gets the Overrides Table for this Node.
|
String |
getServiceConfigurationName()
Gets the name of the ServiceConfiguration.
|
String |
getServiceName()
Gets the name that identifies the running Service.
|
ServiceState |
getServiceState(LibrarySession session)
Gets the ServiceState for the service that this Node manages.
|
protected LibrarySession |
getSession()
Gets the session for this Node.
|
AttributeValueTable |
getStateTable()
Gets the State Table for this Node.
|
int |
getStatus()
Gets the status of this Node.
|
protected AttributeValueTable |
getTimerConfiguration()
Gets the Timer Configuration.
|
protected void |
handleControllerRequest(RuntimeState target)
Called to handle a ControllerRequest that was posted to the specified
RuntimeState object, if one is active.
|
protected void |
handleDisposeNode()
Called when the Node is requested to dispose.
|
void |
handleEvent(IfsEvent event)
Handles events on RuntimeState objects.
|
protected void |
handleHandlerControllerRequest(HandlerState hs)
Called to handle a ControllerRequest that was posted to the specified
HandlerState object, if one is active.
|
protected void |
handleNodeConfigurationOverride(String propName)
Handle a NodeConfiguration override.
|
protected void |
handleNodeConfigurationOverrideRequest(NodeState ns)
Handle NodeConfiguration overrides that have been posted.
|
protected void |
handleNodeControllerRequest(NodeState ns)
Called to handle a ControllerRequest that was posted to the specified
NodeState object, if one is active.
|
protected void |
handleNodeDisposed()
Called as a notification when the Node is disposed.
|
protected void |
handleNodeStateEvent(String eventKey)
Handle a NodeState event, specified as an AuditEvent key.
|
protected void |
handleRequest(Node.NodeRequest request)
Handles the specified pending request for this Node.
|
protected void |
handleRequests()
Dispatches any pending requests for this Node.
|
protected void |
handleRestartNode()
Called when the Node is requested to restart.
|
protected void |
handleServerControllerRequest(ServerState ss)
Called to handle a ControllerRequest that was posted to the specified
ServerState object, if one is active.
|
protected void |
handleServerDisposed(ServerState ss)
Called to process notification that one of the managed Servers
has been disposed.
|
protected void |
handleServiceControllerRequest(ServiceState svs)
Called to handle a ControllerRequest that was posted to the specified
ServiceState object, if one is active.
|
protected void |
handleStartNewServerRequest(ServerState ss)
Handle a request to start a new managed server.
|
protected void |
handleStartNode()
Called when the Node is requested to start.
|
protected void |
handleStopNode()
Called when the Node is requested to stop.
|
protected void |
handleTimerExpired()
Called when the Node's timer expires.
|
protected void |
initialize()
Initializes this Node.
|
protected void |
initializeLogging()
Initialize logging system, if it is not already initialized,
or if "reinitialize" is specified in the Node configuration.
|
protected void |
initializeTimerCounts()
Initialize the timer counts.
|
protected boolean |
isNodeDisposed()
Indicates the Node has been requested to dispose, and that
the run loop should end.
|
protected void |
performCriticalTimedDuties()
Perform the critical timed Node duties.
|
protected void |
performTimedChallengerDuties()
Perform Controller challenge duties.
|
protected void |
performTimedControllerDuties()
Perform the timed Controller Node duties.
|
protected void |
performTimedDuties()
Perform timed Node duties.
|
protected void |
postControllerAlertRequest(AttributeValue runtimeTarget)
Post request to alert the Controller, issued from the specified
RuntimeState.
|
protected void |
postControllerReplyRequest(AttributeValue runtimeTarget)
Post request to reply to the Controller, issued from the specified
RuntimeState.
|
protected void |
postControllerRequestRequest(AttributeValue runtimeTarget)
Post request to a request from the Controller, issued on the specified
RuntimeState.
|
protected void |
postControllerTimedDuties()
Post request to alert the Controller to perform its timed duties.
|
void |
postDisposeNodeRequest()
Post request to dispose a node.
|
void |
postNodeDisposedRequest()
Post request to indicate that the node is disposed.
|
protected void |
postRequest(int type)
Posts a request to this Node, with no payload.
|
protected void |
postRequest(int type,
Object payload)
Posts a request to this Node, with an optional opaque payload.
|
void |
postRestartNodeRequest()
Post request to restart a node.
|
protected void |
postRun()
Performs post-run tasks for this Node.
|
void |
postServerDisposedRequest(AttributeValue ssValue,
Server server)
Post request to respond to a Server indicating that it has been disposed.
|
void |
postStartNodeRequest()
Post request to start a node.
|
void |
postStopNodeRequest()
Post request to stop a node.
|
protected void |
preRun()
The pre-run tasks for this Node.
|
protected void |
processEvent(IfsEvent event)
Processes an IfsEvent previously placed in this Node's event
queue by
queueEvent . |
protected void |
processEvents()
Dispatches any IfsEvents previously placed in this Node's event
queue by
queueEvent . |
protected void |
queueEvent(IfsEvent event)
Queues an IfsEvent for this Node.
|
protected void |
releaseSession()
Releases the Node's session back to the session pool.
|
protected void |
resetTimer()
Resets the timer for this Node.
|
void |
run()
Execute the "Run loop" for this Node.
|
protected void |
setDesiredStatus(int status)
Sets the desired status of this Node.
|
protected void |
setDesiredStatus(int status,
boolean force)
Sets the desired status of this Node.
|
protected void |
setStatus(int status)
Sets the status of this Node.
|
protected boolean |
shouldRemovePreviousOverrides()
Gets indication as to whether previous overrides should be
applied when restarting a Node.
|
protected void |
showRuntimeStates()
Show the all undisposed RuntimeState objects, organized by the managing Node.
|
void |
start()
Requests to start the Node.
|
protected void |
startNode()
Starts (or restarts) the Node.
|
void |
startService()
Starts the service associated with this Node.
|
protected void |
startTimer()
Starts a timer that will generate "timer expiration" requests for
this Node at a specified interval.
|
void |
stop()
Deprecated.
9.3.4.0: use ControllerJob to request Node to stop
|
protected void |
stopNode()
Stops this Node.
|
protected void |
stopTimer()
Stops the timer for this Node.
|
void |
timerExpired()
Notififcation that the timer has expired.
|
static String |
toStatusLabel(int status)
Gets a localized label for the specified status of a Node, using a
default Localizer.
|
static String |
toStatusLabel(int status,
LibrarySessionInterface session)
Gets a localized label for the specified status of a Node, using the
specified session's Localizer.
|
static String |
toStatusLabel(int status,
Localizer localizer)
Gets a localized label for the specified status of a Node, using the
specified Localizer.
|
protected void |
triggerExit()
Called when the Node must exit immediately.
|
protected void |
updateAcknowledgeDate()
Update the last ack date.
|
protected void |
updateNodeStateLogLevelOverrides()
Update the NodeState with updated LogLevelOverrides information.
|
protected void |
waitNode()
Blocks the current thread until one of the following occurs.
|
public Node() throws IfsException
Subclasses should provide a zero-argument constructor.
IfsException
- if the operation failspublic String getNodeName()
getNodeName
in interface NodeInterface
public String getNodeConfigurationName()
getNodeConfigurationName
in interface NodeInterface
public String getServiceConfigurationName()
getServiceConfigurationName
in interface NodeInterface
public String getServiceName()
getServiceName
in interface NodeInterface
public int getStatus()
getStatus
in interface NodeInterface
public int getDesiredStatus()
getDesiredStatus
in interface NodeInterface
public AttributeValue getConfigurationValue(String key) throws IfsException
getConfigurationValue
in interface NodeInterface
key
- the configuration property keyIfsException
- if the operation failspublic String getOracleHome() throws IfsException
The Oracle home directory is specified by the Node's
IFS.NODE.OracleHome
property.
getOracleHome
in interface NodeInterface
IfsException
- if the operation failspublic String getIfsHome() throws IfsException
The CM SDK home directory is specified by the node's
IFS.NODE.IfsHome
property.
getIfsHome
in interface NodeInterface
IfsException
- if the operation failspublic NodeState getNodeState(LibrarySession session) throws IfsException
getNodeState
in interface NodeInterface
session
- the session context to useIfsException
- if the operation failspublic ServiceState getServiceState(LibrarySession session) throws IfsException
getServiceState
in interface NodeInterface
session
- the session context to useIfsException
- if the operation failspublic AttributeValueTable getConfigurationTable()
public AttributeValueTable getOverridesTable()
public AttributeValueTable getStateTable()
public void configure(String ncName, String svcName, AttributeValueTable ncOverrides) throws IfsException
ncName
- the name of the NodeConfigurationsvcName
- the name of the ServiceConfiguration (can be null)ncOverrides
- the table of NodeConfiguration parameter overridesIfsException
- if the operation failspublic void configure(String ncName, String svcName, AttributeValueTable ncOverrides, DataSource ds) throws IfsException
ncName
- the name of the NodeConfigurationsvcName
- the name of the ServiceConfiguration (can be null)ncOverrides
- the table of NodeConfiguration parameter overridesds
- the DatatSource to use in starting the ServiceIfsException
- if the operation failspublic void startService() throws IfsException
The primary service is defined in the NodeConfiguration. Currently this
is picked up from the overrides specified in the configure
method.
IfsException
- if the operation failspublic void start() throws IfsException
Called from the startNode
operation, currently defined in
RuntimeOperations, which is the standard way of starting Node's within
a script.
IfsException
- if the operation failspublic void stop() throws IfsException
IfsException
- if the operation failspublic void dispose() throws IfsException
IfsException
- if the operation failsprotected void startNode() throws IfsException
IfsException
- if the operation failsprotected boolean shouldRemovePreviousOverrides() throws IfsException
This is an override point for Node subclasses. It is called within
startNode
, from within the Node's controlled "run loop".
IfsException
- if the operation failsprotected void initializeLogging() throws IfsException
Configure LogManager if indicated by settings in the Node configuration.
IfsException
- if the operation failsprotected void initialize() throws IfsException
This is an extensibility point, called to allow subclasses perform initialization after the basic initialization occurs by the source that launches the Node.
IfsException
- if the operation failspublic void run()
protected void preRun() throws Exception
Extensiblity point for activity prior to the start of the run loop.
Exception
- if the operation failsprotected void postRun()
Extensiblity point for activity after exiting the run loop.
protected boolean isNodeDisposed()
protected void startTimer() throws IfsException
If the timer is already started, it is stopped and restarted.
IfsException
- (IFS-45364) if the operation failsprotected void stopTimer() throws IfsException
If the timer is not started, this method has no effect.
IfsException
- if the operation failsprotected void resetTimer() throws IfsException
This has the effect of preventing the next "timer expired" event from occurring until the Activation Period elapses relative to the current time. If the timer is not started, this method has no effect.
IfsException
- if the operation failsprotected void enableEventListening() throws IfsException
IfsException
- if the operation failsprotected void disableEventListening() throws IfsException
IfsException
- if the operation failspublic void handleEvent(IfsEvent event) throws IfsException
This queues the events for processing inside the run loop.
handleEvent
in interface IfsEventHandler
event
- the event to handleIfsException
- if the operation failsprotected final void queueEvent(IfsEvent event) throws IfsException
This is called by the handleEvent
method of an IfsEventHandler. The event remains in the Node's
event queue until processEvents
is called from within the
Node's run loop, at which point processEvent
is called to process the event.
event
- the event to queueIfsException
- (IFS-45369) if the operation failsprotected final void processEvents() throws IfsException
queueEvent
.IfsException
- (IFS-45371) if the operation failsprotected void processEvent(IfsEvent event) throws Exception
queueEvent
.
This method is called by processEvents
. Override
it to perform tasks in response to an event. Unless overridden,
no operation is performed by this method.
The processEvents
method will rethrow any exception
thrown by this method.
event
- the eventException
- if the operation failsprotected void postRequest(int type)
type
- the enumerated request typeprotected void postRequest(int type, Object payload)
type
- the enumerated request typepayload
- the optional Object payloadprotected final void handleRequests() throws IfsException
Results in calls to handleRequest
for each of the
queued requests.
IfsException
- (IFS-45370) if the operation failsprotected void handleRequest(Node.NodeRequest request) throws IfsException
This method can be overridden by subclasses to process custom requests.
The implmentation in this base class handles the standard requests,
which result in calls to:
handleRequest
, which in turn calls
handleTimerExpired
.
These calls occur in the same thread that called this method. Should one of these methods throw, request handling will cease, any requests not yet dispatched will remain pending, and this method will rethrow the exception.
request
- the NodeRequest to handleIfsException
- (IFS-45370) if the operation failsprotected final void waitNode() throws IfsException
queueEvent
is called to enqueue an event
IfsException
- (IFS-45372) if the operation failspublic void postStartNodeRequest()
public void postStopNodeRequest()
public void postRestartNodeRequest()
public void postDisposeNodeRequest()
public void postNodeDisposedRequest()
public void postServerDisposedRequest(AttributeValue ssValue, Server server)
postServerDisposedRequest
in interface NodeInterface
ssValue
- the ServerState value for the Server that was disposedserver
- the Server that was disposedprotected void postControllerRequestRequest(AttributeValue runtimeTarget)
runtimeTarget
- the RuntimeState target (as an AttributeValue)protected void postControllerReplyRequest(AttributeValue runtimeTarget)
runtimeTarget
- the RuntimeState target (as an AttributeValue)protected void postControllerAlertRequest(AttributeValue runtimeTarget)
runtimeTarget
- the RuntimeState target (as an AttributeValue)protected void postControllerTimedDuties()
public void timerExpired()
timerExpired
in interface TimerContext
protected void triggerExit()
protected void handleTimerExpired() throws IfsException
IfsException
- if the operation failsprotected void performTimedDuties() throws IfsException
IfsException
- if the operation failsprotected void performCriticalTimedDuties() throws IfsException
IfsException
- if the operation failsprotected void checkNodeState() throws IfsException
IfsException
- if the operation failsprotected void updateAcknowledgeDate() throws IfsException
IfsException
- if the operation failsprotected void showRuntimeStates() throws IfsException
IfsException
- if the operation failsprotected void checkTimer() throws IfsException
IfsException
- if the operation failsprotected void performTimedChallengerDuties() throws IfsException
IfsException
- if the operation failsprotected void performTimedControllerDuties() throws IfsException
IfsException
- if the operation failsprotected void handleStartNode() throws IfsException
IfsException
- if the operation failsprotected void handleStopNode() throws IfsException
IfsException
- if the operation failsprotected void handleRestartNode() throws IfsException
IfsException
- if the operation failsprotected void handleDisposeNode() throws IfsException
IfsException
- if the operation failsprotected void handleNodeDisposed() throws IfsException
IfsException
- if the operation failsprotected void handleServerDisposed(ServerState ss) throws IfsException
ss
- the ServerState that was disposedIfsException
- if the operation failsprotected void handleControllerRequest(RuntimeState target) throws IfsException
Called when an IfsEvent is received that indicates a ControllerRequest has been added to the RuntimeState object, or during the Node's timed duties where all RuntimeStates managed by the Node are visited to handle any pending ControllerRequests. It is a no-op if no ControllerRequests are pending.
target
- the target RuntimeState objectIfsException
- if the operation failsprotected void handleNodeControllerRequest(NodeState ns) throws IfsException
Called when an IfsEvent is received that indicates a ControllerRequest has been added to the NodeState object, or during the Node's timed duties. It is a no-op if no ControllerRequests are pending.
ns
- the target NodeState objectIfsException
- if the operation failsprotected void handleServerControllerRequest(ServerState ss) throws IfsException
Called when an IfsEvent is received that indicates a ControllerRequest has been added to the ServerState object, or during the Node's timed duties. It is a no-op if no ControllerRequests are pending.
ss
- the target ServerState objectIfsException
- if the operation failsprotected void handleHandlerControllerRequest(HandlerState hs) throws IfsException
Called when an IfsEvent is received that indicates a ControllerRequest has been added to the HandlerState object, or during the Node's timed duties. It is a no-op if no ControllerRequests are pending.
hs
- the target HandlerState objectIfsException
- if the operation failsprotected void handleServiceControllerRequest(ServiceState svs) throws IfsException
Called when an IfsEvent is received that indicates a ControllerRequest has been added to the ServiceState object, or during the Node's timed duties. It is a no-op if no ControllerRequests are pending.
svs
- the target ServiceState objectIfsException
- if the operation failsprotected void stopNode() throws IfsException
IfsException
- if the operation failsprotected void disposeNode() throws IfsException
IfsException
- if the operation failsprotected void disposeService() throws IfsException
IfsException
- if the operation failsprotected LibrarySession acquireSession() throws IfsException
IfsException
- if the operation failsprotected LibrarySession getSession() throws IfsException
IfsException
- if the operation failsprotected void releaseSession() throws IfsException
IfsException
- if the operation failsprotected LibrarySessionPool constructLibrarySessionPool(int maxSessCount, String serviceName, String appName, SystemUserCredential cred) throws IfsException
maxSessCount
- the maximum number of sessions that can
be constructed by this poolserviceName
- the service nameappName
- the application name (for DB connection metadata)cred
- the system user credentialsIfsException
- if the operation failsprotected void handleNodeStateEvent(String eventKey) throws IfsException
eventKey
- the NodeState event keyIfsException
- if the operation failsprotected void handleNodeConfigurationOverrideRequest(NodeState ns) throws IfsException
ns
- the NodeState instanceIfsException
- if the operation failsprotected void handleNodeConfigurationOverride(String propName) throws IfsException
The overridden value can be obtained from the current configuration table.
propName
- the NodeConfiguration property nameIfsException
- if the operation failsprotected void updateNodeStateLogLevelOverrides() throws IfsException
IfsException
- if the operation failsprotected void handleStartNewServerRequest(ServerState ss) throws IfsException
ss
- the ServerState created by the Controller to request
a Server to start on its managing NodeIfsException
- if the operation failsprotected void setDesiredStatus(int status) throws IfsException
status
- the new statusIfsException
- if the operation failsprotected void setDesiredStatus(int status, boolean force) throws IfsException
status
- the new statusforce
- if true, set the desired status regardless of
the current statusIfsException
- if the operation failsprotected void setStatus(int status) throws IfsException
status
- the new statusIfsException
- if the operation failspublic static String toStatusLabel(int status) throws IfsException
Equivalent to toStatusLabel(status, null)
.
status
- the statusIfsException
- if the operation failspublic static String toStatusLabel(int status, LibrarySessionInterface session) throws IfsException
Equivalent to toStatusLabel(status, session.getLocalizer())
.
status
- the statussession
- the sessionIfsException
- if the operation failspublic static String toStatusLabel(int status, Localizer localizer) throws IfsException
If localizer
is null, this method is equivalent to
toStatusLabel(status, new Localizer())
.
status
- the statuslocalizer
- the LocalizerIfsException
- if the operation failsprotected TimerInterface createTimer() throws IfsException
The Timer configuration is hardcoded to run every 5 minutes, with a base time of day of 00:00:00.
IfsException
- if the operation failsprotected void initializeTimerCounts() throws IfsException
IfsException
- if the operation failsprotected AttributeValueTable getTimerConfiguration() throws IfsException
Node Subclasses may override this to derive different values for the timer settings.
IfsException
- if the operation failsCopyright © 2023. All rights reserved.