HOME

com.ireasoning.protocol.snmp
Class DefaultAgentConfig

java.lang.Object
  extended bycom.ireasoning.protocol.snmp.DefaultAgentConfig
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
SnmpAgentConfig

public abstract class DefaultAgentConfig
extends Object
implements Serializable

This class represents agent's configuration settings.

See Also:
Serialized Form

Constructor Summary
DefaultAgentConfig()
          Constructs a SnmpAgentConfig object
 
Method Summary
 boolean addGroup(Map attrs)
          Adds a group, views associated with this group should already exist.
 void addPropertyChangeListener(com.ireasoning.protocol.snmp.PropertyChangeListener listener)
          Adds PropertyChangeListener listener.
 boolean addProxy(ProxyEntry proxy, boolean isPersistent)
          Adds a new proxy
 void addReadCommunity(String community)
          Adds a new read community string
 void addTrapSink(Map attributes)
          Adds a trapSink or snmpV3TrapSink element
 void addTrapSink(TrapSink trapsink)
          Adds a trapSink or snmpV3TrapSink element
 boolean addUser(Map attrs)
          Adds a user.
 boolean addView(Map attrs)
          Adds a view
 void addWriteCommunity(String community)
          Adds a new write community string
protected abstract  boolean doAddGroup(Map attrs)
          Adds a group, views associated with this group should already exist.
protected abstract  boolean doAddProxy(ProxyEntry entry)
          Adds a new proxy to the config settings
protected abstract  boolean doAddTrapSink(Map attributes)
          Adds a trapSink or snmpV3TrapSink element
protected abstract  boolean doAddUser(Map attrs)
          Adds a user.
protected abstract  boolean doAddView(Map attrs)
          Adds a view
protected abstract  Map doGetPropertiesProps()
          Returns a Map object which stores the attributes of properties node
protected abstract  Map[] doGetProxyProps()
          Return proxies' properties
protected abstract  Map[] doGetSnmpV3TrapSinkProps()
          Returns SNMPv3 trapsinks' properties
protected abstract  Map doGetTrapProxyProps()
          Returns trap proxy's properties
protected abstract  Map[] doGetTrapSinkProps()
          Returns non-SNMPv3 trapsinks' properties
protected abstract  void doReloadConfig()
          Reloads config settings
protected abstract  boolean doRemoveGroup(String groupName)
          Removes a group.
protected abstract  boolean doRemoveProxy(ProxyEntry entry)
          Adds a new proxy to the config settings
protected abstract  boolean doRemoveTrapSink(String trapSinkHostName, int trapSinkPort, int trapSinkVersion)
          Removes a trapSink or snmpV3TrapSink element
protected abstract  boolean doRemoveUser(String userName)
          Removes a user
protected abstract  boolean doRemoveView(String viewName)
          Removes a view.
protected abstract  void doSave()
          Saves config settings.
 Map[] getCommunityViews()
          Returns communityView's properties
 int getEngineBoots()
          Returns the engineBoots value
 byte[] getEngineID()
          Returns the engineID of this agent
abstract  Map[] getGroups()
          Returns groups' properties
 int getInformRetries()
          Returns the number of retries for inform requests
 int getInformTimeout()
          Returns the timeout value for inform requests, in seconds
 String getIpAddress()
          Returns the IP address of this agent.
 String[] getManagerIpAddresses()
          Returns the authorized manager's IP address
 int getMasterAgentPort()
          Returns the SNMP master agent's listening port
 int getMaxPacketSize()
          Returns the max packet size value, in bytes
 int getMaxThreadCount()
          Returns the max number of threads in thread pool
 int getPort()
          Returns the SNMP agent's listening port
 Vector getProxies()
          Returns a vector whose elements are objects of ProxyEntry
 String[] getReadCommunities()
          Returns the community strings for READ operation
 SnmpOID getReloadConfigOID()
          Returns the reload config OID
 String getRemoteMasterAgentIpAddress()
          Returns the remote SNMP master agent's ip address or host name
 int getRemoteMasterAgentPort()
          Returns the remote SNMP master agent's listening port
 String[] getSubagentIpAddresses()
          Returns the authorized subagent's IP address
 SnmpOID getSysObjectID()
          Returns the sysObjectID
 TrapSink[] getTrapSinks()
          Returns the trap sink objects (including TrapSink and SnmpV3TrapSink).
 long getUnderCreationTimeWindow()
          Returns the time window allowed in the underCreation state, in milliseconds.
