Package org.opennms.netmgt.config
Class TrapdConfigFactory
- java.lang.Object
-
- org.opennms.netmgt.config.TrapdConfigFactory
-
- All Implemented Interfaces:
TrapdConfig
public final class TrapdConfigFactory extends 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(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.String
getSnmpTrapAddress()
int
getSnmpTrapPort()
Return the port on which SNMP traps should be received.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)
-
-
-
Constructor Detail
-
TrapdConfigFactory
public TrapdConfigFactory(InputStream stream) throws IOException
Constructor for TrapdConfigFactory.
- Parameters:
stream
- aInputStream
object.- Throws:
IOException
-
-
Method Detail
-
init
public static void init() throws IOException
Load the config from the default config file and create the singleton instance of this factory.- Throws:
IOException
- Thrown if the specified config file cannot be readIOException
- if any.
-
reload
public static void reload() throws IOException
Reload the config from the default config file- Throws:
IOException
- Thrown if the specified config file cannot be read/loadedIOException
- if any.
-
getInstance
public static TrapdConfig getInstance()
Return the singleton instance of this factory.- Returns:
- The current factory instance.
- Throws:
IllegalStateException
- Thrown if the factory has not yet been initialized.
-
setInstance
public static void setInstance(TrapdConfig config)
setInstance
- Parameters:
config
- aTrapdConfig
object.
-
getSnmpTrapAddress
public 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 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()
-
-