com.sun.management.snmp.manager
Class SnmpPeer

java.lang.Object
  extended by com.sun.management.snmp.manager.SnmpPeer
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
SnmpUsmPeer

public class SnmpPeer
extends Object
implements Serializable

Holds information about an SNMP agent. This information is used to communicate with the agent. These are the IP address, port number, SNMP parameters, and peer channel parameters (such as the maximum request packet size, maximum number of variable bindings in a packet, retries, and timeouts). Changing these would affect all active requests.

The class contains the following properties:

JavaBean compliant getters and setters allow the properties listed above to be modified.

Since:
Java DMK 5.1
See Also:
SnmpSession, SnmpRequest, SnmpParameters, Serialized Form

Field Summary
static int defaultSnmpRequestPktSize
          The default SNMP packet size of an SNMP request (2 * 1024).
static int defaultSnmpResponsePktSize
          The default SNMP packet size of an SNMP response (8 * 1024).
 
Constructor Summary
SnmpPeer(InetAddress netaddr)
          Creates an SNMP peer object for a device.
SnmpPeer(String host)
          Creates an SNMP peer object for a device.
SnmpPeer(String host, int port)
          Creates an SNMP peer object for a device with the specified port.
 
Method Summary
 boolean allowSnmpSets()
          Determines whether an SNMP set operation is allowed with this peer object.
 boolean equals(Object obj)
          Compares the two peer objects to determine whether they are the same.
 long getAvgRtt()
          Gets the average round trip time for a packet with the peer.
 InetAddress getDestAddr()
          Gets the InetAddress object for this peer.
 InetAddress[] getDestAddrList()
          Gets the list of alternate InetAddress configured for this peer.
 int getDestPort()
          Gets the destination port number of the peer to which SNMP requests are to be sent.
 String getDevName()
          Gets the name specified in the constructor while creating this object.
 long getMaxRtt()
          Gets the maximum round trip time for a packet with the peer.
 int getMaxSnmpPktSize()
          Gets the maximum request packet size that is currently used.
 int getMaxTries()
          Gets the number of times to try before giving up.
 long getMinRtt()
          Gets the minimum round trip time for a packet with the peer.
 SnmpParams getParams()
          Gets the SnmpParams object associated with the peer.
 int getTimeout()
          Gets the timeout to wait for a response from the peer.
 int getVarBindLimit()
          Gets the maximum number of variable bindings that can be sent to a peer.
 String ipAddressInUse()
          Returns the dot-formatted IP address string (for example 171.69.220.224).
 void setDestPort(int newPort)
          Changes the port address of the destination for the request.
 void setMaxSnmpPktSize(int newsize)
          Configures the maximum packet size that can be used when generating an SNMP request.
 void setMaxTries(int newMaxTries)
          Changes the maximum number of times to try before giving up.
 void setParams(SnmpParams params)
          Sets the SnmpParams object associated with the peer.
 void setTimeout(int newTimeout)
          Changes the timeout to wait for a response from the peer.
 void setVarBindLimit(int limit)
          Configures the maximum number of variable bindings that can be sent to a peer.
 String toString()
          Returns the String representation for this SnmpPeer.
 void useAddressList(InetAddress[] adrList)
          Specifies the list of addresses to be used.
 void useIPAddress(String ipaddr)
          Sets a specific IP address to which the peer will communicate.
 void useNextAddress()
          Causes all subsequent requests to go to the new address obtained from the specified list of alternate addresses.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultSnmpRequestPktSize

public static int defaultSnmpRequestPktSize
The default SNMP packet size of an SNMP request (2 * 1024).
The maximum size is initially set to Ethernet maximum transfer unit (MTU).


defaultSnmpResponsePktSize

public static int defaultSnmpResponsePktSize
The default SNMP packet size of an SNMP response (8 * 1024).
This will be the default size that the session socket uses when receiving a packet.

Constructor Detail

SnmpPeer

public SnmpPeer(String host)
         throws UnknownHostException
Creates an SNMP peer object for a device. The default port is 161.

Parameters:
host - The peer name.
Throws:
UnknownHostException - If the host name cannot be resolved.

SnmpPeer

public SnmpPeer(InetAddress netaddr)
Creates an SNMP peer object for a device. The default port is 161.

Parameters:
netaddr - The peer InetAddress.

SnmpPeer

public SnmpPeer(String host,
                int port)
         throws UnknownHostException
Creates an SNMP peer object for a device with the specified port.

Parameters:
host - The peer name.
port - The port number.
Throws:
UnknownHostException - If the host name cannot be resolved.
Method Detail

