Search in sources :

Example 1 with AbstractPingerFactory

use of org.opennms.netmgt.icmp.AbstractPingerFactory in project opennms by OpenNMS.

the class CamelBlueprintTest method doPreSetup.

/**
     * Use Aries Blueprint synchronous mode to avoid a blueprint deadlock bug. Also, make sure
     * the PingerFactory is reset so DSCP/fragment bits are cleared.
     *
     * @see https://issues.apache.org/jira/browse/ARIES-1051
     * @see https://access.redhat.com/site/solutions/640943
     */
@Override
public void doPreSetup() throws Exception {
    System.setProperty("org.apache.aries.blueprint.synchronous", Boolean.TRUE.toString());
    System.setProperty("de.kalpatec.pojosr.framework.events.sync", Boolean.TRUE.toString());
    try {
        final PingerFactory pingerFactory = getOsgiService(PingerFactory.class, 2000);
        if (pingerFactory instanceof AbstractPingerFactory) {
            ((AbstractPingerFactory) pingerFactory).reset();
        }
    } catch (final Exception e) {
        LOG.warn("Failed to get PingerFactory. This may be intentional.");
    }
}
Also used : PingerFactory(org.opennms.netmgt.icmp.PingerFactory) AbstractPingerFactory(org.opennms.netmgt.icmp.AbstractPingerFactory) AbstractPingerFactory(org.opennms.netmgt.icmp.AbstractPingerFactory)

Example 2 with AbstractPingerFactory

use of org.opennms.netmgt.icmp.AbstractPingerFactory in project opennms by OpenNMS.

the class Main method initializePinger.

public void initializePinger() {
    final AbstractPingerFactory pingerFactory = new BestMatchPingerFactory();
    if (m_disableIcmp) {
        LOG.info("Disabling ICMP by user request.");
        System.setProperty("org.opennms.netmgt.icmp.pingerClass", "org.opennms.netmgt.icmp.NullPinger");
        pingerFactory.setInstance(0, true, new NullPinger());
        return;
    }
    final String pingerClass = System.getProperty("org.opennms.netmgt.icmp.pingerClass");
    if (pingerClass == null) {
        LOG.info("System property org.opennms.netmgt.icmp.pingerClass is not set; using JnaPinger by default");
        System.setProperty("org.opennms.netmgt.icmp.pingerClass", "org.opennms.netmgt.icmp.jna.JnaPinger");
    }
    LOG.info("Pinger class: {}", System.getProperty("org.opennms.netmgt.icmp.pingerClass"));
    try {
        final Pinger pinger = pingerFactory.getInstance();
        pinger.ping(InetAddress.getLoopbackAddress());
    } catch (final Throwable t) {
        LOG.warn("Unable to get pinger instance.  Setting pingerClass to NullPinger.  For details, see: http://www.opennms.org/wiki/ICMP_could_not_be_initialized");
        System.setProperty("org.opennms.netmgt.icmp.pingerClass", "org.opennms.netmgt.icmp.NullPinger");
        pingerFactory.setInstance(0, true, new NullPinger());
        if (m_gui) {
            final String message = "ICMP (ping) could not be initialized: " + t.getMessage() + "\nDisabling ICMP and using the NullPinger instead." + "\nFor details, see: http://www.opennms.org/wiki/ICMP_could_not_be_initialized";
            JOptionPane.showMessageDialog(null, message, "ICMP Not Available", JOptionPane.WARNING_MESSAGE);
        }
    }
}
Also used : NullPinger(org.opennms.netmgt.icmp.NullPinger) Pinger(org.opennms.netmgt.icmp.Pinger) NullPinger(org.opennms.netmgt.icmp.NullPinger) AbstractPingerFactory(org.opennms.netmgt.icmp.AbstractPingerFactory) BestMatchPingerFactory(org.opennms.netmgt.icmp.best.BestMatchPingerFactory)

Aggregations

AbstractPingerFactory (org.opennms.netmgt.icmp.AbstractPingerFactory)2 NullPinger (org.opennms.netmgt.icmp.NullPinger)1 Pinger (org.opennms.netmgt.icmp.Pinger)1 PingerFactory (org.opennms.netmgt.icmp.PingerFactory)1 BestMatchPingerFactory (org.opennms.netmgt.icmp.best.BestMatchPingerFactory)1