Package org.opennms.netmgt.config
Class TrapdConfigFactory
- java.lang.Object
-
- org.opennms.netmgt.config.TrapdConfigFactory
-
- All Implemented Interfaces:
TrapdConfig
public final class TrapdConfigFactory extends java.lang.Object implements TrapdConfig
This is the singleton class used to load the configuration for the OpenNMS Trapd from the trapd-configuration.xml. Note: Users of this class should make sure the init() is called before calling any other method to ensure the config is loaded before accessing other convenience methods.- Author:
- Sowmya Nataraj , Tarus Balog , OpenNMS
-
-
Constructor Summary
Constructors Constructor Description TrapdConfigFactory(java.io.InputStream stream)
Constructor for TrapdConfigFactory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getBatchIntervalMs()
Messages are aggregated in batches before being dispatched.int
getBatchSize()
Messages are aggregated in batches before being dispatched.TrapdConfiguration
getConfig()
static TrapdConfig
getInstance()
Return the singleton instance of this factory.boolean
getNewSuspectOnTrap()
Return whether or not a newSuspect event should be sent when a trap is received from an unknown IP address.int
getNumThreads()
Number of threads used for consuming/dispatching messages.int
getQueueSize()
Maximum number of messages to keep in memory while waiting to be dispatched.java.lang.String
getSnmpTrapAddress()
int
getSnmpTrapPort()
Return the port on which SNMP traps should be received.java.util.List<SnmpV3User>
getSnmpV3Users()
static void
init()
Load the config from the default config file and create the singleton instance of this factory.boolean
isIncludeRawMessage()
static void
reload()
Reload the config from the default config filestatic void
setInstance(TrapdConfig config)
setInstanceboolean
shouldUseAddressFromVarbind()
void
update(TrapdConfig config)
-
-
-
Method Detail
-
init
public static void init() throws java.io.IOException
Load the config from the default config file and create the singleton instance of this factory.- Throws:
java.io.IOException
- Thrown if the specified config file cannot be readjava.io.IOException
- if any.
-
reload
public static void reload() throws java.io.IOException
Reload the config from the default config file- Throws:
java.io.IOException
- Thrown if the specified config file cannot be read/loadedjava.io.IOException
- if any.
-
getInstance
public static TrapdConfig getInstance()
Return the singleton instance of this factory.- Returns:
- The current factory instance.
- Throws:
java.lang.IllegalStateException
- Thrown if the factory has not yet been initialized.
-
setInstance
public static void setInstance(TrapdConfig config)
setInstance
- Parameters:
config
- aTrapdConfig
object.
-
getSnmpTrapAddress
public java.lang.String getSnmpTrapAddress()
- Specified by:
getSnmpTrapAddress
in interfaceTrapdConfig
-
getSnmpTrapPort
public int getSnmpTrapPort()
Return the port on which SNMP traps should be received.- Specified by:
getSnmpTrapPort
in interfaceTrapdConfig
- Returns:
- the port on which SNMP traps should be received
-
getNewSuspectOnTrap
public boolean getNewSuspectOnTrap()
Return whether or not a newSuspect event should be sent when a trap is received from an unknown IP address.- Specified by:
getNewSuspectOnTrap
in interfaceTrapdConfig
- Returns:
- whether to generate newSuspect events on traps.
-
getSnmpV3Users
public java.util.List<SnmpV3User> getSnmpV3Users()
- Specified by:
getSnmpV3Users
in interfaceTrapdConfig
-
isIncludeRawMessage
public boolean isIncludeRawMessage()
- Specified by:
isIncludeRawMessage
in interfaceTrapdConfig
-
getNumThreads
public int getNumThreads()
Description copied from interface:TrapdConfig
Number of threads used for consuming/dispatching messages.- Specified by:
getNumThreads
in interfaceTrapdConfig
- Returns:
- number of threads
-
getQueueSize
public int getQueueSize()
Description copied from interface:TrapdConfig
Maximum number of messages to keep in memory while waiting to be dispatched.- Specified by:
getQueueSize
in interfaceTrapdConfig
- Returns:
- queue size
-
getBatchSize
public int getBatchSize()
Description copied from interface:TrapdConfig
Messages are aggregated in batches before being dispatched. When the batch reaches this size, it will be dispatched.- Specified by:
getBatchSize
in interfaceTrapdConfig
- Returns:
- batch size
-
getBatchIntervalMs
public int getBatchIntervalMs()
Description copied from interface:TrapdConfig
Messages are aggregated in batches before being dispatched. When the batch has been created for longer than this interval it will be dispatched, regardless of the size.- Specified by:
getBatchIntervalMs
in interfaceTrapdConfig
- Returns:
- interval in ms
-
shouldUseAddressFromVarbind
public boolean shouldUseAddressFromVarbind()
- Specified by:
shouldUseAddressFromVarbind
in interfaceTrapdConfig
-
update
public void update(TrapdConfig config)
- Specified by:
update
in interfaceTrapdConfig
-
getConfig
public TrapdConfiguration getConfig()
-
-