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 intgetBatchIntervalMs()Messages are aggregated in batches before being dispatched.intgetBatchSize()Messages are aggregated in batches before being dispatched.TrapdConfigurationgetConfig()static TrapdConfiggetInstance()Return the singleton instance of this factory.booleangetNewSuspectOnTrap()Return whether or not a newSuspect event should be sent when a trap is received from an unknown IP address.intgetNumThreads()Number of threads used for consuming/dispatching messages.intgetQueueSize()Maximum number of messages to keep in memory while waiting to be dispatched.StringgetSnmpTrapAddress()intgetSnmpTrapPort()Return the port on which SNMP traps should be received.List<SnmpV3User>getSnmpV3Users()static voidinit()Load the config from the default config file and create the singleton instance of this factory.booleanisIncludeRawMessage()static voidreload()Reload the config from the default config filestatic voidsetInstance(TrapdConfig config)setInstancebooleanshouldUseAddressFromVarbind()voidupdate(TrapdConfig config)
-
-
-
Constructor Detail
-
TrapdConfigFactory
public TrapdConfigFactory(InputStream stream) throws IOException
Constructor for TrapdConfigFactory.
- Parameters:
stream- aInputStreamobject.- Throws:
IOException
-
-
Method Detail
-
init
public static void init() throws IOExceptionLoad 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 IOExceptionReload 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- aTrapdConfigobject.
-
getSnmpTrapAddress
public String getSnmpTrapAddress()
- Specified by:
getSnmpTrapAddressin interfaceTrapdConfig
-
getSnmpTrapPort
public int getSnmpTrapPort()
Return the port on which SNMP traps should be received.- Specified by:
getSnmpTrapPortin 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:
getNewSuspectOnTrapin interfaceTrapdConfig- Returns:
- whether to generate newSuspect events on traps.
-
getSnmpV3Users
public List<SnmpV3User> getSnmpV3Users()
- Specified by:
getSnmpV3Usersin interfaceTrapdConfig
-
isIncludeRawMessage
public boolean isIncludeRawMessage()
- Specified by:
isIncludeRawMessagein interfaceTrapdConfig
-
getNumThreads
public int getNumThreads()
Description copied from interface:TrapdConfigNumber of threads used for consuming/dispatching messages.- Specified by:
getNumThreadsin interfaceTrapdConfig- Returns:
- number of threads
-
getQueueSize
public int getQueueSize()
Description copied from interface:TrapdConfigMaximum number of messages to keep in memory while waiting to be dispatched.- Specified by:
getQueueSizein interfaceTrapdConfig- Returns:
- queue size
-
getBatchSize
public int getBatchSize()
Description copied from interface:TrapdConfigMessages are aggregated in batches before being dispatched. When the batch reaches this size, it will be dispatched.- Specified by:
getBatchSizein interfaceTrapdConfig- Returns:
- batch size
-
getBatchIntervalMs
public int getBatchIntervalMs()
Description copied from interface:TrapdConfigMessages 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:
getBatchIntervalMsin interfaceTrapdConfig- Returns:
- interval in ms
-
shouldUseAddressFromVarbind
public boolean shouldUseAddressFromVarbind()
- Specified by:
shouldUseAddressFromVarbindin interfaceTrapdConfig
-
update
public void update(TrapdConfig config)
- Specified by:
updatein interfaceTrapdConfig
-
getConfig
public TrapdConfiguration getConfig()
-
-