How to serialize/deserialize IgniteConfiguration to/from JSON

classic Classic list List threaded Threaded
4 messages Options
juanavelez juanavelez
Reply | Threaded
Open this post in threaded view
|

How to serialize/deserialize IgniteConfiguration to/from JSON

Is there a way to easily serialize/deserialize an IgniteConfiguration object to/from JSON?

The IgniteConfiguration class makes use of several interfaces for properties as well as for keys which makes it very difficult to serialize/deserialize to/from JSON without having to resort to annotate the source code (which I can only guess the main developers would not want to).

Any advice or samples from someone who has already done it, would be greatly appreciated

PS: Yes, I know that I could use the Spring module for configuration but I am trying to stay away from having to use Spring, which I might not be able to avoid it after all.

Thanks - Juan
vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: How to serialize/deserialize IgniteConfiguration to/from JSON

Juan,

Currently there is no support for this, but I believe it can be added. Would you mind to create a ticket and share your thoughts on how this feature should look like?

-Val
juanavelez juanavelez
Reply | Threaded
Open this post in threaded view
|

Re: How to serialize/deserialize IgniteConfiguration to/from JSON

Hello Val,

Thank you for your prompt reply.

After responding to another issue you replied (Help with Integrating Ignite… with JBoss…) I don’t know how easy would be to describe an IgniteConfiguration object as a JSON string. As you mentioned in that reply, there are many factories, SPIs, etc. that are properties themselves.

I think the main reason for having a JSON configuration of Ignite would be to avoid the use of Spring for configuration but seeing how the IgniteConfiguration class (and its dependents) don’t really follow a JavaBean approach, I don’t think it would be a good candidate for JSON deserialization.

One of the issues (and I think in this case you have no control over it) I ran into was that CacheConfiguration extends MutableConfiguration (from JCache) and MutableConfiguration’s expiryPolicyFactory is set at construction time to EternalExpiryPolicy.factoryOf() which itself returns a FactoryBuilder.SingletonFactory that does not have a default constructor.

Another issue was with the DiscoverySpi configuration whose concrete implementation class TcpDiscoverySpi has many getter methods that when called raise an NPE (e.g. getRemoteNodes() ) and the reason for this, is that a TcpDiscoverySpi is not really ready until its spiStart method is called, which a JSON Serializer would not know about that.

Having said all this, I am going to open a ticket to request that Ignite itself provides some utility class/method that returns an IgniteConfiguration from a JSON string and generates a JSON from an IgniteConfiguration. It would be left to the implementors of the feature to determine how to specify the JSON string for deserialization and/or other restrictions/constraints/pre-requisites necessary for it to work correctly.

Thanks - Juan

> On Dec 7, 2015, at 1:20 PM, vkulichenko <[hidden email]> wrote:
>
> Juan,
>
> Currently there is no support for this, but I believe it can be added. Would
> you mind to create a ticket and share your thoughts on how this feature
> should look like?
>
> -Val
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-to-serialize-deserialize-IgniteConfiguration-to-from-JSON-tp2164p2167.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.

juanavelez juanavelez
Reply | Threaded
Open this post in threaded view
|

Re: How to serialize/deserialize IgniteConfiguration to/from JSON