/** * <p>hasNewCollectionTypeValue</p> * * @param newVal a {@link org.opennms.netmgt.model.PrimaryType} object. * @param existingVal a {@link org.opennms.netmgt.model.PrimaryType} object. * @return a boolean. */ protected static boolean hasNewCollectionTypeValue(PrimaryType newVal, PrimaryType existingVal) { return newVal != null && !newVal.equals(existingVal) && newVal != PrimaryType.NOT_ELIGIBLE; }
@Override public PrimaryType unmarshal(final String typeCode) throws Exception { return typeCode == null? null : PrimaryType.get(typeCode); }
@Override public String marshal(final PrimaryType type) throws Exception { return type == null? null : type.getCode(); }
@Override public boolean equals(final Object o) { if (o instanceof PrimaryType) { return this.compareTo((PrimaryType)o) == 0; } else return false; }
/** * <p>setPrimaryString</p> * * @param primaryType a {@link java.lang.String} object. */ public void setPrimaryString(String primaryType) { m_isSnmpPrimary = new PrimaryType(primaryType.charAt(0)); }
@Override public int hashCode() { return Objects.hash(this.nodeId, this.type.getCharCode()); }
public boolean isLessThan(final PrimaryType collType) { return compareTo(collType) < 0; }
/** * <p>isPrimary</p> * * @return a boolean. */ @Transient @XmlTransient public boolean isPrimary(){ return m_isSnmpPrimary.equals(PrimaryType.PRIMARY); }
public static List<PrimaryType> getAllTypes() { final List<PrimaryType> types = new ArrayList<>(); for (final char c : s_order) { types.add(PrimaryType.get(c)); } return types; }
/** {@inheritDoc} */ @Override public String getAsText() { return ((PrimaryType)super.getValue()).getCode(); }
public boolean isGreaterThan(final PrimaryType collType) { return compareTo(collType) > 0; }
} else if (!getSnmpPrimary().equals(other.getSnmpPrimary())) { return false;
public static PrimaryType get(final String code) { if (code == null) { return NOT_ELIGIBLE; } final String codeText = code.trim(); if (codeText.length() < 1) { return NOT_ELIGIBLE; } else if (codeText.length() > 1) { throw new IllegalArgumentException("Cannot convert string '"+codeText+"' to a collType"); } else { return get(codeText.charAt(0)); } }
@Override public void visitInterface(final OnmsIpInterfaceRequisition ifaceReq) { final String ipAddr = ifaceReq.getIpAddr(); if (ipAddr == null || "".equals(ipAddr)) { bldr.clearInterface(); LOG.error("Found interface on node {} with an empty ipaddr! Ignoring!", bldr.getCurrentNode().getLabel()); return; } final InterfaceBuilder ifBldr = bldr.addInterface(ipAddr); ifBldr.setIsManaged(ifaceReq.getStatus() == 3 ? "U" : "M"); ifBldr.setIsSnmpPrimary(ifaceReq.getSnmpPrimary().getCode()); }
List<OnmsIpInterface> primaryInterfaces = new ArrayList<>(); for(OnmsIpInterface iface : getIpInterfaces()) { if (PrimaryType.PRIMARY.equals(iface.getIsSnmpPrimary())) { primaryInterfaces.add(iface);
/** {@inheritDoc} */ @Override public void setAsText(final String text) throws IllegalArgumentException { super.setValue(PrimaryType.get(text)); }
private void validateIsSnmpPrimary() throws CollectionInitializationException { if (!PrimaryType.PRIMARY.equals(getIsSnmpPrimary())) { throw new CollectionInitializationException("Interface " + getHostAddress() + " is not the primary SNMP interface for nodeid " + getNodeId()); } }
public InterfaceBuilder setIsSnmpPrimary(final String isSnmpPrimary) { m_iface.setIsSnmpPrimary(PrimaryType.get(isSnmpPrimary)); return this; }
try { for (IpInterfaceTopologyEntity ip: m_topologyEntityCache.getIpInterfaceTopologyEntities()) { if (ip.getIsSnmpPrimary().equals(PrimaryType.PRIMARY)) { m_nodeToOnmsIpPrimaryMap.put(ip.getNodeId(), ip); } else {
/** {@inheritDoc} */ public void foundInterface(final String ipAddr, final Object descr, final InterfaceSnmpPrimaryType snmpPrimary, final boolean managed, final int status) { if ("".equals(ipAddr)) { log().error("Found interface on node "+m_node.getLabel()+" with an empty ipaddr! Ignoring!"); // create a bogus OnmsIpInterface and set it to current to services we run across get ignored as well m_currentInterface = new OnmsIpInterface(); return; } m_currentInterface = new OnmsIpInterface(ipAddr, m_node); m_currentInterface.setIsManaged(status == 3 ? "U" : "M"); m_currentInterface.setIsSnmpPrimary(PrimaryType.get(snmpPrimary.toString())); //m_currentInterface.setIpStatus(status == 3 ? new Integer(3) : new Integer(1)); if (InterfaceSnmpPrimaryType.P.equals(snmpPrimary)) { final InetAddress addr = InetAddressUtils.addr(ipAddr); if (addr == null) { LogUtils.errorf(this, "Unable to resolve address of snmpPrimary interface for node %s", m_node.getLabel()); } m_collector = new IfSnmpCollector(addr); } //FIXME: verify this doesn't conflict with constructor. The constructor already adds this //interface to the node. m_node.addIpInterface(m_currentInterface); }