protected PDU prepareTrap(Notification notification, SnmpVersion snmpVersion) throws InvalidSnmpConfigurationException {
    PDU pdu = DefaultPDUFactory.createPDU(snmpVersion.getTargetVersion());
    pdu.setType(snmpVersion.getTrapType());
    // Set trap oid for PDU
    pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, new OID(getDispatchProperty(notification.DispatchProperties, TRAP_OID_PROPERTY))));
    // Set notification body and subject for PDU objects with identifiers specified in dispatch properties.
    pdu.add(new VariableBinding(new OID(getDispatchProperty(notification.DispatchProperties, BODY_OID_PROPERTY)), new OctetString(notification.Body)));
    pdu.add(new VariableBinding(new OID(getDispatchProperty(notification.DispatchProperties, SUBJECT_OID_PROPERTY)), new OctetString(notification.Subject)));
    return pdu;
  }
Creates protocol data unit (PDU) with corresponding SNMP version for alert notification.
@param notification alert notification to dispatch
@param snmpVersion SNMP version
@return PDU containing notification info
@throws InvalidSnmpConfigurationException if notification's dispatch properties don't contain any of required properties.
ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/SNMPDispatcher.java