OpenNMS API 1.2.9

## org.opennms.netmgt.discovery
Class PingManager.Pinger

    java.lang.Object
      org.opennms.netmgt.discovery.PingManager.Pinger

All Implemented Interfaces:
  ExtendedStatusFiber, Fiber, PausableFiber, java.lang.Runnable

Enclosing class:
  PingManager

static final class PingManager.Pinger
extends java.lang.Object
implements java.lang.Runnable, PausableFiber, ExtendedStatusFiber

Field Summary
`(package private) static int` `IDLE` This is the constant value that represents an idle pinger thread.
`private FifoQueue` `m_addressQ` The queue of inbound addresses to poll.
`private long` `m_fiberId` The identifier for the fiber.
`private short` `m_icmpId` The value stored in the icmp identifier field.
`private QuantumSemaphore` `m_semaphore` The semaphore that each poller must acquire before they can send a packet
`private boolean` `m_signaled` True if the `signal` method is invoked.
`private IcmpSocket` `m_socket` The socket used to send datagrams.
`private int` `m_status` The normal fiber's status.
`private java.net.InetAddress` `m_target` The current target address.
`private java.lang.Thread` `m_worker` The thread that is executing the `run` method on behalf of the fiber.
`private int` `m_xstatus` The extended status.
`(package private) static int` `POLLING` This is the constant value that represents a polling pinger thread.

Fields inherited from interface org.opennms.core.fiber.PausableFiber
`PAUSE_PENDING, PAUSED, RESUME_PENDING`

Fields inherited from interface org.opennms.core.fiber.Fiber
`RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED`

Constructor Summary
`(package private)` `PingManager.Pinger(IcmpSocket socket, QuantumSemaphore semaphore, FifoQueue addrQ, short filterId, long tid)` Constructs a new instance of a pinging fiber.

Method Summary
`int` `getExtendedStatus()` Returns the extends status of the thread.
`long` `getId()` Returns the identifier that is placed in the ping `packet`.
`java.lang.String` `getName()` Returns the name of the fiber.
`int` `getStatus()` Returns the current status of the pinging thread.
`boolean` `isPinging(java.net.InetAddress addr)` Returns true if this thread is currently polling the passed IP Address.
`void` `pause()` Pauses the current fiber.
`private boolean` `poll(IPPollAddress addr)` This method does the actual polling of the encapsulated address using the timeout and retry values.
`void` `resume()` Resumes a currently paused fiber.
`void` `run()` The main method that does the work for the pinging thread.
`void` `signal()` Signals the instance that it's current target has responded to an echo check.
`void` `start()` Starts the current fiber.
`void` `stop()` Attempts to stop the current polling cycle as quickly as possbile.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### m_semaphore

    private final QuantumSemaphore m_semaphore

  The semaphore that each poller must acquire before they can send a packet

### m_socket

    private final IcmpSocket m_socket

  The socket used to send datagrams.

### m_addressQ

    private final FifoQueue m_addressQ

  The queue of inbound addresses to poll.

### m_icmpId

    private final short m_icmpId

  The value stored in the icmp identifier field.

### m_fiberId

    private final long m_fiberId

  The identifier for the fiber. This is stored in the ping packet.

### m_status

    private int m_status

  The normal fiber's status.

### m_xstatus

    private int m_xstatus

  The extended status.

### m_target

    private java.net.InetAddress m_target

  The current target address.

### m_signaled

    private boolean m_signaled

  True if the `signal` method is invoked. Used to indicate a responsive address.

### m_worker

    private java.lang.Thread m_worker

  The thread that is executing the `run` method on behalf of the fiber.

### IDLE

    static final int IDLE

  This is the constant value that represents an idle pinger thread.

  See Also:
    Constant Field Values

### POLLING

    static final int POLLING

  This is the constant value that represents a polling pinger thread.

  See Also:
    Constant Field Values

Constructor Detail

### PingManager.Pinger

    PingManager.Pinger(IcmpSocket socket,
                       QuantumSemaphore semaphore,
                       FifoQueue addrQ,
                       short filterId,
                       long tid)

  Constructs a new instance of a pinging fiber.

Parameters:
  `socket` - The ICMP socket
  `semaphore` - The control semaphore
  `addrQ` - The input address queue.
  `filterId` - The ICMP id for filtering datagrams
  `tid` - The Thread ID stored in the Packet.

Method Detail

### poll

    private boolean poll(IPPollAddress addr)
                  throws java.io.IOException,
                         java.lang.InterruptedException

  This method does the actual polling of the encapsulated address using the timeout and retry values. The polling will continue until either all the retries are exhausted or the pinger is signaled that the address responded.

  NOTICE: The instance lock must be heald prior to calling this method. This method uses the `wait`method and lock ownership is required to invoke the `wait` method.

  Parameters:
    `addr` - The address and information for polling.
  Throws:
    `java.io.IOException` - Thrown if an error occurs sending the ICMP information.
    `java.lang.InterruptedException` - Thrown if the thread is interrupted.

### start

    public void start()

  Starts the current fiber. If the fiber has already been started, regardless of it's current state, then an IllegalStateException is thrown.

  Specified by:
    `start` in interface `Fiber`
  Throws:
    `java.lang.IllegalStateException` - Thrown if the fiber has already been started.

### stop

    public void stop()

  Attempts to stop the current polling cycle as quickly as possbile. If the fiber has never been started then an `IllegalStateExceptio` is generated.

  Specified by:
    `stop` in interface `Fiber`
  Throws:
    `java.lang.IllegalStateException` - Thrown if the fiber has never been started.

### pause

    public void pause()

  Pauses the current fiber. This does not take effect immediently, but after the current polling cycle has completed.

  To determine if the fiber has finished its current polling cycle check for a status equal to `PAUSED` and the extended status equal to `IDLE`.

  Specified by:
    `pause` in interface `PausableFiber`

### resume

    public void resume()

  Resumes a currently paused fiber.

  Specified by:
    `resume` in interface `PausableFiber`

### getName

    public java.lang.String getName()

  Returns the name of the fiber.

  Specified by:
    `getName` in interface `Fiber`
  Returns:
    The name of the Fiber.

### getStatus

    public int getStatus()

  Returns the current status of the pinging thread.

  Specified by:
    `getStatus` in interface `Fiber`
  Returns:
    The status of the Fiber.

### getExtendedStatus

    public int getExtendedStatus()

  Returns the extends status of the thread. This will always be one of two values: POLLING or IDLE.

  Specified by:
    `getExtendedStatus` in interface `ExtendedStatusFiber`
  Returns:
    The current polling status.

### run

    public void run()

  The main method that does the work for the pinging thread. This method reads `IPPollAddress`instances from the input queue and then polls the target using the information.

  While a poll is in process the extended status of the fiber will return `POLLING`otherwise it should be `IDLE`.

  If an error occurs then the thread will exit and set the status to `STOPPED`.

  Specified by:
    `run` in interface `java.lang.Runnable`

### isPinging

    public boolean isPinging(java.net.InetAddress addr)

  Returns true if this thread is currently polling the passed IP Address.

  Parameters:
    `addr` - The address to check.
  Returns:
    True if the thread is currently targeting the passed address.

### signal

    public void signal()

  Signals the instance that it's current target has responded to an echo check.

### getId

    public long getId()

  Returns the identifier that is placed in the ping `packet`.

  Returns:
    The thread id for the packet.

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.