Module org.snmp4j

Class AbstractTransportMapping<A extends Address>

    • Field Detail

      • maxInboundMessageSize

        protected int maxInboundMessageSize
      • asyncMsgProcessingSupported

        protected boolean asyncMsgProcessingSupported
      • suspendedAddresses

        protected Set<A extends Address> suspendedAddresses
      • listenWorkerTask

        protected WorkerTask listenWorkerTask
      • connectionTimeout

        protected long connectionTimeout
    • Constructor Detail

      • AbstractTransportMapping

        public AbstractTransportMapping()
    • Method Detail

      • isListening

        public boolean isListening()
        Description copied from interface: TransportMapping
        Returns true if the transport mapping is listening for incoming messages. For connection oriented transport mappings this is a prerequisite to be able to send SNMP messages. For connectionless transport mappings it is a prerequisite to be able to receive responses.
        Specified by:
        isListening in interface TransportMapping<A extends Address>
        Returns:
        true if this transport mapping is listening for messages.
      • sendMessage

        public abstract void sendMessage​(A address,
                                         byte[] message,
                                         TransportStateReference tmStateReference,
                                         long timeoutMillis,
                                         int maxRetries)
                                  throws IOException
        Sends a message to the supplied address using this transport. If the target address has been suspended, then instead actually sending the message on the wire, the method handleDroppedMessageToSend(Address, byte[], TransportStateReference, long, int) will be called. To stop suspending of a target address, call resumeAddress(Address) for that address.
        Specified by:
        sendMessage in interface TransportMapping<A extends Address>
        Parameters:
        address - an Address instance denoting the target address.
        message - the whole message as an array of bytes.
        tmStateReference - the (optional) transport model state reference as defined by RFC 5590 section 6.1.
        timeoutMillis - maximum number of milliseconds the connection creation might take (if connection based).
        maxRetries - maximum retries during connection creation.
        Throws:
        IOException - if any underlying IO operation fails.
      • addTransportListener

        public void addTransportListener​(TransportListener l)
        Description copied from interface: TransportMapping
        Adds a transport listener to the transport. Normally, at least one transport listener needs to be added to process incoming messages.
        Specified by:
        addTransportListener in interface TransportMapping<A extends Address>
        Parameters:
        l - a TransportListener instance.
      • removeAllTransportListeners

        public void removeAllTransportListeners()
      • resumeAddress

        public boolean resumeAddress​(A addressToResumeSending)
        Resume sending of messages to the specified address.
        Parameters:
        addressToResumeSending - an arbitrary remote address for which any messages send by sendMessage(Address, byte[], TransportStateReference, long, int) should be dropped before sending and reopening a connection to that address.
        Returns:
        true if the specified address was previously suspended and is now resumed to allow sending messages, false otherwise.
        Since:
        3.4.4
      • handleDroppedMessageToSend

        protected void handleDroppedMessageToSend​(A address,
                                                  byte[] message,
                                                  TransportStateReference transportStateReference,
                                                  long timeoutMillis,
                                                  int maxRetries)
        Handle a message that could not be send to the specified address, because there is no server socket for receiving responses.
        Parameters:
        address - an Address instance denoting the target address.
        message - the whole message as an array of bytes.
        transportStateReference - the (optional) transport model state reference as defined by RFC 5590 section 6.1.
        timeoutMillis - maximum number of milliseconds the connection creation might take (if connection based).
        maxRetries - maximum retries during connection creation.
        Since:
        3.4.4
      • getSocketCleaner

        public CommonTimer getSocketCleaner()
        Gets the CommonTimer that controls socket cleanup operations.
        Returns:
        a socket cleaner timer.
        Since:
        3.0
      • getMaxInboundMessageSize

        public int getMaxInboundMessageSize()
        Description copied from interface: TransportMapping
        Gets the maximum length of an incoming message that can be successfully processed by this transport mapping implementation.
        Specified by:
        getMaxInboundMessageSize in interface TransportMapping<A extends Address>
        Returns:
        an integer > 484.
      • setPriority

        public void setPriority​(int newPriority)
        Changes the priority of the listen thread for this UDP transport mapping. This method has no effect, if called before listen() has been called for this transport mapping.
        Parameters:
        newPriority - the new priority.
        Since:
        3.6.0
        See Also:
        Thread.setPriority(int)
      • setThreadName

        public void setThreadName​(String name)
        Sets the name of the listen thread for this UDP transport mapping. This method has no effect, if called before listen() has been called for this transport mapping.
        Parameters:
        name - the new thread name.
        Since:
        3.6.0
      • getThreadName

        public String getThreadName()
        Returns the name of the listen thread.
        Returns:
        the thread name if in listening mode, otherwise null.
        Since:
        3.6.0
      • removeTransportStateListener

        public void removeTransportStateListener​(TransportStateListener l)
        Remove a TransportStateListener from this transport mapping.
        Parameters:
        l - the listener callback interface to be removed.
        Since:
        3.7.0
      • getListenAddress

        public abstract A getListenAddress()
        Description copied from interface: TransportMapping
        Returns the address that represents the actual incoming address this transport mapping uses to listen for incoming packets.
        Specified by:
        getListenAddress in interface TransportMapping<A extends Address>
        Returns:
        the address for incoming packets or null this transport mapping is not configured to listen for incoming packets.
      • fireConnectionStateChanged

        protected void fireConnectionStateChanged​(TransportStateEvent change)
      • getSuspendedAddresses

        public Set<A> getSuspendedAddresses()
        Gets a unmodifiable set of the suspended addresses of this
        Returns: