AP&C API Reference
Classes | Public Member Functions | Protected Member Functions | Properties | Events | List of all members
Apac.Supervisors.Supervisor Class Referenceabstract

The base implementation for ISupervisor providing controls for initializing, starting, and stopping configured ISupervisable instances. More...

Inheritance diagram for Apac.Supervisors.Supervisor:
Apac.Supervisors.ISupervisor Apac.ISupervisable Apac.Supervisors.ControllerSupervisor Apac.Supervisors.DataSupervisor Apac.Supervisors.ExecutiveSupervisor

Classes

class  SubordinateHandle
 This class is used during asynchronous invocation to keep a handle on the subordinate along with the method that was invoked (the function). More...
 

Public Member Functions

Licensing.AcquisitionResponse RequestLocks (Licensing.LicensedFeatures features)
 This default implementation will return null.
More...
 
Licensing.ReleaseResponse ReleaseLock (string acquisitionId)
 
void Initialize (SupervisableConfig config, ISupervisor exec)
 Do basic initialization of simple supervisable configuraiton. More...
 
void ResolveReferences ()
 Prompts subordinates to resolve their references (supervisors don't have references). More...
 
void CheckReferencesStates ()
 Prompts the subordinates to check their references' states (supervisors don't have references). More...
 
void Initialize (ConfigElement config)
 Initialized the supervisor from configuration. More...
 
ISupervisable LocateSupervisableAgent (string name)
 Initiates the call chain to locate the supervisable agent with the given name. More...
 
ISupervisable[] LocateSupervisableAgents (Predicate< ISupervisable > predicate, bool askExec)
 Initiates the call chain to locate the supervisable agent with the given name. More...
 
void Starting ()
 Signals that Start() will soon be called on the component. This can be used as an opportunity to perform preparatory activity, like checking the state of referenced components and similar actions. More...
 
void Start ()
 Instructs the supervisor to start operations. This call results in a No-Op if the supervisor is not in a Stopped or Initialized state. More...
 
void Stop ()
 Instructs the supervisor to stop operations. This call results in a No-Op if the supervisor is not running. More...
 
void AddSubordinate (ISupervisable subordinate)
 Adds a subordinate under the control of the supervisor. More...
 
void RemoveSubordinate (string name)
 Removes the subordinate with the given name; More...
 
void StartSubordinate (string name)
 Starts the subordinate with the given name; More...
 
void StopSubordinate (string name)
 Stops the subordinate with the given name; More...
 
SupervisableDescription[] ListSubordinates ()
 Lists the subordinates. More...
 
SupervisableState GetSubordinateState (string name)
 Gets the state of the subordinate. More...
 
override object InitializeLifetimeService ()
 Ensures this remotable object's lease never times out. Subclassed supervisors wanting to manage leases more tightly should override this and not call this parent implementation. More...
 
- Public Member Functions inherited from Apac.ISupervisable
void Initialize (Apac.Configuration.SupervisableConfig config, Supervisors.ISupervisor exec)
 Initializes the component with the given SupervisableConfig (or derivative) and ISupervisor. More...
 

Protected Member Functions

virtual Licensing.AcquisitionResponse OnRequestLocks (Licensing.LicensedFeatures features)
 Called when the license needs to be checked by a subordinate. More...
 
virtual Licensing.ReleaseResponse OnReleaseLock (string acquisitionId)
 Called when the license needs to be released by a subordinate. More...
 
virtual void OnInitialize (ConfigElement config)
 
virtual void OnStarting ()
 
abstract void OnStart ()
 Signals when Start() has been called. More...
 
abstract void OnStop ()
 Signals when Stop() has been called. More...
 
virtual void OnStateChanging (SupervisableState currentState, SupervisableState newState)
 Signals when the state is changing. More...
 
virtual void OnStateChanged (SupervisableState previousState, SupervisableState newState)
 
virtual void OnException (Exception ex)
 
virtual ISupervisable OnLocateSupervisableAgent (string name)
 Provides subclasses the opportunity to override the agent lookup process. More...
 
