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' <muthukumara...@ericsson.com>; Robert Varga <n...@hq.sk>; 
controller-dev@lists.opendaylight.org; mdsal-...@lists.opendaylight.org
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:muthukumara...@ericsson.com]
Sent: Tuesday, July 26, 2016 9:43 AM
To: Sela, Guy <guy.s...@hpe.com>; Robert Varga <n...@hq.sk>; 
controller-dev@lists.opendaylight.org; mdsal-...@lists.opendaylight.org
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:guy.s...@hpe.com]
Sent: Monday, July 25, 2016 12:45 PM
To: Muthukumaran K; Robert Varga; controller-dev@lists.opendaylight.org; 
mdsal-...@lists.opendaylight.org
Subject: RE: [mdsal-dev] Serialize/Deserialize DTOs to JSON

Quick guess: Did you just pass the Builders instead?


-----Original Message-----
From: mdsal-dev-boun...@lists.opendaylight.org 
[mailto:mdsal-dev-boun...@lists.opendaylight.org] On Behalf Of Sela, Guy
Sent: Monday, July 25, 2016 10:12 AM
To: Muthukumaran K <muthukumara...@ericsson.com>; Robert Varga <n...@hq.sk>; 
controller-dev@lists.opendaylight.org; mdsal-...@lists.opendaylight.org
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:muthukumara...@ericsson.com]
Sent: Monday, July 25, 2016 8:56 AM
To: Sela, Guy <guy.s...@hpe.com>; Robert Varga <n...@hq.sk>; 
controller-dev@lists.opendaylight.org; mdsal-...@lists.opendaylight.org
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: controller-dev-boun...@lists.opendaylight.org 
[mailto:controller-dev-boun...@lists.opendaylight.org] On Behalf Of Sela, Guy
Sent: Sunday, July 24, 2016 8:36 PM
To: Robert Varga; controller-dev@lists.opendaylight.org; 
mdsal-...@lists.opendaylight.org
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:n...@hq.sk]
Sent: Sunday, July 24, 2016 4:52 PM
To: Sela, Guy <guy.s...@hpe.com>; controller-dev@lists.opendaylight.org; 
mdsal-...@lists.opendaylight.org
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
controller-dev@lists.opendaylight.org
https://lists.opendaylight.org/mailman/listinfo/controller-dev
_______________________________________________
mdsal-dev mailing list
mdsal-...@lists.opendaylight.org
https://lists.opendaylight.org/mailman/listinfo/mdsal-dev
_______________________________________________
controller-dev mailing list
controller-dev@lists.opendaylight.org
https://lists.opendaylight.org/mailman/listinfo/controller-dev

Reply via email to