Suppressing reflective serialisation in Ignite

classic Classic list List threaded Threaded
5 messages Options
Raymond Wilson Raymond Wilson
Reply | Threaded
Open this post in threaded view
|

Suppressing reflective serialisation in Ignite

We are currently converting our use of Ignite reflective serialisation to use IBinarizable based serialisation [using Ignite 2.6 with c# client]

What I would like to do is enforce a policy of not using reflective serialisation to ensure we have all the bases covered.

Is there a way to do this in Ignite?

Thanks,
Raymond.

Denis Magda-2 Denis Magda-2
Reply | Threaded
Open this post in threaded view
|

Re: Suppressing reflective serialisation in Ignite

Hi Raymond,

If to believe this page, the reflective serialization converts an object to the binary format (sort of marked with IBaniralizable interface implicitly):

--
Denis


On Tue, Nov 6, 2018 at 1:01 PM Raymond Wilson <[hidden email]> wrote:
We are currently converting our use of Ignite reflective serialisation to use IBinarizable based serialisation [using Ignite 2.6 with c# client]

What I would like to do is enforce a policy of not using reflective serialisation to ensure we have all the bases covered.

Is there a way to do this in Ignite?

Thanks,
Raymond.

Raymond Wilson Raymond Wilson
Reply | Threaded
Open this post in threaded view
|

Re: Suppressing reflective serialisation in Ignite

Hi Denis,

Yes, I understand reflective serialisation uses binarizable serialisation under the hood (and it's fast and easy to use). But it has issues in the face of schema changes so it is better (and recommended in the Ignite docs) to use Binarizable serialization for production.

I want to make sure all my serialization contexts are covered by explicit IBinarizable serialization. A simple approach would be to turn off reflective serialization to ensure cases where we have missed it fail explicitly. Is that possible?

Thanks,
Raymond.


On Thu, Nov 8, 2018 at 1:10 PM Denis Magda <[hidden email]> wrote:
Hi Raymond,

If to believe this page, the reflective serialization converts an object to the binary format (sort of marked with IBaniralizable interface implicitly):

--
Denis


On Tue, Nov 6, 2018 at 1:01 PM Raymond Wilson <[hidden email]> wrote:
We are currently converting our use of Ignite reflective serialisation to use IBinarizable based serialisation [using Ignite 2.6 with c# client]

What I would like to do is enforce a policy of not using reflective serialisation to ensure we have all the bases covered.

Is there a way to do this in Ignite?

Thanks,
Raymond.

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

Re: Suppressing reflective serialisation in Ignite

Hi Raymond,

Yes, you can do that by implementing IBinarySerializer like this:

class BinarizableSerializer : IBinarySerializer
{
public void WriteBinary(object obj, IBinaryWriter writer)
{
if (obj is IBinarizable bin)
{
bin.WriteBinary(writer);
}

throw new Exception("Not IBinarizable: " + obj.GetType());

}

public void ReadBinary(object obj, IBinaryReader reader)
{
if (obj is IBinarizable bin)
{
bin.ReadBinary(reader);
}

throw new Exception("Not IBinarizable: " + obj.GetType());
}
}
Then set it globally in IgniteConfiguration:
var cfg = new IgniteConfiguration
{
BinaryConfiguration = new BinaryConfiguration
{
Serializer = new BinarizableSerializer()
}
};


On Thu, Nov 8, 2018 at 9:28 PM Raymond Wilson <[hidden email]> wrote:
Hi Denis,

Yes, I understand reflective serialisation uses binarizable serialisation under the hood (and it's fast and easy to use). But it has issues in the face of schema changes so it is better (and recommended in the Ignite docs) to use Binarizable serialization for production.

I want to make sure all my serialization contexts are covered by explicit IBinarizable serialization. A simple approach would be to turn off reflective serialization to ensure cases where we have missed it fail explicitly. Is that possible?

Thanks,
Raymond.


On Thu, Nov 8, 2018 at 1:10 PM Denis Magda <[hidden email]> wrote:
Hi Raymond,

If to believe this page, the reflective serialization converts an object to the binary format (sort of marked with IBaniralizable interface implicitly):

--
Denis


On Tue, Nov 6, 2018 at 1:01 PM Raymond Wilson <[hidden email]> wrote:
We are currently converting our use of Ignite reflective serialisation to use IBinarizable based serialisation [using Ignite 2.6 with c# client]

What I would like to do is enforce a policy of not using reflective serialisation to ensure we have all the bases covered.

Is there a way to do this in Ignite?

Thanks,
Raymond.

Raymond Wilson Raymond Wilson
Reply | Threaded
Open this post in threaded view
|

Re: Suppressing reflective serialisation in Ignite

Thanks Pavel - works well! :)

Raymond.

On Tue, Nov 13, 2018 at 9:20 AM Pavel Tupitsyn <[hidden email]> wrote:
Hi Raymond,

Yes, you can do that by implementing IBinarySerializer like this:

class BinarizableSerializer : IBinarySerializer
{
public void WriteBinary(object obj, IBinaryWriter writer)
{
if (obj is IBinarizable bin)
{
bin.WriteBinary(writer);
}

throw new Exception("Not IBinarizable: " + obj.GetType());

}

public void ReadBinary(object obj, IBinaryReader reader)
{
if (obj is IBinarizable bin)
{
bin.ReadBinary(reader);
}

throw new Exception("Not IBinarizable: " + obj.GetType());
}
}
Then set it globally in IgniteConfiguration:
var cfg = new IgniteConfiguration
{
BinaryConfiguration = new BinaryConfiguration
{
Serializer = new BinarizableSerializer()
}
};


On Thu, Nov 8, 2018 at 9:28 PM Raymond Wilson <[hidden email]> wrote:
Hi Denis,

Yes, I understand reflective serialisation uses binarizable serialisation under the hood (and it's fast and easy to use). But it has issues in the face of schema changes so it is better (and recommended in the Ignite docs) to use Binarizable serialization for production.

I want to make sure all my serialization contexts are covered by explicit IBinarizable serialization. A simple approach would be to turn off reflective serialization to ensure cases where we have missed it fail explicitly. Is that possible?

Thanks,
Raymond.


On Thu, Nov 8, 2018 at 1:10 PM Denis Magda <[hidden email]> wrote:
Hi Raymond,

If to believe this page, the reflective serialization converts an object to the binary format (sort of marked with IBaniralizable interface implicitly):

--
Denis


On Tue, Nov 6, 2018 at 1:01 PM Raymond Wilson <[hidden email]> wrote:
We are currently converting our use of Ignite reflective serialisation to use IBinarizable based serialisation [using Ignite 2.6 with c# client]

What I would like to do is enforce a policy of not using reflective serialisation to ensure we have all the bases covered.

Is there a way to do this in Ignite?

Thanks,
Raymond.