abstract  Map[] getUsers()
          Returns users' properties
 int getVersion()
          Returns the SNMP version
abstract  Map[] getViews()
          Returns views' properties
 String[] getWriteCommunities()
          Returns the community strings for WRITE operation
 boolean isAuthTrapEnabled()
           
 boolean isUseThreadPool()
          Whether to use thread pool to handle requests and send traps.
static void main(String[] args)
           
protected  void postReloadConfig()
          It's invoked after reloadConfig() method is called
 void reloadConfig()
          Reloads config.
 boolean removeGroup(String groupName)
          Removes a group.
 boolean removePropertyChangeListener(com.ireasoning.protocol.snmp.PropertyChangeListener listener)
          Removes PropertyChangeListener object
 boolean removeProxy(ProxyEntry proxy, boolean isPersistent)
          Removes a proxy
 boolean removeTrapSink(String trapSinkHostName, int trapSinkPort, int trapSinkVersion)
          Removes a trapSink or snmpV3TrapSink element
 boolean removeTrapSink(TrapSink trapsink)
          Removes a trapSink or snmpV3TrapSink element
 boolean removeUser(String userName)
          Removes a user
 boolean removeView(String viewName)
          Removes a view.
 void save()
           
protected abstract  boolean setAttributeValue(String elementName, Map keyvals, String attributeName, String attributeValue)
          Sets attribute's value.
 void setEngineBoots(int boots)
          Sets the engineBoots value
 void setEngineID(String engineID)
          Sets a new engineID
 boolean setGroupAttributeValue(String groupName, String attrName, String attrValue)
          Changes group's attribute's value
 void setInformRetries(int retries)
          Sets the number of retries for inform requests
 void setInformTimeout(int timeout)
          Sets the timeout value for inform requests, in seconds
 void setIpAddress(String ip)
          Sets the local ip address
 void setManagerIpAddresses(String ipaddresses)
          Sets the authorized manager's IP address
 void setManagerIpAddresses(String[] ipaddresses)
          Sets the authorized manager's IP address
 void setMasterAgentPort(int port)
          Sets SNMP master agent's listening port
 void setMaxPacketSize(int size)
          Sets the max packet size value, in bytes
 void setPort(int port)
          Sets SNMP agent's listening port
 void setProperty(String name, String value)
          Sets "properties" element node 's attributes value
protected  void setPropertyValue(String name, String value)
           
 void setReadCommunities(String communities)
          Sets the community string for READ operation
 void setReloadConfigOID(SnmpOID reloadConfigOID)
          Sets the reload config oid
 void setRemoteMasterAgentIpAddress(String ipAddr)
          Sets the remote SNMP master agent's ip address or host name
 void setRemoteMasterAgentPort(int port)
          Sets remote SNMP master agent's port
 void setSubagentIpAddresses(String ipaddresses)
          Sets the authorized subagent's IP address
 void setSubagentIpAddresses(String[] ipaddresses)
          Sets the authorized subagent's IP address
 void setSysObjectID(SnmpOID sysObjectID)
          Sets the sysObjectID
 void setUnderCreationTimeWindow(long time)
          Returns the time window allowed in the underCreation state, in milliseconds.
 boolean setUserAttributeValue(String userName, String attrName, String attrValue)
          Changes user's attribute's value
 void setUseThreadPool(boolean b)
          To set whether agent is to use thread pool or not
 void setVersion(int version)
          Sets SNMP version
 void setWriteCommunities(String communities)
          Sets the community strings for WRITE operation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultAgentConfig

public DefaultAgentConfig()
Constructs a SnmpAgentConfig object

Method Detail

setAttributeValue

protected abstract boolean setAttributeValue(String elementName,
                                             Map keyvals,
                                             String attributeName,
                                             String attributeValue)
Sets attribute's value.

Parameters:
keyvals - key/value pairs used to distinguish nodes with identical node names
elementName - element name if config is a XML file. Or table name if config settings are stored in database.
attributeName - attribute's name
attributeValue - attribute's value

doGetPropertiesProps

protected abstract Map doGetPropertiesProps()
Returns a Map object which stores the attributes of properties node


doAddTrapSink

