Ask Your Question
0

How do I extract data from a DataChangeEvent?

asked 2016-07-22 06:00:47 -0700

Gamuto gravatar image

updated 2016-08-01 06:13:17 -0700

Hello everyone,

I created a plugin for ODL which implements a DataChangeListener to extract the current topology from OpenDaylight by using the following code:

InstanceIdentifier<Topology> topologyIID = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(new TopologyId("flow:1")));

this.registration = db.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, topologyIID, this, DataChangeScope.SUBTREE);

It works fine so far providing a new DataChangeEvent everytime the topology gets updated.

However, I'm having trouble to use the data provided by the DataChangeEvent. I know how to get a specific node with...

event.getCreatedData().get(iid)

and an InstanceIdentifier which points at a node with a given ID. But can I get a list of all new created nodes and links or something similar?

Thank you in advance and have a great weekend,

Gamuto

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-08-01 06:12:17 -0700

Gamuto gravatar image

I figured it out! The DataChangeEvent gives you certain objects you can work with.

event.getCreatedData() returns a Collection you can iterate over and access the data of, for example nodes, by using something like this:

for (Iterator iterator = createdDataValues.iterator(); iterator.hasNext();) {
            Object object = (Object) iterator.next();
            // Object is a Node
            if (object instanceof Node) {
                Node new_name = (Node) object;
                System.out.println(new_name.getNodeId());
            }
}
edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2016-07-22 06:00:47 -0700

Seen: 21 times

Last updated: Aug 01 '16