0

I am trying to use a pojo which does not implement Serializable from an external library in the kinesis flink application .The serialization is failing while using it inside flatMap function.

Pojo

public class ExecutionRecord {
    private Map<String, VariableGroup> factMap;
    private List<ModelResult> models;
    private List<RulesetResult> rulesets;
    private Outcome outcome;
    private ExecutionMetadata executionMetadata;
}

Output of TypeInformation.of(ExecutionRecord.class).toString()

PojoType<ExecutionRecord, fields = [executionMetadata: PojoType<ExecutionMetadata, fields = [endTime: String, evaluationType: String, executionHost: String, executionId: String, gmraInstanceIDs: GenericType<java.util.List>, startTime: String]>, factMap: GenericType<java.util.Map>, models: GenericType<java.util.List>, outcome: PojoType<Outcome, fields = [actions: GenericType<java.util.List>, failedActions: GenericType<java.util.List>, outcomeName: String]>, rulesets: GenericType<java.util.List>]>

Error- java.io.NotSerializableException: ExecutionRecord

The stack trace is also not showing which specific field it is not able to serialize.

How shall I register the serializer for java.util.list and java.util.map which are recognised as generic types and for rest of custom pojos

Yash Jain
  • 1
  • 1
  • Are you using the default serializer (Kyro)? Does `ExecutionRecord` satisfy all the [requirements](https://ci.apache.org/projects/flink/flink-docs-release-1.13/docs/dev/serialization/types_serialization/#pojos)? (For example I can't see getters for the private fields) – Peter Csala Jun 30 '21 at 11:35
  • @PeterCsala I tried by both ways - force enabling Kyro as well letting flink decide. Yes, those are getting satisfied. The pojo has the public getter , setter for all fields as well as default constructor . I think that why its getting recognized as pojoType from TypeInformation output. – Yash Jain Jun 30 '21 at 21:02

1 Answers1

0

You can do something like this

public static final TypeInformation<ExecutionRecord> TYPE_INFORMATION_POJO = Types.POJO(ExecutionRecord.class);

or

public static final TypeInformation<ExecutionRecord> TYPE_INFORMATION = TypeInformation.of(BehProdViewFLDTO.class);

and pass either TYPE_INFORMATION_POJO or TYPE_INFORMATION to the states or when you may needed!

Alter
  • 903
  • 1
  • 11
  • 27