简体   繁体   English

Flink 从单个 jar 运行多个作业

[英]Flink runs multiple jobs from single jar

I have 2 jobs read data from 2 topics in Kafka.我有 2 个作业从 Kafka 的 2 个主题中读取数据。 Business logic of each job is different and can be run in parallel but they are using any common lib, function,... So I write 2 jobs in one project java.每个作业的业务逻辑不同,可以并行运行,但它们使用任何公共库、函数、...所以我在一个项目 java 中编写了 2 个作业。 I have any questions to run 2 jobs above:我有任何问题要运行上面的 2 个作业:

Opt1 : Upload one jar (1 main class includes 2 streams), and run 1 job. Opt1 :上传一个 jar(1 个主类包括 2 个流),并运行 1 个作业。

=> But with the checkpoint, job 1 can be affected to job 2 and affect to performance. => 但是有了检查点,工作 1 可能会影响工作 2 并影响性能。

Opt2 : Upload one jar (2 main class corresponding to 2 streams) and run 2 jobs through EntryClass: Opt2 :上传一个 jar(2 个主类对应 2 个流)并通过 EntryClass 运行 2 个作业:

=> But when I run 2 jobs, I have catch a error org.apache.kafka.common.config.ConfigException: Invalid value org.apache.kafka.common.serialization.StringSerializer for configuration key.serializer: Class org.apache.kafka.common.serialization.StringSerializer could not be found. => 但是当我运行 2 个作业时,我发现了一个错误org.apache.kafka.common.config.ConfigException: Invalid value org.apache.kafka.common.serialization.StringSerializer for configuration key.serializer: Class org.apache.kafka.common.serialization.StringSerializer could not be found. If i run only 1 job, There will no error.如果我只运行 1 个作业,则不会出现错误。 I think flink conflict when deploy the same 2 file jars.我认为部署相同的 2 个文件 jar 时会发生 flink 冲突。

Opt3 : Each job builds one jar and runs 2 jobs corresponding to 2 jars: Opt3 :每个作业构建一个 jar 并运行对应于 2 个 jar 的 2 个作业:

=> I think similar Opt2. => 我认为类似的 Opt2。

Until you KNOW for sure that you've got an issue, simpler is better.直到你肯定知道你有一个问题,越简单越好。 So I would first use one jar with one workflow (your Opt1), and only if you run into issues would I look at creating two jars (each with their own workflow) that you run at the same time on your cluster (your Opt3).因此,我首先将一个 jar 与一个工作流(您的 Opt1)一起使用,只有当您遇到问题时,我才会考虑创建两个同时在集群(您的 Opt3)上运行的 jar(每个都有自己的工作流) .

As an aside, the issue you encountered with Opt2 sounds like a packaging problem with your jar.顺便说一句,您遇到的 Opt2 问题听起来像是 jar 的包装问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM