obixserver.core.alarm
Class AlarmManager

java.lang.Object
  extended by obix.Obj
      extended by obix.Ref
          extended by obixserver.core.InvocationObj
              extended by obixserver.core.alarm.AlarmManager
All Implemented Interfaces:
obix.IObj, InvocationTarget, Service

public class AlarmManager
extends InvocationObj
implements Service

Manages alarm lifecycle: creation, deletion and updates. Alarms are registered by associating conditions with observables (Objs). A condition may have one or more observables associated with it. E.g. they can check if a Real obj representing temperature is higher then a given threshold, or it can check if two Real objs representing temperatures at two points have difference greater than a certain value. The following relationships are part of an Alarm/Condition/Obj interaction: One condition uses one Obj. One condition uses two Objs. An Obj is used by one Condition An Obj is used by several Conditions An alarm is raised because condition evaluates to false. A condition is associated with one alarm instance. A condition is associated with several alarm instances.


Field Summary
private  obix.Obj alarmBase
          Object that will be parent of newly created alarms
private  String alarmServiceUrl
           
private  Map conditionToAlarmMap
          Map for lookup of alarm by condition.
private  Map conditionToObjListMap
          Map a Condition to a list of Objs.
private  Map objToAlarmMap
          Map for lookup of alarm by obj.
private  Map objToConditionListMap
          Maps an obj to a list of Conditions.
 
Fields inherited from class obixserver.core.InvocationObj
objBroker
 
Constructor Summary
AlarmManager()
           
 
Method Summary
 void addCondition(Condition c)
          Adds condition to the alarm manager.
private  void addToObjToConditionListMap(obix.Obj obj, Condition condition)
           
private  List conditionsForTree(obix.Obj obj)
          Return all conditions for all obj's that are elements of the tree
private  void deleteConditionFromObjToConditionListMap(Condition condition)
           
private  void deleteObjFromConditionsInObjToConditionListMap(obix.Obj obj)
           
 String getAlarmServiceUrl()
           
 Collection getAllarms()
          Return all alarms.
 obix.Obj invoke(String name, obix.Obj arg)
           
 void notifyStatusChange(obix.Obj obj)
          Processes notification about status change of an obj.
 void removeCondition(Condition c)
          Removes condition from alarm manager.
 void removeConditionsForObj(obix.Obj obj)
          Invoked when an obj is deleted from the system and therefore alarm manager needs to cleanup associated data.
private  void removeFromObjToConditionListMap(obix.Obj obj, Condition condition)
           
 void setAlarmServiceUrl(String alarmServiceUrl)
           
 void start()
          Starts the service.
 void stop()
          Stops the service.
 
Methods inherited from class obixserver.core.InvocationObj
getOp, setObjBroker
 
Methods inherited from class obix.Ref
getElement, getResolved, isResolved, toString
 
Methods inherited from class obix.Obj
add, add, addAll, dump, get, getBool, getChildHref, getDisplay, getDisplayName, getHref, getIcon, getInt, getIs, getName, getNormalizedHref, getParent, getReal, getRoot, getStatus, getStr, has, is, is, isAbstime, isBool, isEnum, isErr, isFeed, isInt, isList, isNull, isOp, isReal, isRef, isReltime, isStr, isUri, isVal, isWritable, list, list, remove, removeThis, replace, setBool, setDisplay, setDisplayName, setHref, setIcon, setInt, setIs, setName, setNull, setReal, setStatus, setStr, setWritable, setWritable, size, toClass, toDisplayName, toDisplayString, toObj
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface obix.IObj
add, addAll, get, getBool, getDisplay, getDisplayName, getHref, getIcon, getInt, getIs, getName, getNormalizedHref, getParent, getReal, getRoot, getStatus, getStr, isAbstime, isBool, isEnum, isErr, isFeed, isInt, isList, isNull, isOp, isReal, isRef, isReltime, isStr, isUri, isVal, isWritable, list, remove, removeThis, replace, setBool, setDisplay, setDisplayName, setHref, setIcon, setInt, setIs, setNull, setReal, setStatus, setStr, setWritable, setWritable, size, toDisplayName, toDisplayString
 

Field Detail

alarmServiceUrl

private String alarmServiceUrl

conditionToObjListMap

private Map conditionToObjListMap
Map a Condition to a list of Objs. obj -> objList map


objToConditionListMap

private Map objToConditionListMap
Maps an obj to a list of Conditions. One obj can map to one or more Conditions. obj -> conditionList


conditionToAlarmMap

private Map conditionToAlarmMap
Map for lookup of alarm by condition. Condition -> Alarm.


objToAlarmMap

private Map objToAlarmMap
Map for lookup of alarm by obj. Obj -> Alarm.


alarmBase

private obix.Obj alarmBase
Object that will be parent of newly created alarms

Constructor Detail

AlarmManager

public AlarmManager()
Method Detail

start

public void start()
           throws ObixserverException
Description copied from interface: Service
Starts the service.

Specified by:
start in interface Service
Throws:
ObixserverException - if an error occurs during start invocation.

stop

public void stop()
          throws ObixserverException
Description copied from interface: Service
Stops the service.

Specified by:
stop in interface Service
Throws:
ObixserverException - if an error occurs during stop invocation.

invoke

public obix.Obj invoke(String name,
                       obix.Obj arg)
Specified by:
invoke in interface InvocationTarget
Overrides:
invoke in class InvocationObj

addCondition

public void addCondition(Condition c)
Adds condition to the alarm manager. Changes to observable that meet the condition will raise alarms.


removeCondition

public void removeCondition(Condition c)
Removes condition from alarm manager. Futher changes to observable will not raise alarm.

Parameters:
c - condition to be removed

notifyStatusChange

public void notifyStatusChange(obix.Obj obj)
Processes notification about status change of an obj. Checks all conditions for this obj and raises alarm if a condition is met

Parameters:
obj -

removeConditionsForObj

public void removeConditionsForObj(obix.Obj obj)
Invoked when an obj is deleted from the system and therefore alarm manager needs to cleanup associated data.

Parameters:
obj -

getAllarms

public Collection getAllarms()
Return all alarms. Alarms are ordered in decending order by time.

Returns:
collection of alarms.

conditionsForTree

private List conditionsForTree(obix.Obj obj)
Return all conditions for all obj's that are elements of the tree

Parameters:
obj -
Returns:
list of conditions

deleteObjFromConditionsInObjToConditionListMap

private void deleteObjFromConditionsInObjToConditionListMap(obix.Obj obj)

deleteConditionFromObjToConditionListMap

private void deleteConditionFromObjToConditionListMap(Condition condition)

addToObjToConditionListMap

private void addToObjToConditionListMap(obix.Obj obj,
                                        Condition condition)

removeFromObjToConditionListMap

private void removeFromObjToConditionListMap(obix.Obj obj,
                                             Condition condition)

getAlarmServiceUrl

public String getAlarmServiceUrl()

setAlarmServiceUrl

public void setAlarmServiceUrl(String alarmServiceUrl)


Copyright © 2006-2008 Peter Michalek All Rights Reserved.