public abstract class MasterComponentImplBase extends CharacteristicComponentImpl implements AcsStateChangeListener
Each ALMA subsystem ('subsystem' in its technical meaning) must provide such a
master component for administrational purposes.
It's strongly recommended to do this in Java and use MasterComponentImplBase
as the base class for the component implementation.
This class provides the transition logic for the various states.
Subclasses only need to implement the actions for the various transitions
or, more accurately, for the activity states.
(see method getActionHandler;
as an example, please see TestMasterComponent.
| Modifier and Type | Class and Description |
|---|---|
class |
MasterComponentImplBase.DefaultResourceErrorHandler<T>
[ miscellaneous ]
|
characteristicModelImpl, propertiesm_containerServices, m_instanceName, m_logger| Constructor and Description |
|---|
MasterComponentImplBase() |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanUp()
Master component subclasses must call
super.cleanUp() if they override this method! |
ROstringSeq |
currentStateHierarchy() |
void |
doTransition(SubsystemStateEvent event)
Dispatches the event to the corresponding state machine method.
|
protected abstract AlmaSubsystemActions |
getActionHandler()
Subsystem state machine actions, to be implemented by concrete subclasses.
|
void |
initialize(ContainerServices containerServices)
Master component subclasses must call
super.initialize() if they override this method! |
protected void |
monitorComponent(ACSComponent component)
Subclasses can request to have the "health" of a given subsystem component monitored,
and that the mastercomponent state be set to "Error" in case problems are detected with this component.
|
protected <T extends ACSComponent> |
monitorComponent(T component,
SubsysResourceMonitor.ResourceErrorHandler<T> err)
Subclasses can request to have the "health" of a given subsystem component monitored,
and that the provided
ResourceErrorHandler be called in case problems are detected. |
protected void |
monitorPingableResource(PingableResourceOperations resource,
java.lang.String name)
Like
monitorComponent(ACSComponent) but for objects implementing the PingableResource interface. |
protected <T extends PingableResourceOperations> |
monitorPingableResource(T resource,
java.lang.String name,
SubsysResourceMonitor.ResourceErrorHandler<T> err)
Like
#monitorComponent() but for objects implementing the PingableResource interface. |
protected <T> void |
monitorResource(SubsysResourceMonitor.ResourceChecker<T> checker,
SubsysResourceMonitor.ResourceErrorHandler<T> err,
int monitorDelaySeconds)
Subclasses can request to have the "health" of a given subsystem component monitored,
and that the provided
ResourceErrorHandler be called in case problems are detected. |
void |
stateChangedNotify(AcsState[] oldStateHierarchy,
AcsState[] currentStateHierarchy)
Will be called by the state machine implementation for every state change.
|
protected void |
stopMonitoringAllResources()
Stops monitoring all resources that have been previously submitted for monitoring.
|
protected void |
stopMonitoringResource(java.lang.String resourceName)
Stops monitoring a resource.
|
void |
updateStateHierarchy()
Sets the property value of
currentStateHierarchy
to match the current (sub-)states from the state machine. |
descriptor, execute, find_characteristic, get_all_characteristics, get_characteristic_by_name, getComponentContainerServices, registerProperty, unregisterPropertyaboutToAbort, componentState, execute, namepublic void initialize(ContainerServices containerServices) throws ComponentLifecycleException
super.initialize() if they override this method!initialize in interface ComponentLifecycleinitialize in class CharacteristicComponentImplcontainerServices - callback object for services provided by the containerComponentLifecycleExceptionComponentLifecycle.initialize(alma.acs.container.ContainerServices)public void cleanUp()
throws AcsJComponentCleanUpEx
super.cleanUp() if they override this method!cleanUp in interface ComponentLifecyclecleanUp in class CharacteristicComponentImplAcsJComponentCleanUpExCharacteristicComponentImpl.cleanUp()public final ROstringSeq currentStateHierarchy()
alma.ACS.MasterComponentOperations#currentStateHierarchy(),
updateStateHierarchy()public final void doTransition(SubsystemStateEvent event)
throws IllegalStateEventEx
Relies on CORBA to queue concurrent calls, which this synchronized implementation forcefully serializes. Note that calls should always return quickly, since the real work is done asynchronously in activity states.
IllegalStateEventExalma.ACS.MasterComponentOperations#doTransition(alma.ACS.MasterComponentPackage.SubsystemStateEvent)protected abstract AlmaSubsystemActions getActionHandler()
protected final void monitorComponent(ACSComponent component)
Detected problems can be
componentState returns a state other than
OPERATIONAL.
Note that this is a simplified version of #monitorComponent(ACSComponent, ComponentErrorHandler) and
does not require the subclass to provide an error handler.
Before a resource gets unloaded/released etc, its monitoring should be stopped to avoid false errors,
using stopMonitoringResource(String) or stopMonitoringAllResources().
protected final <T extends ACSComponent> void monitorComponent(T component,
SubsysResourceMonitor.ResourceErrorHandler<T> err)
ResourceErrorHandler be called in case problems are detected.
Unlike method monitorComponent(ACSComponent), this method gives full control over the reaction to
a detected failure. The master component can thus ignore or try to fix the problem, or eventually also
go to error state (by calling doTransition(SubsystemStateEvent.SUBSYSEVENT_ERROR)).
Before a resource gets unloaded/released etc, its monitoring should be stopped to avoid false errors,
using stopMonitoringResource(String) or stopMonitoringAllResources().
component - the component that should be monitorederr - a custom error handler. If null, then a default error handler will be used,
and the master component will go to error state automatically (same as using monitorComponent(ACSComponent)).protected final void monitorPingableResource(PingableResourceOperations resource,
java.lang.String name)
monitorComponent(ACSComponent) but for objects implementing the PingableResource interface.resource - the resource that should be monitoredprotected final <T extends PingableResourceOperations> void monitorPingableResource(T resource,
java.lang.String name,
SubsysResourceMonitor.ResourceErrorHandler<T> err)
#monitorComponent() but for objects implementing the PingableResource interface.resource - the resource that should be monitorederr - a custom error handler. If null, then a default error handler will be used,
and the master component will go to error state automatically (same as using #monitorPingableResource(PingableResourceOperations)).protected final <T> void monitorResource(SubsysResourceMonitor.ResourceChecker<T> checker, SubsysResourceMonitor.ResourceErrorHandler<T> err, int monitorDelaySeconds)
ResourceErrorHandler be called in case problems are detected.
Compared with the methods that allow monitoring a component, this method offers more flexibility:
any kind of resource can be monitored, for which a custom ResourceChecker must be provided.
Examples of resources include an "offshoot" remote object, a database,
or a standalone-process such as Tomcat.
This method also takes the delay between monitor calls as a parameter, to allow adjusting the frequency of monitor calls on a per resource basis. Invalid values will result in the default delay being used.
Before a resource gets unloaded/released etc, its monitoring should be stopped to avoid false errors,
using stopMonitoringResource(String) or stopMonitoringAllResources().
T - The resource type. Used to enforce matching checker and error handler.checker - The checker that encapsulates the specifics of the methods to be checked. Must not be null.err - A custom error handler. If null, then a default error handler will be used,
and the master component will go to error state automatically (see comment for method monitorComponent(ACSComponent).monitorDelaySeconds - The delay between two check calls. If monitorDelaySeconds < 1
then the default delay of 10 seconds will be used.protected final void stopMonitoringResource(java.lang.String resourceName)
monitorComponent(ACSComponent),
monitorComponent(ACSComponent, alma.ACS.MasterComponentImpl.SubsysResourceMonitor.ResourceErrorHandler),
monitorResource(alma.ACS.MasterComponentImpl.SubsysResourceMonitor.ResourceChecker, alma.ACS.MasterComponentImpl.SubsysResourceMonitor.ResourceErrorHandler, int),
stopMonitoringAllResources()protected final void stopMonitoringAllResources()
stopMonitoringResource(String)public void stateChangedNotify(AcsState[] oldStateHierarchy, AcsState[] currentStateHierarchy)
Normally you should not overload this method; if you do, make sure to call updateStateHierarchy()
so that the state change propagates to the field which is visible from the outside of this component.
stateChangedNotify in interface AcsStateChangeListeneralma.ACS.MasterComponentImpl.statemachine.AcsStateChangeListener#stateChangedNotify(alma.ACS.MasterComponentImpl.statemachine.AcsState[], alma.ACS.MasterComponentImpl.statemachine.AcsState[])public void updateStateHierarchy()
throws AcsJException
currentStateHierarchy
to match the current (sub-)states from the state machine.
This method should not be overloaded by subclasses! We just don't make it final to meet special testing needs.
AcsJException