Based on input from (DMaaP) team and possible lack of future support we will do filtering on client side
4
Decide on which property to filter on
Which property from the DMaaP event should we filter on?
5
Update Events for address information
is it possible for address information to change ie. does CPS need to listen to these?
Address information might change but we don't need to worry about it for our use case as we use SDN-C and only the pnf-id to identify the resource
Background
When a xNF object is added to A&AI, a DMaaP event, AAI-EVENT is created. A&AI handles the publishing of this event. To be notified of the AAI-EVENT, CPS will need to register on DMaaP Message Router.
DMaaP offers a client plugin called DMaaP Client, which can be found here. This Client can be used to register to a DMaaP event. The PoC code will use this client to show that CPS can listen for and receive DMaaP events.
Filtering of AAI-EVENT
Based on input from the DMaaP team, the filtering will be done on client side. From looking at the DMaaP event that is created when a xNF is created, we can filter on the following properties:
equip-type
equip-vendor
equip-model
AAI-EVENT received from DMaaP
AAI-EVENT received from DMaaP can have different event-header.action values. These are:
CREATE
UPDATE
DELETE
Each action value refers to the type of operation happening to a xNF on A&AI. When a xNF is added to A&AI, the event-header.action value is CREATE. When a xNF is updated in A&AI, the event-header.action value is UPDATE. When a xNF is deleted in A&AI, the event-header.action value is DELETE.
Example of DMaaP Event when a xNF is added to A&AI:
The following builder method is used to create an instance of a DMaaP Consumer Client:
Code Block
language
java
theme
RDark
title
Example DMaaP Consumer Client
linenumbers
true
final MRConsumerImpl mrConsumer = new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(hosts)
.setTopic("AAI-EVENT").setConsumerGroup("onap-cps").setConsumerId("cps-ncmp").setTimeoutMs(10000)
.setLimit(1000).setFilter("").setApiKey_username(null)
.setApiSecret_password(null).createMRConsumerImpl();
*Note setFilter() method is not documented and we have been advised by DMaaP team not to use it. So all filtering as to be done on client side. See also issue #2
For the Consumer client to be created we need to pass in the values for the following attributes:
Attribute name
Attribute Description
Example
setHostPart
The host and port of the DMaaP server in the format <host:port>. This method takes a collection of strings, check example.
Code Block
language
java
theme
RDark
title
Example of HostPart
linenumbers
true
final Collection<String> hosts = new ArrayList<>();
hosts.add("message-router.onap:3904");
setTopic
The topic name to consume from
"AAI-EVENT"
setConsumerGroupThe consumer group to consume from
A name that uniquely identifies the subscriber's group
"onap-cps"
setConsumerIdThe consumer ID of the client
Within the subscriber's group, a name that uniquely identifies the subscriber's process
"cps-ncmp"
setTimeoutMs
Time in ms to wait for messages on the server before returning
10000
setLimit
Maximum number of messages that is returned per fetch
1000
setFilter
A customizable message filter, or null if no filtering is required
null
setApiKey_username
The username of the client application
null
setApiSecret_password
The password for the username
null
Adding required properties to the consumer
The consumer also takes in the following properties:
...
Code Block
language
java
theme
RDark
title
Setting the Protocol property
linenumbers
true
# The http protocol to use:
# http
# https
final Properties props = new Properties();
props.setProperty("Protocol", "http");
mrConsumer.setProps(props);
Fetching DMaaP event using the consumer object
To fetch, the following method needs to be called on the consumer object:
Code Block
language
java
theme
RDark
title
Fetch Method Example
linenumbers
true
mrConsumer.fetch()
POC code used in the demo
Code Block
language
java
theme
RDark
title
Demo POC code
linenumbers
true
collapse
true
public static void main(String[] args) throws Exception {
final Collection<String> hosts = new ArrayList<>();
hosts.add("message-router.onap:3904");
final MRConsumerImpl mrConsumer = new MRConsumerImpl.MRConsumerImplBuilder().setHostPart(hosts)
.setTopic("AAI-EVENT").setConsumerGroup("cg").setConsumerId("cid").setTimeoutMs(10000)
.setLimit(1000).setFilter("").setApiKey_username(null)
.setApiSecret_password(null).createMRConsumerImpl();
mrConsumer.setProtocolFlag("HTTPNOAUTH");
final Properties props = new Properties();
props.setProperty("Protocol", "http");
mrConsumer.setProps(props);
log.info("fetch {}", mrConsumer.fetch());
}