Interface MonitorAdmin
-
public interface MonitorAdminTheMonitorAdminservice is a singleton service that handlesStatusVariablequery requests and measurement job control requests.Note that an alternative but not recommended way of obtaining
StatusVariables is that applications having the requiredServicePermissionscan query the list ofMonitorableservices from the service registry and then query the list ofStatusVariablenames from theMonitorableservices. This way all services which publishStatusVariables will be returned regardless of whether they do or do not hold the necessaryMonitorPermissionfor publishingStatusVariables. By using theMonitorAdminto obtain theStatusVariables it is guaranteed that only thoseMonitorableservices will be accessed who are authorized to publishStatusVariables. It is the responsibility of theMonitorAdminimplementation to check the required permissions and show only those variables which pass this check.The events posted by
MonitorAdmincontain the following properties:mon.monitorable.pid: The identifier of theMonitorablemon.statusvariable.name: The identifier of theStatusVariablewithin the givenMonitorablemon.statusvariable.value: The value of theStatusVariable, represented as aStringmon.listener.id: The identifier of the initiator of the monitoring job (only present if the event was generated due to a monitoring job)
Most of the methods require either a Monitorable ID or a Status Variable path parameter, the latter in [Monitorable_ID]/[StatusVariable_ID] format. These parameters must not be
null, and the IDs they contain must conform to their respective definitions inMonitorableandStatusVariable. If any of the restrictions are violated, the method must throw anIllegalArgumentException.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringgetDescription(java.lang.String path)Returns a human readable description of the givenStatusVariable.java.lang.String[]getMonitorableNames()Returns the names of theMonitorableservices that are currently registered.MonitoringJob[]getRunningJobs()Returns the list of currently runningMonitoringJobs.StatusVariablegetStatusVariable(java.lang.String path)Returns aStatusVariableaddressed by its full path.java.lang.String[]getStatusVariableNames(java.lang.String monitorableId)Returns the list ofStatusVariablenames published by aMonitorableinstance.StatusVariable[]getStatusVariables(java.lang.String monitorableId)Returns theStatusVariableobjects published by aMonitorableinstance.booleanresetStatusVariable(java.lang.String path)Issues a request to reset a givenStatusVariable.MonitoringJobstartJob(java.lang.String initiator, java.lang.String[] statusVariables, int count)Starts a change basedMonitoringJobwith the parameters provided.MonitoringJobstartScheduledJob(java.lang.String initiator, java.lang.String[] statusVariables, int schedule, int count)Starts a time basedMonitoringJobwith the parameters provided.voidswitchEvents(java.lang.String path, boolean on)Switches event sending on or off for the specifiedStatusVariables.
-
-
-
Method Detail
-
getStatusVariable
StatusVariable getStatusVariable(java.lang.String path) throws java.lang.IllegalArgumentException, java.lang.SecurityException
Returns aStatusVariableaddressed by its full path. The entity which queries aStatusVariableneeds to holdMonitorPermissionfor the given target with thereadaction present.- Parameters:
path- the full path of theStatusVariablein [Monitorable_ID]/[StatusVariable_ID] format- Returns:
- the
StatusVariableobject - Throws:
java.lang.IllegalArgumentException- ifpathisnullor otherwise invalid, or points to a non-existingStatusVariablejava.lang.SecurityException- if the caller does not hold aMonitorPermissionfor theStatusVariablespecified bypathwith thereadaction present
-
getMonitorableNames
java.lang.String[] getMonitorableNames()
Returns the names of theMonitorableservices that are currently registered. TheMonitorableinstances are not accessible through theMonitorAdmin, so that requests to individual status variables can be filtered with respect to the publishing rights of theMonitorableand the reading rights of the caller.The returned array contains the names in alphabetical order. It cannot be
null, an empty array is returned if noMonitorableservices are registered.- Returns:
- the array of
Monitorablenames
-
getStatusVariables
StatusVariable[] getStatusVariables(java.lang.String monitorableId) throws java.lang.IllegalArgumentException
Returns theStatusVariableobjects published by aMonitorableinstance. TheStatusVariableswill hold the values taken at the time of this method call. Only those status variables are returned where the following two conditions are met:- the specified
Monitorableholds aMonitorPermissionfor the status variable with thepublishaction present - the caller holds a
MonitorPermissionfor the status variable with thereadaction present
The elements in the returned array are in no particular order. The return value cannot be
null, an empty array is returned if no (authorized and readable) Status Variables are provided by the givenMonitorable.- Parameters:
monitorableId- the identifier of aMonitorableinstance- Returns:
- a list of
StatusVariableobjects published by the specifiedMonitorable - Throws:
java.lang.IllegalArgumentException- ifmonitorableIdisnullor otherwise invalid, or points to a non-existingMonitorable
- the specified
-
getStatusVariableNames
java.lang.String[] getStatusVariableNames(java.lang.String monitorableId) throws java.lang.IllegalArgumentExceptionReturns the list ofStatusVariablenames published by aMonitorableinstance. Only those status variables are listed where the following two conditions are met:- the specified
Monitorableholds aMonitorPermissionfor the status variable with thepublishaction present - the caller holds a
MonitorPermissionfor the status variable with thereadaction present
The returned array does not contain duplicates, and the elements are in alphabetical order. It cannot be
null, an empty array is returned if no (authorized and readable) Status Variables are provided by the givenMonitorable.- Parameters:
monitorableId- the identifier of aMonitorableinstance- Returns:
- a list of
StatusVariableobjects names published by the specifiedMonitorable - Throws:
java.lang.IllegalArgumentException- ifmonitorableIdisnullor otherwise invalid, or points to a non-existingMonitorable
- the specified
-
switchEvents
void switchEvents(java.lang.String path, boolean on) throws java.lang.IllegalArgumentException, java.lang.SecurityExceptionSwitches event sending on or off for the specifiedStatusVariables. When theMonitorAdminis notified about aStatusVariablebeing updated it sends an event unless this feature is switched off. Note that events within a monitoring job can not be switched off. The event sending state of theStatusVariablesmust not be persistently stored. When aStatusVariableis registered for the first time in a framework session, its event sending state is set to ON by default.Usage of the "*" wildcard is allowed in the path argument of this method as a convenience feature. The wildcard can be used in either or both path fragments, but only at the end of the fragments. The semantics of the wildcard is that it stands for any matching
StatusVariableat the time of the method call, it does not affect the event sending status ofStatusVariables which are not yet registered. As an example, when theswitchEvents("MyMonitorable/*", false)method is executed, event sending from allStatusVariablesof the MyMonitorable service are switched off. However, if the MyMonitorable service starts to publish a newStatusVariablelater, it's event sending status is on by default.- Parameters:
path- the identifier of theStatusVariable(s) in [Monitorable_id]/[StatusVariable_id] format, possibly with the "*" wildcard at the end of either path fragmenton-falseif event sending should be switched off,trueif it should be switched on for the given path- Throws:
java.lang.SecurityException- if the caller does not holdMonitorPermissionwith theswitcheventsaction or if there is anyStatusVariablein thepathfield for which it is not allowed to switch event sending on or off as per the target field of the permissionjava.lang.IllegalArgumentException- ifpathisnullor otherwise invalid, or points to a non-existingStatusVariable
-
resetStatusVariable
boolean resetStatusVariable(java.lang.String path) throws java.lang.IllegalArgumentException, java.lang.SecurityExceptionIssues a request to reset a givenStatusVariable. Depending on the semantics of theStatusVariablethis call may or may not succeed: it makes sense to reset a counter to its starting value, but e.g. aStatusVariableof type String might not have a meaningful default value. Note that for numericStatusVariables the starting value may not necessarily be 0. Resetting aStatusVariabletriggers a monitor event if theStatusVariablesupports update notifications.The entity that wants to reset the
StatusVariableneeds to holdMonitorPermissionwith theresetaction present. The target field of the permission must match theStatusVariablename to be reset.- Parameters:
path- the identifier of theStatusVariablein [Monitorable_id]/[StatusVariable_id] format- Returns:
trueif theMonitorablecould successfully reset the givenStatusVariable,falseotherwise- Throws:
java.lang.IllegalArgumentException- ifpathisnullor otherwise invalid, or points to a non-existingStatusVariablejava.lang.SecurityException- if the caller does not holdMonitorPermissionwith theresetaction or if the specifiedStatusVariableis not allowed to be reset as per the target field of the permission
-
getDescription
java.lang.String getDescription(java.lang.String path) throws java.lang.IllegalArgumentException, java.lang.SecurityExceptionReturns a human readable description of the givenStatusVariable. Thenullvalue may be returned if there is no description for the givenStatusVariable.The entity that queries a
StatusVariableneeds to holdMonitorPermissionfor the given target with thereadaction present.- Parameters:
path- the full path of theStatusVariablein [Monitorable_ID]/[StatusVariable_ID] format- Returns:
- the human readable description of this
StatusVariableornullif it is not set - Throws:
java.lang.IllegalArgumentException- ifpathisnullor otherwise invalid, or points to a non-existingStatusVariablejava.lang.SecurityException- if the caller does not hold aMonitorPermissionfor theStatusVariablespecified bypathwith thereadaction present
-
startScheduledJob
MonitoringJob startScheduledJob(java.lang.String initiator, java.lang.String[] statusVariables, int schedule, int count) throws java.lang.IllegalArgumentException, java.lang.SecurityException
Starts a time basedMonitoringJobwith the parameters provided. Monitoring events will be sent according to the specified schedule. All specifiedStatusVariables must exist when the job is started. The initiator string is used in themon.listener.idfield of all events triggered by the job, to allow filtering the events based on the initiator.The
scheduleparameter specifies the time in seconds between two measurements, it must be greater than 0. The first measurement will be taken when the timer expires for the first time, not when this method is called.The
countparameter defines the number of measurements to be taken, and must either be a positive integer, or 0 if the measurement is to run until explicitly stopped.The entity which initiates a
MonitoringJobneeds to holdMonitorPermissionfor all the specified targetStatusVariables with thestartjobaction present. If the permission's action string specifies a minimal sampling interval then thescheduleparameter should be at least as great as the value in the action string.- Parameters:
initiator- the identifier of the entity that initiated the jobstatusVariables- the list ofStatusVariables to be monitored, with eachStatusVariablename given in [Monitorable_PID]/[StatusVariable_ID] formatschedule- the time in seconds between two measurementscount- the number of measurements to be taken, or 0 for the measurement to run until explicitly stopped- Returns:
- the successfully started job object, cannot be
null - Throws:
java.lang.IllegalArgumentException- if the list ofStatusVariablenames contains an invalid or non-existingStatusVariable; ifinitiatorisnullor empty; or if thescheduleorcountparameters are invalidjava.lang.SecurityException- if the caller does not holdMonitorPermissionfor all the specifiedStatusVariables, with thestartjobaction present, or if the permission does not allow starting the job with the given frequency
-
startJob
MonitoringJob startJob(java.lang.String initiator, java.lang.String[] statusVariables, int count) throws java.lang.IllegalArgumentException, java.lang.SecurityException
Starts a change basedMonitoringJobwith the parameters provided. Monitoring events will be sent when theStatusVariables of this job are updated. All specifiedStatusVariables must exist when the job is started, and all must support update notifications. The initiator string is used in themon.listener.idfield of all events triggered by the job, to allow filtering the events based on the initiator.The
countparameter specifies the number of changes that must happen to aStatusVariablebefore a new notification is sent, this must be a positive integer.The entity which initiates a
MonitoringJobneeds to holdMonitorPermissionfor all the specified targetStatusVariables with thestartjobaction present.- Parameters:
initiator- the identifier of the entity that initiated the jobstatusVariables- the list ofStatusVariables to be monitored, with eachStatusVariablename given in [Monitorable_PID]/[StatusVariable_ID] formatcount- the number of changes that must happen to aStatusVariablebefore a new notification is sent- Returns:
- the successfully started job object, cannot be
null - Throws:
java.lang.IllegalArgumentException- if the list ofStatusVariablenames contains an invalid or non-existingStatusVariable, or one that does not support notifications; if theinitiatorisnullor empty; or ifcountis invalidjava.lang.SecurityException- if the caller does not holdMonitorPermissionfor all the specifiedStatusVariables, with thestartjobaction present
-
getRunningJobs
MonitoringJob[] getRunningJobs()
Returns the list of currently runningMonitoringJobs. Jobs are only visible to callers that have the necessary permissions: to receive a Monitoring Job in the returned list, the caller must hold all permissions required for starting the job. This means that if the caller does not haveMonitorPermissionwith the properstartjobaction for all the Status Variables monitored by a job, then that job will be silently omitted from the results.The returned array cannot be
null, an empty array is returned if there are no running jobs visible to the caller at the time of the call.- Returns:
- the list of running jobs visible to the caller
-
-