0
votes

I have a server node based on the example mentioned in https://github.com/apache/ignite/blob/master/modules/platforms/dotnet/examples/ServerNode/Program.cs

Also in another process, I have a client with "ClientMode = true" like below.

        return new IgniteConfiguration(GetServerNodeConfiguration())
        {
            ClientMode = true
        };

The cache will hold the information of the "Employee" class, and I'm using IBinarySerializer to serialize the "Employee" and "Address" classes, and serializers are added into the IgniteConfiguration as below...

IgniteConfiguration.BinaryConfiguration = new BinaryConfiguration
                {
                    TypeConfigurations = new List<BinaryTypeConfiguration>
                    {
                        new(typeof(Employee)){Serializer = new EmployeeSerializer()},
                        new(typeof(Address)){Serializer = new AddressSerializer()},
                    }
                }

My questions are...

  1. Do we need to have the "Employee" and "Address" classes both on the server and the client code? or do I just mention them on the client side?
  2. Do we need to have the IBinarySerializer serializers in ignite BinaryConfiguration both on the server and the client code? or do I just mention them on the client-side?

Employee

public class Employee
{
    public Guid EmployeeId { get; set; }
    public string Name { get; set; }
    public Address Address { get; set; }
}

Address

public class Address
{
    public string Street { get; set; }
    public string Zip { get; set; }
}

IBinarySerializer implementations

public sealed class EmployeeSerializer : IBinarySerializer
{
    public void WriteBinary(object obj, IBinaryWriter writer)
    {
        var employee = (Employee)obj;

        writer.WriteGuid("employeeId", employee.EmployeeId );
        writer.WriteString("name", employee.Name);
        writer.WriteObject("address", employee.Address);
    }

    public void ReadBinary(object obj, IBinaryReader reader)
    {
        var employee = (employee)obj;

        employee.EmployeeId  = reader.ReadObject<Guid>("employeeId");
        employee.Name = reader.ReadString("name");
        employee.Address = reader.ReadObject<Address>("address");
    }
}


public sealed class AddressSerializer : IBinarySerializer
{
    public void WriteBinary(object obj, IBinaryWriter writer)
    {
        var address = (Address)obj;

        writer.WriteString("street", address.Street);
        writer.WriteString("zip", address.Zip);
    }

    public void ReadBinary(object obj, IBinaryReader reader)
    {
        var address = (Address)obj;

        address.Street = reader.ReadString("street");
        address.Zip = reader.ReadString("zip");
    }
}