virtual ISupervisable[] OnLocateSupervisableAgents (Predicate< ISupervisable > predicate, bool askExec)
 
void SetState (SupervisableState newState)
 Changes the state of the supervisor to the new state. More...
 
virtual void OnStateChangeStarting ()
 
virtual void OnStateChangeRunning ()
 
virtual void OnStateChangeStopping ()
 
virtual void OnStateChangeStopped ()
 
virtual void OnStateChangeInitializing ()
 
virtual void OnStateChangeInitialized ()
 
virtual void OnStateChangeErrored ()
 
virtual void OnSupervisableHeartbeat (ISupervisable sender, DateTime heartbeat)
 This signature was carefully chosen to let a subordinate report its heartbeat OR to let a supervisor report a subordinate heartbeat up the controll chain. More...
 
virtual void OnSubordinateStateChanging (ISupervisable sender, SupervisableStateChangeEventArgs args)
 
virtual void OnSubordinateStateChanged (ISupervisable sender, SupervisableStateChangeEventArgs args)
 
virtual void OnSubordinateHeartbeat (ISupervisable sender, EventArgs args)
 
virtual void OnSubordinateErrored (ISupervisable sender, SupervisableErroredEventArgs args)
 

Properties

string Name [get]
 Gets the configured name for the supervisor. More...
 
string Description [get]
 Get the configured description for the supervisor. More...
 
bool Prioritized [get]
 Indicates if the supervisor should be executed on a higher thread priority. More...
 
DateTime LastHeartbeat [get]
 Gets the last heartbeat. More...
 
bool IsRunning [get]
 Gets a value indicating whether this instance is running. More...
 
Supervisors.ISupervisor ExecutiveSupervisor [get]
 Gets the excecutive supervisor. More...
 
DateTime StartTime [get]
 Gets the time this supervisable component was started. More...
 
DateTime StopTime [get]
 Gets the time this supervisable component was stopped. More...
 
TimeSpan UpTime [get]
 Gets the amount of time this supervisable component has been running, or did run before it was stopped (if IsRunning is false). More...
 
SupervisableState CurrentState [get]
 Gets the state of the supervisor. More...
 
SupervisableState PreviousState [get]
 Gets the previos state of the supervisor. More...
 
Exception LastException [get]
 Gets the last exception that occured in the supervisor. More...
 
SupervisableCollection Subordinates [get]
 Lazy-initialized list of components that are supervised by this supervisor. More...
 
log4net.ILog Log [get]
 Gets the log4net.ILog for the instance. More...
 
- Properties inherited from Apac.Supervisors.ISupervisor
SupervisableCollection Subordinates [get]
 
- Properties inherited from Apac.ISupervisable
string Name [get]
 The name of the component, for unique identification purposes. More...
 
string Description [get]
 The description of the component, for human consumption. More...
 
bool Prioritized [get]
 Indicates if the component should be high priority. More...
 
Supervisors.ISupervisor ExecutiveSupervisor [get]
 Walks the tree to find the top level supervisor. More...
 
bool IsRunning [get]
 Indicates that the component is running. More...
 
DateTime LastHeartbeat [get]
 
DateTime StartTime [get]
 Gets the time this supervisable component was started. More...
 
DateTime StopTime [get]
 Gets the time this supervisable component was stopped. More...
 
TimeSpan UpTime [get]
 Gets the amount of time this supervisable component has been running, or did run before it was stopped (if IsRunning is false). More...
 
SupervisableState CurrentState [get]
 Gets the current SupervisableState of this component. More...
 
SupervisableState PreviousState [get]
 Gets the previous SupervisableState of this component. More...
 
Exception LastException [get]
 Gets the last exception to have occurred and been trapped by this component. More...
 

Events

SupervisableErroredHandler SubordinateErrored
 
SupervisableHeartbeatHandler SubordinateHeartbeat
 
SupervisableStateChangingHandler SubordinateStateChanging
 
SupervisableStateChangedHandler SubordinateStateChanged
 
