Class AbstractNorthbounder
- java.lang.Object
-
- org.opennms.netmgt.alarmd.api.support.AbstractNorthbounder
-
- All Implemented Interfaces:
java.lang.Runnable
,Northbounder
,StatusFactory<NorthboundAlarm>
- Direct Known Subclasses:
AlarmNorthbounder
,BSFNorthbounder
,DroolsNorthbounder
,EmailNorthbounder
,HttpNorthbounder
,JmsNorthbounder
,SnmpTrapNorthbounder
,SyslogNorthbounder
public abstract class AbstractNorthbounder extends java.lang.Object implements Northbounder, java.lang.Runnable, StatusFactory<NorthboundAlarm>
AbstractNorthBounderThe purpose of this class is manage the queue of alarms that need to be forward and receive queries to/from a Southbound Interface.
It passes Alarms on to the forwardAlarms method implemented by base classes in batches as they are added to the queue. The forwardAlarms method does the actual work of sending them to the Southbound Interface.
Preserve, accept and discard are called to add the Alarms to the queue as appropriate.
- Author:
- David Hustace, Alejandro Galue
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNorthbounder(java.lang.String name)
Instantiates a new abstract northbounder.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract boolean
accepts(NorthboundAlarm alarm)
Accepts.protected java.util.Map<java.lang.String,java.lang.Object>
createMapping(NorthboundAlarm alarm, java.lang.String dateFormat)
Creates the mapping.NorthboundAlarm
createSyncLostMessage()
Creates a new Status object.protected void
discard(NorthboundAlarm alarm)
Discard.abstract void
forwardAlarms(java.util.List<NorthboundAlarm> alarms)
Forward alarms.java.lang.String
getName()
Gets the name.void
onAlarm(NorthboundAlarm alarm)
On alarm.protected void
onPostStart()
Override this to perform actions after startup.protected void
onPreStart()
Override this to perform actions before startup.protected void
onStop()
Override this to perform actions when stopping.protected void
preserve(NorthboundAlarm alarm)
Preserve.void
reloadConfig()
Override this to perform actions when reloading the configuration.void
run()
void
setMaxBatchSize(int maxBatchSize)
Sets the max batch size.void
setMaxPreservedAlarms(int maxPreservedAlarms)
Sets the max preserved alarms.void
setNaglesDelay(long delay)
Sets the nagles delay.void
setRetryInterval(int retryInterval)
Sets the retry interval.void
start()
Start.void
stop()
Stop.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opennms.netmgt.alarmd.api.Northbounder
isReady
-
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:Northbounder
Gets the name.- Specified by:
getName
in interfaceNorthbounder
- Returns:
- the name
-
setNaglesDelay
public void setNaglesDelay(long delay)
Sets the nagles delay.- Parameters:
delay
- the new nagles delay
-
setRetryInterval
public void setRetryInterval(int retryInterval)
Sets the retry interval.- Parameters:
retryInterval
- the new retry interval
-
setMaxBatchSize
public void setMaxBatchSize(int maxBatchSize)
Sets the max batch size.- Parameters:
maxBatchSize
- the new max batch size
-
setMaxPreservedAlarms
public void setMaxPreservedAlarms(int maxPreservedAlarms)
Sets the max preserved alarms.- Parameters:
maxPreservedAlarms
- the new max preserved alarms
-
onPreStart
protected void onPreStart()
Override this to perform actions before startup.
-
onPostStart
protected void onPostStart()
Override this to perform actions after startup.
-
start
public final void start() throws NorthbounderException
Description copied from interface:Northbounder
Start.- Specified by:
start
in interfaceNorthbounder
- Throws:
NorthbounderException
- the northbounder exception
-
onAlarm
public final void onAlarm(NorthboundAlarm alarm) throws NorthbounderException
Description copied from interface:Northbounder
On alarm.- Specified by:
onAlarm
in interfaceNorthbounder
- Parameters:
alarm
- the alarm- Throws:
NorthbounderException
- the northbounder exception
-
accepts
protected abstract boolean accepts(NorthboundAlarm alarm)
Accepts.- Parameters:
alarm
- the alarm- Returns:
- true, if successful
-
preserve
protected void preserve(NorthboundAlarm alarm) throws NorthbounderException
Preserve.- Parameters:
alarm
- the alarm- Throws:
NorthbounderException
- the northbounder exception
-
discard
protected void discard(NorthboundAlarm alarm) throws NorthbounderException
Discard.- Parameters:
alarm
- the alarm- Throws:
NorthbounderException
- the northbounder exception
-
onStop
protected void onStop()
Override this to perform actions when stopping.
-
reloadConfig
public void reloadConfig()
Override this to perform actions when reloading the configuration.- Specified by:
reloadConfig
in interfaceNorthbounder
-
stop
public final void stop() throws NorthbounderException
Description copied from interface:Northbounder
Stop.- Specified by:
stop
in interfaceNorthbounder
- Throws:
NorthbounderException
- the northbounder exception
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
createSyncLostMessage
public NorthboundAlarm createSyncLostMessage()
Description copied from interface:StatusFactory
Creates a new Status object.- Specified by:
createSyncLostMessage
in interfaceStatusFactory<NorthboundAlarm>
- Returns:
- the generic type object
-
forwardAlarms
public abstract void forwardAlarms(java.util.List<NorthboundAlarm> alarms) throws NorthbounderException
Forward alarms.- Parameters:
alarms
- the alarms- Throws:
NorthbounderException
- the northbounder exception
-
createMapping
protected java.util.Map<java.lang.String,java.lang.Object> createMapping(NorthboundAlarm alarm, java.lang.String dateFormat)
Creates the mapping.- Parameters:
alarmMappings
- the alarm mappingsalarm
- the northbound alarm- Returns:
- the mapping object
-
-