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.");
}
}
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);
}
}
}
Aggregations