Ask Your Question
0

How to get data from databroker?

asked 2014-09-08 10:48:35 -0700

canwu gravatar image

I have checked the wiki of the ODL, but still don't know how to deal with it, So I came to ask your help. I have checked the inside of the databroker and known that we could use "read" to get the information.

    String TargetURI = input.getTargetURI(); // get a String type URI,
    ReadTransaction getAccessID = dataService.newReadOnlyTransaction();
    InstanceIdentifier<CSEBase> target = InstanceIdentifier.keyOf(TargetURI);//?????????????? how to translate string to InstanceIdentifier?
    ListenableFuture<Optional<CSEBase>> readtarget = getAccessID.read(LogicalDatastoreType.OPERATIONAL, target);

I tried this way, of course it did not work, my question is how to get the data from a known path? Or how to translate string to InstanceIdentifier? After that, how can I use the returned datatype?

Thanks!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-09-26 04:40:00 -0700

Devin Avery gravatar image

To read from the DataBroker you create an instance identifier using InstanceIdentifer.builder(). To this method and the chained methods you would provide the class names which represent the different levels you want to read from.

Check out this section in the Toaster example for some examples: https://wiki.opendaylight.org/view/OpenDaylightController:MD-SAL:ToasterStep-By-Step#ImplementtheRPC_methods

That link also provides some examples now how to read from the broker / write to it and provides best practices for handing async requests.

For more complex InstanceIdentifier examples, check out https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Concepts#Example (BindingAware version).

edit flag offensive delete publish link more

Comments

Thanks so much!

canwu ( 2014-10-07 08:29:49 -0700 )edit
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2014-09-08 10:48:35 -0700

Seen: 377 times

Last updated: Sep 26 '14