George K J
George K J

Reputation: 23

Custom Serialization capability for EntryProcessor in Hazelcast

Do we have custom serialization capability for EntryProcessor or ExecutorService ?. Hazelcast document is not specifying anything in this regard. There are no samples given in the document related to custom serialization of EntryProcessor. We are looking for a Portable serialization of the EntryProcessor.

public class SampleEntryProcessor implements EntryProcessor<SampleDataKey, SampleDataValue , SampleDataValue >,Portable {

/**
 * 
 */
private static final long serialVersionUID = 1L;

private SampleDataValue sampleDataValue ;

public SampleDataValue process(Map.Entry<SampleDataKey, SampleDataValue > entry) {
    
    //Sample logic here
    return null;
}


@Override
public int getFactoryId() {
    return 1;
}

@Override
public int getClassId() {
    return 1;
}

@Override
public void writePortable(PortableWriter writer) throws IOException {
    writer.writePortable("i", sampleDataValue );
    
}

@Override
public void readPortable(PortableReader reader) throws IOException {
    sampleDataValue = reader.readPortable("i");
}

}

UPDATE : When i try to call processor am getting error as follows.

Exception in thread "main" java.lang.ClassCastException: com.hazelcast.internal.serialization.impl.portable.DeserializedPortableGenericRecord cannot be cast to com.hazelcast.map.EntryProcessor
at com.hazelcast.client.impl.protocol.task.map.MapExecuteOnKeyMessageTask.prepareOperation(MapExecuteOnKeyMessageTask.java:42)
at com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask.processInternal(AbstractPartitionMessageTask.java:45)

Upvotes: 1

Views: 137

Answers (1)

mdumandag
mdumandag

Reputation: 276

Yes, you can use different serialization mechanisms to serialize entry processors, provided that they are correctly configured on the sender and receiver sides. So, after making sure that the Portable factory for your class is registered on the members and on the instance you are sending the entry processor from (for example, your client), it should work.

Upvotes: 0

Related Questions