public static InetAddress resolveHostname(final String hostname, final boolean preferInet6Address) throws UnknownHostException { return resolveHostname(hostname, preferInet6Address, true); }
/** * This method updates the 'nodelabel' and 'nodelabelsource' fields of the * 'node' table for the specified nodeID. A database connection is retrieved * from the Vault. * * WARNING: A properly instantiated and initialized Vault class object is * required prior to calling this method. This method will initially only be * called from the WEB UI. * * @param nodeID * Unique identifier of the node to be updated. * @param nodeLabel * Object containing label and source values. * @throws java.sql.SQLException if any. * * @deprecated Use a {@link NodeDao#update(org.opennms.netmgt.model.OnmsNode)} method call instead */ @Override public void assignLabel(final int nodeID, final NodeLabel nodeLabel) throws SQLException { final Connection dbConnection = DataSourceFactory.getInstance().getConnection(); final DBUtils d = new DBUtils(NodeLabelJDBCImpl.class, dbConnection); try { assignLabel(nodeID, nodeLabel, dbConnection); } finally { d.cleanUp(); } }
/** * This method determines what label should be associated with a particular * node. A database connection is retrieved from the Vault. * * WARNING: A properly instantiated and initialized Vault class object is * required prior to calling this method. This method will initially only be * called from the WEB UI. * * @param nodeID * Unique identifier of the node to be updated. * @return NodeLabel Object containing label and source values * @throws java.sql.SQLException if any. * * @deprecated Update this to use modern DAO methods instead of raw SQL */ public NodeLabel computeLabel(final int nodeID) throws SQLException { final Connection dbConnection = DataSourceFactory.getInstance().getConnection(); final DBUtils d = new DBUtils(NodeLabelJDBCImpl.class, dbConnection); try { return computeLabel(nodeID, dbConnection); } finally { d.cleanUp(); } }
return new NodeLabelJDBCImpl(netbiosName, NodeLabelSource.NETBIOS); loadAddressList(rs, ipv4AddrList, ipHostNameList); } catch (Throwable e) { LOG.warn("Exception thrown while fetching managed interfaces: {}", e.getMessage(), e); InetAddress primaryAddr = selectPrimaryAddress(ipv4AddrList, method); rs = stmt.executeQuery(); d.watch(rs); loadAddressList(rs, ipv4AddrList, ipHostNameList); } catch (Throwable e) { LOG.warn("Exception thrown while fetching managed interfaces: {}", e.getMessage(), e); primaryAddr = selectPrimaryAddress(ipv4AddrList, method); return new NodeLabelJDBCImpl("Unknown", NodeLabelSource.UNKNOWN); return new NodeLabelJDBCImpl(primaryHostName, NodeLabelSource.HOSTNAME); return new NodeLabelJDBCImpl(primarySysName, NodeLabelSource.SYSNAME); return new NodeLabelJDBCImpl(InetAddressUtils.str(primaryAddr), NodeLabelSource.ADDRESS);
/** * <p>getDomain</p> * * @return a {@link java.lang.String} object. */ public String getDomain() { if ("nodeid".equalsIgnoreCase(m_domain)) { return Integer.toString(getIfInfo().getNodeId()); } else if ("nodelabel".equalsIgnoreCase(m_domain)) { try { return new NodeLabelJDBCImpl().retrieveLabel(getIfInfo().getNodeId()).getLabel(); } catch (Throwable e) { return "nodeid-" + Integer.toString(getIfInfo().getNodeId()); } } else { return m_domain; } }
/** * This method queries the 'node' table for the value of the 'nodelabel' and * 'nodelabelsource' fields for the node with the provided nodeID. A * NodeLabel object is returned initialized with the retrieved values. * * WARNING: A properly instantiated and initialized Vault class object is * required prior to calling this method. This method will initially only be * called from the WEB UI. * * @param nodeID * Unique identifier of the node to be updated. * @return Object containing label and source values. * @throws java.sql.SQLException if any. * * @deprecated Use a {@link NodeDao#load(Integer)} method call instead */ @Override public NodeLabel retrieveLabel(final int nodeID) throws SQLException { final Connection dbConnection = DataSourceFactory.getInstance().getConnection(); final DBUtils d = new DBUtils(NodeLabelJDBCImpl.class, dbConnection); try { return retrieveLabel(nodeID, dbConnection); } finally { d.cleanUp(); } }
return new NodeLabelJDBCImpl(nodeLabel, NodeLabelSource.ADDRESS); } else if (NodeLabelSource.HOSTNAME.toString().equals(nodeLabelSource)) { return new NodeLabelJDBCImpl(nodeLabel, NodeLabelSource.HOSTNAME); } else if (NodeLabelSource.NETBIOS.toString().equals(nodeLabelSource)) { return new NodeLabelJDBCImpl(nodeLabel, NodeLabelSource.NETBIOS); } else if (NodeLabelSource.SYSNAME.toString().equals(nodeLabelSource)) { return new NodeLabelJDBCImpl(nodeLabel, NodeLabelSource.SYSNAME); } else if (NodeLabelSource.UNKNOWN.toString().equals(nodeLabelSource)) { return new NodeLabelJDBCImpl(nodeLabel, NodeLabelSource.UNKNOWN); } else if (NodeLabelSource.USER.toString().equals(nodeLabelSource)) { return new NodeLabelJDBCImpl(nodeLabel, NodeLabelSource.USER); } else { return new NodeLabelJDBCImpl(nodeLabel, NodeLabelSource.UNKNOWN);
@After public void verifyAnticipated() { getEventAnticipator().verifyAnticipated(1000, 0, 0, 0, 0); }
public static InetAddress resolveHostname(final String hostname) throws UnknownHostException { return resolveHostname(hostname, false); }
@Test @Ignore public void testPreferIPv6() throws Exception { DnsUtils.resolveHostname("ipv4.www.yahoo.com", false); try { DnsUtils.resolveHostname("ipv4.www.yahoo.com", true); fail(); } catch (UnknownHostException e) { // Expected exception } try { DnsUtils.resolveHostname("ipv6.www.yahoo.com", false); fail(); } catch (UnknownHostException e) { // Expected exception } DnsUtils.resolveHostname("ipv6.www.yahoo.com", true); }
@Test @Ignore public void testLookup() throws Exception { InetAddress fb = DnsUtils.resolveHostname("www.opennms.org", false); assertNotNull(fb); }
if (m_page.getRequireIPv4()) { try { InetAddress address = DnsUtils.resolveHostname(host, false); if (!(address instanceof Inet4Address)) throw new UnknownHostException(); host = InetAddressUtils.str(address); InetAddress address = DnsUtils.resolveHostname(host, true); host = "[" + InetAddressUtils.str(address) + "]"; } catch (UnknownHostException e) {