Just a quick update about this issue. I'm still using the DTOs and not the NormalizedNode because I'm working on a demo. With the correct strategy in KRYO, you can pass the DTOs themselves and not the Builders: kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
This still won't work if you just send the DTO. But, if you wrap it in your own "message" Object, which exposes a no-args constructor, you can send the DTO as is. -----Original Message----- From: Sela, Guy Sent: Tuesday, July 26, 2016 1:01 PM To: 'Muthukumaran K' <[email protected]>; Robert Varga <[email protected]>; [email protected]; [email protected] Subject: RE: [mdsal-dev] Serialize/Deserialize DTOs to JSON Can you elaborate of what you exactly mean by creating a codec per DTO? In my usecase, I want to send an instance of the DTO "X" between sites. * I create a new XBuilder initialized with the instance of X. * I use KRYO to serialize the XBuilder on Site 1. * Send it to Site 2. * Site 2 expects to receive an XBuilder, so it just uses KRYO to deserialize the byte array into XBuilder. * Calls build() on the XBuilder * Gets a cloned instance of X. -----Original Message----- From: Muthukumaran K [mailto:[email protected]] Sent: Tuesday, July 26, 2016 9:43 AM To: Sela, Guy <[email protected]>; Robert Varga <[email protected]>; [email protected]; [email protected] Subject: RE: [mdsal-dev] Serialize/Deserialize DTOs to JSON Hi Guy, You are correct. That was a quick dirty hack I did for a demo. As I said, this would not scale as we have to create codec for every binding-aware DTO. That's why I dropped the idea. Regards Muthu -----Original Message----- From: Sela, Guy [mailto:[email protected]] Sent: Monday, July 25, 2016 12:45 PM To: Muthukumaran K; Robert Varga; [email protected]; [email protected] Subject: RE: [mdsal-dev] Serialize/Deserialize DTOs to JSON Quick guess: Did you just pass the Builders instead? -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Sela, Guy Sent: Monday, July 25, 2016 10:12 AM To: Muthukumaran K <[email protected]>; Robert Varga <[email protected]>; [email protected]; [email protected] Subject: Re: [mdsal-dev] Serialize/Deserialize DTOs to JSON How did you manage to work with Kryo given the fact that the DTOs don't offer a no-args constructor? -----Original Message----- From: Muthukumaran K [mailto:[email protected]] Sent: Monday, July 25, 2016 8:56 AM To: Sela, Guy <[email protected]>; Robert Varga <[email protected]>; [email protected]; [email protected] Subject: RE: [mdsal-dev] Serialize/Deserialize DTOs to JSON As a naïve experiment, I had tried Kryo serialization. It did work for basic serialization and deserialization. But that was nothing serious. There are some dangers in using Kryo and hence dropped the idea. Regards Muthu -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Sela, Guy Sent: Sunday, July 24, 2016 8:36 PM To: Robert Varga; [email protected]; [email protected] Subject: Re: [controller-dev] [mdsal-dev] Serialize/Deserialize DTOs to JSON Thanks Robert. And what about just serialize/deserialize DTOs in an efficient way? (ProtoBuffs?) Is there something like that implemented? -----Original Message----- From: Robert Varga [mailto:[email protected]] Sent: Sunday, July 24, 2016 4:52 PM To: Sela, Guy <[email protected]>; [email protected]; [email protected] Subject: Re: [mdsal-dev] Serialize/Deserialize DTOs to JSON On 07/24/2016 01:36 PM, Sela, Guy wrote: > Hi, > > Is there an API that I can call which gets a DataObject as input and > returns a JSON representation of it? Not directly, as DataObject and related generated code is an access facade. Primary data representation is NormalizedNode, hence you need to transform the DTOs to NormalizedNodes (see mdsal-binding-dom-codec) and then use yang-data-codec-gson (or -xml) to get the representation you seek. I think TTPUtils (in TTP) does exactly that. Bye, Robert _______________________________________________ controller-dev mailing list [email protected] https://lists.opendaylight.org/mailman/listinfo/controller-dev _______________________________________________ mdsal-dev mailing list [email protected] https://lists.opendaylight.org/mailman/listinfo/mdsal-dev _______________________________________________ controller-dev mailing list [email protected] https://lists.opendaylight.org/mailman/listinfo/controller-dev
