You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Jayant Ameta <wi...@gmail.com> on 2018/06/08 10:55:40 UTC

Implementation of ElasticsearchSinkFunction, how to handle class level variables

Hi,
I'm trying to integrate ElasticsearchSink in my pipeline. The example
<https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/connectors/elasticsearch.html>shows
using Anonymous class which implements ElasticsearchSinkFunction. This is
passed as a constructor argument to another anonymous class which extends
ElasticsearchSink.

Can I create a separate class instead of using anonymous classes?
If I do so, I'll have to have index and type as class level fields. How is
state maintenance done for class level fields? Do I need to mark the fields
as transient, and implement CheckpointedFunction?

Thanks,
Jayant

Re: Implementation of ElasticsearchSinkFunction, how to handle class level variables

Posted by "Tzu-Li (Gordon) Tai" <tz...@apache.org>.
Hi Jayant,

Yes, you don’t have to use an anonymous class for the sink function. An actual separate class works just as fine.
The class fields don’t need to be marked as transient or checkpointed, since they should just be constants that come with instantiation of the sink function, or could even be static fields, for example.

Cheers,
Gordon

On 8 June 2018 at 12:55:57 PM, Jayant Ameta (wittyameta@gmail.com) wrote:

Hi,
I'm trying to integrate ElasticsearchSink in my pipeline. The example shows using Anonymous class which implements ElasticsearchSinkFunction. This is passed as a constructor argument to another anonymous class which extends ElasticsearchSink.

Can I create a separate class instead of using anonymous classes?
If I do so, I'll have to have index and type as class level fields. How is state maintenance done for class level fields? Do I need to mark the fields as transient, and implement CheckpointedFunction?

Thanks,
Jayant