SupervisableStateChangedHandler SupervisableStateChanged
 This event is raised when the supervised state changes. For this event the arguments will contain the previous state and the new state. More...
 
SupervisableStateChangingHandler SupervisableStateChanging
 This event is raised just prior to the supervised state being changed. For this event the arguments will only contain the current state; use SupervisableStateChangeEventArgs.CurrentState as SupervisableStateChangeEventArgs.CurrentState will always contain SupervisableState.Unknown. More...
 
SupervisableErroredHandler SupervisableErrored
 This event is raised if an exception is encountered by a supervisor. More...
 
SupervisableHeartbeatHandler SupervisableHeartbeat
 This event is raised on a periodic basis as a heartbeat to the supervisor. More...
 
- Events inherited from Apac.Supervisors.ISupervisor
SupervisableStateChangingHandler SubordinateStateChanging
 
SupervisableStateChangedHandler SubordinateStateChanged
 
SupervisableErroredHandler SubordinateErrored
 
SupervisableHeartbeatHandler SubordinateHeartbeat
 
- Events inherited from Apac.ISupervisable
SupervisableStateChangingHandler SupervisableStateChanging
 Notifies listeners that the state is about to change. More...
 
SupervisableStateChangedHandler SupervisableStateChanged
 Notifies listeners that the state has changed. More...
 
SupervisableErroredHandler SupervisableErrored
 Notifies listeners that an error occured within the controller. More...
 
SupervisableHeartbeatHandler SupervisableHeartbeat
 Notifies listeners that the component is still active. More...
 

Detailed Description

The base implementation for ISupervisor providing controls for initializing, starting, and stopping configured ISupervisable instances.

Member Function Documentation

◆ AddSubordinate()

void Apac.Supervisors.Supervisor.AddSubordinate ( ISupervisable  subordinate)
inline

Adds a subordinate under the control of the supervisor.

Parameters
subordinateThe object to be controlled by the supervisor.

Implements Apac.Supervisors.ISupervisor.

◆ CheckReferencesStates()

void Apac.Supervisors.Supervisor.CheckReferencesStates ( )
inline

Prompts the subordinates to check their references' states (supervisors don't have references).

Implements Apac.ISupervisable.

◆ GetSubordinateState()

SupervisableState Apac.Supervisors.Supervisor.GetSubordinateState ( string  name)
inline

Gets the state of the subordinate.

Parameters
nameThe name.
Returns

Implements Apac.Supervisors.ISupervisor.

◆ Initialize() [1/2]

void Apac.Supervisors.Supervisor.Initialize ( ConfigElement  config)
inline

Initialized the supervisor from configuration.

Parameters
configThe configuration object holding the settings.

Implements Apac.Supervisors.ISupervisor.

◆ Initialize() [2/2]

void Apac.Supervisors.Supervisor.Initialize ( SupervisableConfig  config,
ISupervisor  exec 
)
inline

Do basic initialization of simple supervisable configuraiton.

Parameters
configThe configuration object holding the settings.

◆ InitializeLifetimeService()

override object Apac.Supervisors.Supervisor.InitializeLifetimeService ( )
inline

Ensures this remotable object's lease never times out. Subclassed supervisors wanting to manage leases more tightly should override this and not call this parent implementation.

Returns

◆ ListSubordinates()

SupervisableDescription [] Apac.Supervisors.Supervisor.ListSubordinates ( )
inline

Lists the subordinates.

Returns

Implements Apac.Supervisors.ISupervisor.

◆ LocateSupervisableAgent()

ISupervisable Apac.Supervisors.Supervisor.LocateSupervisableAgent ( string  name)
inline

Initiates the call chain to locate the supervisable agent with the given name.

Parameters
nameThe name of the requested agent.
Returns
The requesed supervisable agent or null.

Implements Apac.Supervisors.ISupervisor.

◆ LocateSupervisableAgents()

ISupervisable [] Apac.Supervisors.Supervisor.LocateSupervisableAgents ( Predicate< ISupervisable predicate,
bool  askExec 
)
inline