protected abstract boolean doAddTrapSink(Map attributes)
Adds a trapSink or snmpV3TrapSink element

Parameters:
attributes - a Map object containing the name/value of attributes, such as "verion" -- "2"

doRemoveTrapSink

protected abstract boolean doRemoveTrapSink(String trapSinkHostName,
                                            int trapSinkPort,
                                            int trapSinkVersion)
Removes a trapSink or snmpV3TrapSink element

Parameters:
trapSinkHostName - host name or ip address of trap receiver
trapSinkPort - port number of trap receiver
trapSinkVersion - version of trapSink. 1: SNMPv1, 2: SNMPv2c, 3: SNMPv3
Returns:
true if it's been successfully removed.

getViews

public abstract Map[] getViews()
Returns views' properties

Returns:
null if no view. Otherwise it returns a Map array of view's properties

doAddView

protected abstract boolean doAddView(Map attrs)
Adds a view

Parameters:
attrs - a map containing view's attributes
Returns:
true if view is successfully added; false otherwise(because some of the attributes are not present)

doRemoveView

protected abstract boolean doRemoveView(String viewName)
Removes a view. Returns true if group is successfully removed. And if the view is removed, all the groups associated with this view will be removed as well.


getGroups

public abstract Map[] getGroups()
Returns groups' properties

Returns:
null if no group. Otherwise it returns a Map array of group's properties

doAddGroup

protected abstract boolean doAddGroup(Map attrs)
Adds a group, views associated with this group should already exist.

