Package org.opennms.netmgt.bsm.daemon
Class Bsmd
- java.lang.Object
-
- org.opennms.netmgt.bsm.daemon.Bsmd
-
- All Implemented Interfaces:
AlarmLifecycleListener
,BusinessServiceStateChangeHandler
,SpringServiceDaemon
,org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.InitializingBean
public class Bsmd extends Object implements SpringServiceDaemon, BusinessServiceStateChangeHandler, AlarmLifecycleListener
This daemon is responsible for driving the Business Service state machine by: 1) Updating the state machine with Alarms when they are created, deleted or updated 2) Sending events on the event bus when the operational status of a Business Service changes 3) Reloading the Business Service configuration in the state machine when requested- Author:
- jwhite
-
-
Field Summary
Fields Modifier and Type Field Description protected static long
DEFAULT_POLL_INTERVAL
static String
NAME
protected static String
POLL_INTERVAL_KEY
static long
RELOAD_DELAY
-
Constructor Summary
Constructors Constructor Description Bsmd()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
void
destroy()
BusinessServiceStateMachine
getBusinessServiceStateMachine()
EventConfDao
getEventConfDao()
EventIpcManager
getEventIpcManager()
org.springframework.transaction.support.TransactionTemplate
getTransactionTemplate()
boolean
getVerifyReductionKeys()
void
handleAlarmSnapshot(List<OnmsAlarm> alarms)
Called periodically with a complete set of alarms as present in the database at the given timestamp.void
handleBusinessServiceStateChanged(BusinessServiceGraph graph, BusinessService businessService, Status newStatus, Status prevStatus)
Called when the operational status of a business service was changed.void
handleDeletedAlarm(int alarmId, String reductionKey)
Called when an alarm has been deleted.void
handleNewOrUpdatedAlarm(OnmsAlarm alarm)
Called when an alarm has been created or updated.void
handleReloadEvent(IEvent e)
void
postHandleAlarmSnapshot()
Called afterAlarmLifecycleListener.handleAlarmSnapshot(java.util.List<org.opennms.netmgt.model.OnmsAlarm>)
has been called on all the listeners, and after the session & transaction used to perform the snapshot has been closed.void
preHandleAlarmSnapshot()
Called before the transaction is opened and the alarms are read for subsequent calls toAlarmLifecycleListener.handleAlarmSnapshot(java.util.List<org.opennms.netmgt.model.OnmsAlarm>)
.void
serviceInterfaceOrNodeDeleted(IEvent e)
void
setBusinessServiceStateMachine(BusinessServiceStateMachine stateMachine)
void
setEventConfDao(EventConfDao eventConfDao)
void
setEventIpcManager(EventIpcManager eventIpcManager)
void
setTransactionTemplate(org.springframework.transaction.support.TransactionTemplate template)
void
setVerifyReductionKeys(boolean verify)
void
start()
start
-
-
-
Field Detail
-
DEFAULT_POLL_INTERVAL
protected static final long DEFAULT_POLL_INTERVAL
- See Also:
- Constant Field Values
-
POLL_INTERVAL_KEY
protected static final String POLL_INTERVAL_KEY
- See Also:
- Constant Field Values
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
RELOAD_DELAY
public static final long RELOAD_DELAY
- See Also:
- Constant Field Values
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
start
public void start() throws Exception
Description copied from interface:SpringServiceDaemon
start
- Specified by:
start
in interfaceSpringServiceDaemon
- Throws:
Exception
- if any.
-
handleAlarmSnapshot
public void handleAlarmSnapshot(List<OnmsAlarm> alarms)
Description copied from interface:AlarmLifecycleListener
Called periodically with a complete set of alarms as present in the database at the given timestamp. This should be used to synchronize any state to ensure it matches what is currently in the database. Note that it is possible that the *current* state of alarms is different from the state at the time at which the snapshot was taken. Implementations should take this in consideration when performing any state synchronization. This method will be called while the related session & transaction that created the alarm are still open. All of the listeners are invoked serially, so the implementors should avoid blocking when possible.- Specified by:
handleAlarmSnapshot
in interfaceAlarmLifecycleListener
- Parameters:
alarms
- canonical set of alarms in the database
-
preHandleAlarmSnapshot
public void preHandleAlarmSnapshot()
Description copied from interface:AlarmLifecycleListener
Called before the transaction is opened and the alarms are read for subsequent calls toAlarmLifecycleListener.handleAlarmSnapshot(java.util.List<org.opennms.netmgt.model.OnmsAlarm>)
. This can be used to trigger any necessary state tracking to accurately handle the snapshot results.- Specified by:
preHandleAlarmSnapshot
in interfaceAlarmLifecycleListener
-
postHandleAlarmSnapshot
public void postHandleAlarmSnapshot()
Description copied from interface:AlarmLifecycleListener
Called afterAlarmLifecycleListener.handleAlarmSnapshot(java.util.List<org.opennms.netmgt.model.OnmsAlarm>)
has been called on all the listeners, and after the session & transaction used to perform the snapshot has been closed. This can be used to trigger any necessary post-processing of the results once the related session has been closed. This function may be called immediately after a call toAlarmLifecycleListener.preHandleAlarmSnapshot()
if an error occurred while preparing the snapshot i.e. when opening the transaction.- Specified by:
postHandleAlarmSnapshot
in interfaceAlarmLifecycleListener
-
handleNewOrUpdatedAlarm
public void handleNewOrUpdatedAlarm(OnmsAlarm alarm)
Description copied from interface:AlarmLifecycleListener
Called when an alarm has been created or updated. This method will be called while the related session & transaction that created the alarm are still open. All of the listeners are invoked serially, so the implementors should avoid blocking when possible.- Specified by:
handleNewOrUpdatedAlarm
in interfaceAlarmLifecycleListener
- Parameters:
alarm
- a newly created or updated alarm
-
handleDeletedAlarm
public void handleDeletedAlarm(int alarmId, String reductionKey)
Description copied from interface:AlarmLifecycleListener
Called when an alarm has been deleted. This method will be called while the related session & transaction that created the alarm are still open. All of the listeners are invoked serially, so the implementors should avoid blocking when possible.- Specified by:
handleDeletedAlarm
in interfaceAlarmLifecycleListener
- Parameters:
alarmId
- id of the alarm that was deletedreductionKey
- reduction key of the alarm that was deleted
-
serviceInterfaceOrNodeDeleted
public void serviceInterfaceOrNodeDeleted(IEvent e)
-
handleBusinessServiceStateChanged
public void handleBusinessServiceStateChanged(BusinessServiceGraph graph, BusinessService businessService, Status newStatus, Status prevStatus)
Called when the operational status of a business service was changed.- Specified by:
handleBusinessServiceStateChanged
in interfaceBusinessServiceStateChangeHandler
-
handleReloadEvent
public void handleReloadEvent(IEvent e)
-
destroy
public void destroy()
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
-
setEventIpcManager
public void setEventIpcManager(EventIpcManager eventIpcManager)
-
getEventIpcManager
public EventIpcManager getEventIpcManager()
-
setEventConfDao
public void setEventConfDao(EventConfDao eventConfDao)
-
getEventConfDao
public EventConfDao getEventConfDao()
-
setTransactionTemplate
public void setTransactionTemplate(org.springframework.transaction.support.TransactionTemplate template)
-
getTransactionTemplate
public org.springframework.transaction.support.TransactionTemplate getTransactionTemplate()
-
setVerifyReductionKeys
public void setVerifyReductionKeys(boolean verify)
-
getVerifyReductionKeys
public boolean getVerifyReductionKeys()
-
setBusinessServiceStateMachine
public void setBusinessServiceStateMachine(BusinessServiceStateMachine stateMachine)
-
getBusinessServiceStateMachine
public BusinessServiceStateMachine getBusinessServiceStateMachine()
-
-