Initiates the call chain to locate the supervisable agent with the given name.

Parameters
predicateThe Predicate<ISupervisable> provided by the caller for matching against supervisable agents.
Returns
The requesed supervisable agents or an empty array.

Implements Apac.Supervisors.ISupervisor.

◆ OnLocateSupervisableAgent()

virtual ISupervisable Apac.Supervisors.Supervisor.OnLocateSupervisableAgent ( string  name)
inlineprotectedvirtual

Provides subclasses the opportunity to override the agent lookup process.

Parameters
typeThe type of agent being requested.
nameThe name of the agent being requested, as defined in the configuration.
Returns
The requested supervisable agent or null.

Reimplemented in Apac.Supervisors.ExecutiveSupervisor.

◆ OnReleaseLock()

virtual Licensing.ReleaseResponse Apac.Supervisors.Supervisor.OnReleaseLock ( string  acquisitionId)
inlineprotectedvirtual

Called when the license needs to be released by a subordinate.

Parameters
acquisitionIdThe acquisition id.
Returns
Returns null by default, but overloads return a valid instance of Licensing.ReleaseResponse indicating the result of the release operation.

Reimplemented in Apac.Supervisors.ExecutiveSupervisor.

◆ OnRequestLocks()

virtual Licensing.AcquisitionResponse Apac.Supervisors.Supervisor.OnRequestLocks ( Licensing.LicensedFeatures  features)
inlineprotectedvirtual

Called when the license needs to be checked by a subordinate.

Parameters
featuresThe features.
Returns
Returns null by default, but overloads return a valid instance of Licensing.AcquisitionResponse indicating the result of the request.

◆ OnStart()

abstract void Apac.Supervisors.Supervisor.OnStart ( )
protectedpure virtual

◆ OnStateChanging()

virtual void Apac.Supervisors.Supervisor.OnStateChanging ( SupervisableState  currentState,
SupervisableState  newState 
)
inlineprotectedvirtual

Signals when the state is changing.

Parameters
currentStateThe SupervisableState from which the instance is changing.
newStateThe SupervisableState to which the instance is changing.

◆ OnStop()

abstract void Apac.Supervisors.Supervisor.OnStop ( )
protectedpure virtual

◆ OnSupervisableHeartbeat()

virtual void Apac.Supervisors.Supervisor.OnSupervisableHeartbeat ( ISupervisable  sender,
DateTime  heartbeat 
)
inlineprotectedvirtual

This signature was carefully chosen to let a subordinate report its heartbeat OR to let a supervisor report a subordinate heartbeat up the controll chain.

Parameters
senderThe subordinate reporting the error.
heartbeatThe timestamp of the heartbeat.

◆ RemoveSubordinate()

void Apac.Supervisors.Supervisor.RemoveSubordinate ( string  name)
inline

Removes the subordinate with the given name;

Parameters
nameThe name of the subordinate to be removed.

Implements Apac.Supervisors.ISupervisor.

◆ RequestLocks()

Licensing.AcquisitionResponse Apac.Supervisors.Supervisor.RequestLocks ( Licensing.LicensedFeatures  features)
inline

This default implementation will return null.

Parameters
features
Returns
Returns Licensing.AcquisitionResponse that indicates if the locks were available.

Implements Apac.Supervisors.ISupervisor.

◆ ResolveReferences()

void Apac.Supervisors.Supervisor.ResolveReferences ( )
inline

