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 longDEFAULT_POLL_INTERVALstatic StringNAMEprotected static StringPOLL_INTERVAL_KEYstatic longRELOAD_DELAY
-
Constructor Summary
Constructors Constructor Description Bsmd()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()voiddestroy()BusinessServiceStateMachinegetBusinessServiceStateMachine()EventConfDaogetEventConfDao()EventIpcManagergetEventIpcManager()org.springframework.transaction.support.TransactionTemplategetTransactionTemplate()booleangetVerifyReductionKeys()voidhandleAlarmSnapshot(List<OnmsAlarm> alarms)Called periodically with a complete set of alarms as present in the database at the given timestamp.voidhandleBusinessServiceStateChanged(BusinessServiceGraph graph, BusinessService businessService, Status newStatus, Status prevStatus)Called when the operational status of a business service was changed.voidhandleDeletedAlarm(int alarmId, String reductionKey)Called when an alarm has been deleted.voidhandleNewOrUpdatedAlarm(OnmsAlarm alarm)Called when an alarm has been created or updated.voidhandleReloadEvent(IEvent e)voidpostHandleAlarmSnapshot()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.voidpreHandleAlarmSnapshot()Called before the transaction is opened and the alarms are read for subsequent calls toAlarmLifecycleListener.handleAlarmSnapshot(java.util.List<org.opennms.netmgt.model.OnmsAlarm>).voidserviceInterfaceOrNodeDeleted(IEvent e)voidsetBusinessServiceStateMachine(BusinessServiceStateMachine stateMachine)voidsetEventConfDao(EventConfDao eventConfDao)voidsetEventIpcManager(EventIpcManager eventIpcManager)voidsetTransactionTemplate(org.springframework.transaction.support.TransactionTemplate template)voidsetVerifyReductionKeys(boolean verify)voidstart()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:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
start
public void start() throws ExceptionDescription copied from interface:SpringServiceDaemonstart
- Specified by:
startin interfaceSpringServiceDaemon- Throws:
Exception- if any.
-
handleAlarmSnapshot
public void handleAlarmSnapshot(List<OnmsAlarm> alarms)
Description copied from interface:AlarmLifecycleListenerCalled 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:
handleAlarmSnapshotin interfaceAlarmLifecycleListener- Parameters:
alarms- canonical set of alarms in the database
-
preHandleAlarmSnapshot
public void preHandleAlarmSnapshot()
Description copied from interface:AlarmLifecycleListenerCalled 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:
preHandleAlarmSnapshotin interfaceAlarmLifecycleListener
-
postHandleAlarmSnapshot
public void postHandleAlarmSnapshot()
Description copied from interface:AlarmLifecycleListenerCalled 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:
postHandleAlarmSnapshotin interfaceAlarmLifecycleListener
-
handleNewOrUpdatedAlarm
public void handleNewOrUpdatedAlarm(OnmsAlarm alarm)
Description copied from interface:AlarmLifecycleListenerCalled 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:
handleNewOrUpdatedAlarmin interfaceAlarmLifecycleListener- Parameters:
alarm- a newly created or updated alarm
-
handleDeletedAlarm
public void handleDeletedAlarm(int alarmId, String reductionKey)Description copied from interface:AlarmLifecycleListenerCalled 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:
handleDeletedAlarmin 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:
handleBusinessServiceStateChangedin interfaceBusinessServiceStateChangeHandler
-
handleReloadEvent
public void handleReloadEvent(IEvent e)
-
destroy
public void destroy()
- Specified by:
destroyin 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()
-
-