Reputation: 1
I am trying to use EntryProcessor with CompactSerialization with Hazelcast 5.2 version but getting below error:
Hazelcast.Protocol.RemoteException: 'com.hazelcast.internal.serialization.impl.compact.DeserializedGenericRecord cannot be cast to com.hazelcast.map.EntryProcessor'
Can you please help and guide me what am I missing here? Is there anything need to configure from hazelcast.config side?
My .NET Client side:
public class MyTest
{
public int ID { get; set; }
public bool IsGroupLevel { get; set; }
public int ItemFormContext { get; set; }
public MyTest() { }
public MyTest(int id, bool isGroupLevel, int itemFormContext)
{
this.ID = id;
this.IsGroupLevel = isGroupLevel;
this.ItemFormContext = itemFormContext;
}
}
public class MyTestSerializer : ICompactSerializer\<MyTest\>
{
public string TypeName => "MyTest";
public MyTest Read(ICompactReader reader)
{
var ID = reader.ReadInt32("ID");
var IsGroupLevel = reader.ReadBoolean("IsGroupLevel");
var ItemFormContext = reader.ReadInt32("ItemFormContext");
return new MyTest(ID, IsGroupLevel, ItemFormContext);
}
public void Write(ICompactWriter writer, MyTest value)
{
writer.WriteInt32("ID", value.ID);
writer.WriteBoolean("IsGroupLevel", value.IsGroupLevel);
writer.WriteInt32("ItemFormContext", value.ItemFormContext);
}
}
public class UpdateEntryProcessor : MyTestSerializer, IEntryProcessor<MyTest>
{
private MyTest value;
public UpdateEntryProcessor(MyTest value = null)
{
this.value = value;
}
}
public class Program
{
//Creating client
var options = new HazelcastOptionsBuilder()
.With(args)
.WithDefault("hazelcast.networking.addresses.0", "\<ip address\>") //Read Hazelcast server address from config file
.WithDefault("hazelcast.clustername", "local")
.WithDefault("hazelcast.socket.receive.buffer.size", "128")
.WithDefault("hazelcast.socket.client.receive.buffer.size", "128")
.WithDefault("hazelcast.socket.send.buffer.size", "128")
.Build();
options.Networking.ReconnectMode = Hazelcast.Networking.ReconnectMode.ReconnectSync;
options.Serialization.Compact.AddSerializer(new MyTestSerializer());
IHazelcastClient client = HazelcastClientFactory.StartNewClientAsync(options).GetAwaiter().GetResult();
var vpmap = client.GetMapAsync\<int, MyTest\>("vpMap").GetAwaiter().GetResult();
vpmap.SetAsync(1, new MyTest(1, false, 100)).GetAwaiter().GetResult();
var r1 = vpmap.GetAsync(1).GetAwaiter().GetResult();
//update using entry processor
vpmap.ExecuteAsync(new UpdateEntryProcessor(r1), r1.ID).GetAwaiter().GetResult();
}
Can you please help and guide me what am I missing here? Is there anything need to configure from hazelcast.config side?
Upvotes: 0
Views: 291
Reputation: 702
It means that your server does not know MyTest type. So it is creating a DeserializedGenericRecord but your EntryProcessor expects MyTest and you are getting class cast exception Either
See this question for some examples with UCD
Deploy compactSerializer to hazelcast member
Upvotes: 0