Prompts subordinates to resolve their references (supervisors don't have references).

Implements Apac.ISupervisable.

◆ SetState()

void Apac.Supervisors.Supervisor.SetState ( SupervisableState  newState)
inlineprotected

Changes the state of the supervisor to the new state.

Parameters
newStateThe new state for the supervisor.

This method will not notify or make changes if the new state is not different from the current state.

◆ Start()

void Apac.Supervisors.Supervisor.Start ( )
inline

Instructs the supervisor to start operations. This call results in a No-Op if the supervisor is not in a Stopped or Initialized state.

Implements Apac.ISupervisable.

◆ Starting()

void Apac.Supervisors.Supervisor.Starting ( )
inline

Signals that Start() will soon be called on the component. This can be used as an opportunity to perform preparatory activity, like checking the state of referenced components and similar actions.

Implements Apac.ISupervisable.

◆ StartSubordinate()

void Apac.Supervisors.Supervisor.StartSubordinate ( string  name)
inline

Starts the subordinate with the given name;

Parameters
nameThe name of the subordinate to be started.

Implements Apac.Supervisors.ISupervisor.

◆ Stop()

void Apac.Supervisors.Supervisor.Stop ( )
inline

Instructs the supervisor to stop operations. This call results in a No-Op if the supervisor is not running.

Implements Apac.ISupervisable.

◆ StopSubordinate()

void Apac.Supervisors.Supervisor.StopSubordinate ( string  name)
inline

Stops the subordinate with the given name;

Parameters
nameThe name of the subordinate to be stopped.

Implements Apac.Supervisors.ISupervisor.

Property Documentation

◆ CurrentState

SupervisableState Apac.Supervisors.Supervisor.CurrentState
get

Gets the state of the supervisor.

◆ Description

string Apac.Supervisors.Supervisor.Description
get

Get the configured description for the supervisor.

◆ ExecutiveSupervisor

Supervisors.ISupervisor Apac.Supervisors.Supervisor.ExecutiveSupervisor
get

Gets the excecutive supervisor.

◆ IsRunning

bool Apac.Supervisors.Supervisor.IsRunning
get

Gets a value indicating whether this instance is running.

true if this instance is running; otherwise, false.

◆ LastException

Exception Apac.Supervisors.Supervisor.LastException
get

Gets the last exception that occured in the supervisor.

◆ LastHeartbeat

DateTime Apac.Supervisors.Supervisor.LastHeartbeat
get

Gets the last heartbeat.

The last heartbeat.

◆ Log

log4net.ILog Apac.Supervisors.Supervisor.Log
getprotected

Gets the log4net.ILog for the instance.

◆ Name

string Apac.Supervisors.Supervisor.Name
get

Gets the configured name for the supervisor.

◆ PreviousState

SupervisableState Apac.Supervisors.Supervisor.PreviousState
get

Gets the previos state of the supervisor.

◆ Prioritized

bool Apac.Supervisors.Supervisor.Prioritized
get

Indicates if the supervisor should be executed on a higher thread priority.

◆ StartTime

DateTime Apac.Supervisors.Supervisor.StartTime
get

Gets the time this supervisable component was started.

◆ StopTime

DateTime Apac.Supervisors.Supervisor.StopTime
get

Gets the time this supervisable component was stopped.

◆ Subordinates

SupervisableCollection Apac.Supervisors.Supervisor.Subordinates
get

Lazy-initialized list of components that are supervised by this supervisor.

◆ UpTime

TimeSpan Apac.Supervisors.Supervisor.UpTime
get

Gets the amount of time this supervisable component has been running, or did run before it was stopped (if IsRunning is false).

Event Documentation

◆ SupervisableErrored

SupervisableErroredHandler Apac.Supervisors.Supervisor.SupervisableErrored

This event is raised if an exception is encountered by a supervisor.

◆ SupervisableHeartbeat

SupervisableHeartbeatHandler Apac.Supervisors.Supervisor.SupervisableHeartbeat

This event is raised on a periodic basis as a heartbeat to the supervisor.

◆ SupervisableStateChanged

SupervisableStateChangedHandler Apac.Supervisors.Supervisor.SupervisableStateChanged

This event is raised when the supervised state changes. For this event the arguments will contain the previous state and the new state.

◆ SupervisableStateChanging

SupervisableStateChangingHandler Apac.Supervisors.Supervisor.SupervisableStateChanging

This event is raised just prior to the supervised state being changed. For this event the arguments will only contain the current state; use SupervisableStateChangeEventArgs.CurrentState as SupervisableStateChangeEventArgs.CurrentState will always contain SupervisableState.Unknown.


The documentation for this class was generated from the following file: