Reputation: 11
I have this custom Aggregator written, which aggregation response is a HashMap. I have a problem on client side deserializer fails in the error given below. Any clue what could be wrong?
public class CountFixtureBySportAggregator extends Aggregator<HashMap.Entry<TraderVWFixtureKey, TraderVWFixture>, HashMap<Integer, Integer>> {
private static final long serialVersionUID = 1L;
private final HashMap<Integer, Set<String>> countBySportIdMap;
public CountFixtureBySportAggregator() {countBySportIdMap = new HashMap<>();}
@Override
public void accumulate(HashMap.Entry<TraderVWFixtureKey, TraderVWFixture> input) {
TraderVWFixture inputValue = input.getValue();
Integer sportId = inputValue.getSportId();
Set<String> matchIds = countBySportIdMap.getOrDefault(sportId, new HashSet<>());
if (inputValue.getOutrightId() == null) {
matchIds.add(inputValue.getMatchId());
} else {
matchIds.add(inputValue.getOutrightId());
}
countBySportIdMap.put(sportId, matchIds);
}
@Override
public void combine(Aggregator aggregator) {
CountFixtureBySportAggregator countFixtureBySportAggregator = (CountFixtureBySportAggregator) aggregator;
Map<Integer, Set<String>> sportCountMap = countFixtureBySportAggregator.getCountBySportIdMap();
for (Map.Entry<Integer, Set<String>> entry : sportCountMap.entrySet()) {
Integer key = entry.getKey();
countBySportIdMap.computeIfAbsent(key, integer -> new HashSet<>());
countBySportIdMap.get(key).addAll(entry.getValue());
}
}
@Override
public HashMap<Integer, Integer> aggregate() {
return new HashMap(countBySportIdMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, v -> v.getValue().size())));
}
public HashMap<Integer, Set<String>> getCountBySportIdMap() { return countBySportIdMap; }
}
Deserialization error on client:
com.hazelcast.nio.serialization.HazelcastSerializationException: There is no suitable de-serializer for type -322. This exception is likely to be caused by differences in the serialization configuration between members or between clients and members.
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.newHazelcastSerializationException(AbstractSerializationService.java:238)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:182)
at com.hazelcast.client.spi.ClientProxy.toObject(ClientProxy.java:102)
at com.hazelcast.client.proxy.ClientMapProxy.aggregate(ClientMapProxy.java:1543)
Upvotes: 0
Views: 204
Reputation: 11
I have found out what the issue was. I am working with hazelcast:3.12.3
dependency which does not support HashMap serialization, see: Hazelcast 3.12 Documentation.
The problem was that server had hazelcast.jet:hazelcast-jet:3.2
dependency so for HashMap serialization on server side, it used this serializator which was marked as type -322: com.hazelcast.jet.impl.serialization.HashMapHook
. But as client side did not have dependency on hazelcast jet module it did not find this serializator, hence it threw this error when deserializing fetched response.
The solution was to add jet dependency on client side. The alternative could also be to increase hazelcast version to 4.x.x since this version supports HashMap serialization.
Upvotes: 1