useIPAddress

public final void useIPAddress(String ipaddr)
                        throws UnknownHostException
Sets a specific IP address to which the peer will communicate. Typically used to set an alternate IP address or a specific address which is known to respond to requests. The IP address String can either be a machine name, such as ibiza, or a String representing its IP address, such as "206.26.48.100".

Parameters:
ipaddr - Dot formatted IP address or logical host name.
Throws:
UnknownHostException - If the host name cannot be resolved.

ipAddressInUse

public final String ipAddressInUse()
Returns the dot-formatted IP address string (for example 171.69.220.224). Useful when you want to know which IP address is used when the address was resolved using a DNS name.

Returns:
The dot-formatted IP address being used.

useAddressList

public final void useAddressList(InetAddress[] adrList)
Specifies the list of addresses to be used. When a host is not responding the user can switch to the next address by calling useNextAddress.

Parameters:
adrList - The list of InetAddresses.

useNextAddress

public final void useNextAddress()
Causes all subsequent requests to go to the new address obtained from the specified list of alternate addresses. If it reaches the end of list, it starts again at the first address.


allowSnmpSets

public boolean allowSnmpSets()
Determines whether an SNMP set operation is allowed with this peer object. For now it just makes sure a parameter is configured for a write operation.

Returns:
true if SNMP set is allowed and the parameter is configured, false otherwise.

equals

public boolean equals(Object obj)
Compares the two peer objects to determine whether they are the same. This is used to determine whether requests can be multiplexed.

Overrides:
equals in class Object
Parameters:
obj - The object to compare this with.
Returns:
true if they are referring to same peer and using same address; false otherwise.

getDestAddrList

public final InetAddress[] getDestAddrList()
Gets the list of alternate InetAddress configured for this peer.

Returns:
The InetAddress of the peer.

getDestAddr

public final InetAddress getDestAddr()
Gets the InetAddress object for this peer.

Returns:
The InetAddress of the peer.

getDestPort

public final int getDestPort()
Gets the destination port number of the peer to which SNMP requests are to be sent.

Returns:
The destination port number.

setDestPort

public final void setDestPort(int newPort)
Changes the port address of the destination for the request.

Parameters:
newPort - The destination port.

getTimeout

public final int getTimeout()
Gets the timeout to wait for a response from the peer.

Returns:
The value of the timeout property.

setTimeout

public final void setTimeout(int newTimeout)
Changes the timeout to wait for a response from the peer.

Parameters:
newTimeout - The timeout (in milliseconds).

getMaxTries

public final int getMaxTries()
Gets the number of times to try before giving up.

Returns:
The maximum number of tries.

setMaxTries

public final void setMaxTries(int newMaxTries)
Changes the maximum number of times to try before giving up.

Parameters:
newMaxTries - The maximum number of tries.

getDevName

public final String getDevName()
Gets the name specified in the constructor while creating this object.

Returns:
The name of the host as specified while creating this object.

toString

public String toString()
Returns the String representation for this SnmpPeer.

Overrides:
toString in class Object
Returns:
The String representation.

getVarBindLimit

public final int getVarBindLimit()
Gets the maximum number of variable bindings that can be sent to a peer.

Returns:
The maximum variable bindings that can be encoded into a request packet.

setVarBindLimit

public final void setVarBindLimit(int limit)
Configures the maximum number of variable bindings that can be sent to a peer.

Parameters:
limit - The desired limit.

setParams

public void setParams(SnmpParams params)
Sets the SnmpParams object associated with the peer.

Parameters:
params - The desired parameters.

getParams

public SnmpParams getParams()
Gets the SnmpParams object associated with the peer.

Returns:
The associated parameters.

getMaxSnmpPktSize

public final int getMaxSnmpPktSize()
Gets the maximum request packet size that is currently used.

Returns:
The maximum request packet size.

setMaxSnmpPktSize

public final void setMaxSnmpPktSize(int newsize)
Configures the maximum packet size that can be used when generating an SNMP request.

Parameters:
newsize - The desired packet size.

getMinRtt

public long getMinRtt()
Gets the minimum round trip time for a packet with the peer.

Returns:
The minimum round trip time for a packet with the peer.

getMaxRtt

public long getMaxRtt()
Gets the maximum round trip time for a packet with the peer.

Returns:
The maximum round trip time for a packet with the peer.

getAvgRtt

public long getAvgRtt()
Gets the average round trip time for a packet with the peer.

Returns:
The average round trip time for a packet with the peer.

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.