Returns:
true if group is successfully added; false otherwise (Usually it's because the corresponding view does not exist, or some of the necessary attributes are not present.)

doRemoveGroup

protected abstract boolean doRemoveGroup(String groupName)
Removes a group. Returns true if group is successfully removed. And if group is removed, all the users in this group will be removed as well.


getUsers

public abstract Map[] getUsers()
Returns users' properties

Returns:
null if no user. Otherwise it returns a Map array of user's properties

getCommunityViews

public Map[] getCommunityViews()
Returns communityView's properties

Returns:
null if no communityView. Otherwise it returns a Map array of communityView's properties

doGetTrapSinkProps

protected abstract Map[] doGetTrapSinkProps()
Returns non-SNMPv3 trapsinks' properties

Returns:
null if no trapsink. Otherwise it returns a Map array of trapsink's properties

doGetSnmpV3TrapSinkProps

protected abstract Map[] doGetSnmpV3TrapSinkProps()
Returns SNMPv3 trapsinks' properties

Returns:
null if no trapsink. Otherwise it returns a Map array of trapsink's properties

doGetProxyProps

protected abstract Map[] doGetProxyProps()
Return proxies' properties


doGetTrapProxyProps

protected abstract Map doGetTrapProxyProps()
Returns trap proxy's properties


doAddUser

protected abstract boolean doAddUser(Map attrs)
Adds a user. The group that this new user belongs to should already exist.

Parameters:
attrs - user's attributes, such as "name", "authPassword", "privPassword", etc
Returns:
true if user is successfully added. false otherwise (usually it's because the corresponding group does not exist, or some of the attributes are not present)

doRemoveUser

protected abstract boolean doRemoveUser(String userName)
Removes a user

Returns:
true if user is successfully removed

doSave

protected abstract void doSave()
                        throws IOException
Saves config settings.

Throws:
IOException

doReloadConfig

protected abstract void doReloadConfig()
                                throws IOException
Reloads config settings

Throws:
IOException

doAddProxy

protected abstract boolean doAddProxy(ProxyEntry entry)
Adds a new proxy to the config settings


doRemoveProxy

protected abstract boolean doRemoveProxy(ProxyEntry entry)
Adds a new proxy to the config settings


addPropertyChangeListener

public void addPropertyChangeListener(com.ireasoning.protocol.snmp.PropertyChangeListener listener)
Adds PropertyChangeListener listener. So listener will be notified when any changes to the config occur.


removePropertyChangeListener

public boolean removePropertyChangeListener(com.ireasoning.protocol.snmp.PropertyChangeListener listener)
Removes PropertyChangeListener object

Returns:
true if the passed listener exists

addGroup

public boolean addGroup(Map attrs)
Adds a group, views associated with this group should already exist.

Returns:
true if group is successfully added; false otherwise (Usually it's because the corresponding view does not exist, or some of the necessary attributes are not present.)

removeGroup

public boolean removeGroup(String groupName)
Removes a group. Returns true if group is successfully removed. And if group is removed, all the users in this group will be removed as well.


setGroupAttributeValue

public boolean setGroupAttributeValue(String groupName,
                                      String attrName,
                                      String attrValue)
Changes group's attribute's value

Parameters:
groupName - group's name
attrName - group's attribute's name
attrValue - group's attribute's new value

addUser

public boolean addUser(Map attrs)
Adds a user. The group that this new user belongs to should already exist.

Parameters:
attrs - user's attributes, such as "name", "authPassword", "privPassword", etc
Returns:
true if user is successfully added. false otherwise (usually it's because the corresponding group does not exist, or some of the attributes are not present)

removeUser

public boolean removeUser(String userName)
Removes a user

Returns:
true if user is successfully removed

setUserAttributeValue

public boolean setUserAttributeValue(String userName,
                                     String attrName,
                                     String attrValue)
Changes user's attribute's value

Parameters:
userName - user name
attrName - user's attribute's name
attrValue - user's attribute's new value

addView

public boolean addView(Map attrs)
Adds a view

Parameters:
attrs - a map containing the name/value pairs of view's attributes
Returns:
true if view is successfully added; false otherwise(because some of the attributes are not present)

removeView

public boolean removeView(String viewName)
Removes a view. Returns true if group is successfully removed. And if the view is removed, all the groups associated with this view will be removed as well.


getTrapSinks

public TrapSink[] getTrapSinks()
Returns the trap sink objects (including TrapSink and SnmpV3TrapSink). If there is no trap sink, it returns an empty array.


addTrapSink

public void addTrapSink(TrapSink trapsink)
Adds a trapSink or snmpV3TrapSink element

Parameters:
trapsink - a TrapSink or SnmpV3TrapSink object

addTrapSink

public void addTrapSink(Map attributes)
Adds a trapSink or snmpV3TrapSink element

Parameters:
attributes - a Map object containing the name/value of attributes, such as "verion" -- "2"

removeTrapSink

public boolean removeTrapSink(TrapSink trapsink)
Removes a trapSink or snmpV3TrapSink element

Parameters:
trapsink - a TrapSink or SnmpV3TrapSink object

removeTrapSink

public boolean removeTrapSink(String trapSinkHostName,
                              int trapSinkPort,
                              int trapSinkVersion)
Removes a trapSink or snmpV3TrapSink element

Parameters:
trapSinkHostName - host name or ip address of trap receiver
trapSinkPort - port number of trap receiver
trapSinkVersion - version of trapSink. 1: SNMPv1, 2: SNMPv2c, 3: SNMPv3
Returns:
true if trap sink has been removed successfully.

save

public void save()
          throws IOException
Throws:
IOException

setProperty

public void setProperty(String name,
                        String value)
Sets "properties" element node 's attributes value

Parameters:
name - attribute's name
value - attribute's value

reloadConfig

public void reloadConfig()
                  throws IOException
Reloads config. PropertyChangeListener will receive a null event

If config was loaded from an InputStream object, then reloadConfig(InputStream istream) method should be used instead.

Throws:
IOException

postReloadConfig

protected void postReloadConfig()
It's invoked after reloadConfig() method is called


getVersion

public int getVersion()
Returns the SNMP version


setVersion

public void setVersion(int version)
Sets SNMP version


getPort

public int getPort()
Returns the SNMP agent's listening port


setPort

public void setPort(int port)
Sets SNMP agent's listening port


getRemoteMasterAgentPort

public int getRemoteMasterAgentPort()
Returns the remote SNMP master agent's listening port


setRemoteMasterAgentPort

public void setRemoteMasterAgentPort(int port)
Sets remote SNMP master agent's port


getRemoteMasterAgentIpAddress

public String getRemoteMasterAgentIpAddress()
Returns the remote SNMP master agent's ip address or host name


setRemoteMasterAgentIpAddress

public void setRemoteMasterAgentIpAddress(String ipAddr)
Sets the remote SNMP master agent's ip address or host name


getMasterAgentPort

public int getMasterAgentPort()
Returns the SNMP master agent's listening port


setMasterAgentPort

public void setMasterAgentPort(int port)
Sets SNMP master agent's listening port


getReadCommunities

public String[] getReadCommunities()
Returns the community strings for READ operation


setReadCommunities

public void setReadCommunities(String communities)
Sets the community string for READ operation


addReadCommunity

public void addReadCommunity(String community)
Adds a new read community string


getWriteCommunities

public String[] getWriteCommunities()
Returns the community strings for WRITE operation


setWriteCommunities

public void setWriteCommunities(String communities)
Sets the community strings for WRITE operation


addWriteCommunity

public void addWriteCommunity(String community)
Adds a new write community string


getInformRetries

public int getInformRetries()
Returns the number of retries for inform requests


setInformRetries

public void setInformRetries(int retries)
Sets the number of retries for inform requests


getInformTimeout

public int getInformTimeout()
Returns the timeout value for inform requests, in seconds


setInformTimeout

public void setInformTimeout(int timeout)
Sets the timeout value for inform requests, in seconds


isUseThreadPool

public boolean isUseThreadPool()
Whether to use thread pool to handle requests and send traps. Using thread pool can boost the performance but it also takes more system resources


getMaxThreadCount

public int getMaxThreadCount()
Returns the max number of threads in thread pool


isAuthTrapEnabled

public boolean isAuthTrapEnabled()

getEngineBoots

public int getEngineBoots()
Returns the engineBoots value


setEngineBoots

public void setEngineBoots(int boots)
Sets the engineBoots value


getMaxPacketSize

public int getMaxPacketSize()
Returns the max packet size value, in bytes


setMaxPacketSize

public void setMaxPacketSize(int size)
Sets the max packet size value, in bytes


getUnderCreationTimeWindow

public long getUnderCreationTimeWindow()
Returns the time window allowed in the underCreation state, in milliseconds.


setUnderCreationTimeWindow

public void setUnderCreationTimeWindow(long time)
Returns the time window allowed in the underCreation state, in milliseconds.


setUseThreadPool

public void setUseThreadPool(boolean b)
To set whether agent is to use thread pool or not


getReloadConfigOID

public SnmpOID getReloadConfigOID()
Returns the reload config OID


setReloadConfigOID

public void setReloadConfigOID(SnmpOID reloadConfigOID)
Sets the reload config oid


getSysObjectID

public SnmpOID getSysObjectID()
Returns the sysObjectID


setSysObjectID

public void setSysObjectID(SnmpOID sysObjectID)
Sets the sysObjectID


getSubagentIpAddresses

public String[] getSubagentIpAddresses()
Returns the authorized subagent's IP address


setSubagentIpAddresses

public void setSubagentIpAddresses(String ipaddresses)
Sets the authorized subagent's IP address


setSubagentIpAddresses

public void setSubagentIpAddresses(String[] ipaddresses)
Sets the authorized subagent's IP address


getManagerIpAddresses

public String[] getManagerIpAddresses()
Returns the authorized manager's IP address

Returns:
null if manager ip address is empty

setManagerIpAddresses

public void setManagerIpAddresses(String ipaddresses)
Sets the authorized manager's IP address

Parameters:
ipaddresses - IP address separated by comma

setManagerIpAddresses

public void setManagerIpAddresses(String[] ipaddresses)
Sets the authorized manager's IP address


getEngineID

public byte[] getEngineID()
Returns the engineID of this agent


setEngineID

public void setEngineID(String engineID)
Sets a new engineID


getIpAddress

public String getIpAddress()
Returns the IP address of this agent. Agent will bind to this particular address, it's also used as one of the field in SNMPv1 trap. the first IP address found for the hostname of the machine will be used if this field is empty.


setIpAddress

public void setIpAddress(String ip)
Sets the local ip address


setPropertyValue

protected void setPropertyValue(String name,
                                String value)

getProxies

public Vector getProxies()
Returns a vector whose elements are objects of ProxyEntry


addProxy

public boolean addProxy(ProxyEntry proxy,
                        boolean isPersistent)
Adds a new proxy

Parameters:
proxy - new proxy instance
isPersistent - if true, config settings will be updated
Returns:
true if proxy is successfully added

removeProxy

public boolean removeProxy(ProxyEntry proxy,
                           boolean isPersistent)
Removes a proxy

Parameters:
proxy - new proxy instance
isPersistent - if true, config settings will be updated
Returns:
true if proxy is successfully removed

main

public static void main(String[] args)

HOME

Copyright © 2002 iReasoning Inc. All Rights Reserved.