简体   繁体   English

Flink:包装可执行的非flink jar 在flink集群中运行

[英]Flink: Wrap executable non-flink jar to run it in a flink cluster

Assume that I have an executable jar file that doesn't have any flink code inside and my job is to make it distributed with flink.假设我有一个可执行的 jar 文件,里面没有任何 flink 代码,我的工作是让它与 flink 一起分发。 I have already done this once by creating and executing the StreamExecutionEnvironment somewhere in the code and placing the code of the jar that can be distributed inside flink operators (ie, map functions).我已经通过在代码中的某处创建和执行 StreamExecutionEnvironment 并将 jar 的代码放置在 flink 运算符(即 map 函数)中来完成此操作。

Yesterday, I was asked to do a similar job but with minimal effort.昨天,我被要求做类似的工作,但付出的努力很小。 They told me to find a way to wrap this flink-less jar in a way that it can be executed by a flink cluster (without injecting code and altering the jar like i did above).他们告诉我要找到一种方法来包装这个无 flink jar,使其可以由 flink 集群执行(无需像我上面那样注入代码和更改 jar)。 Is there a way to do this?有没有办法做到这一点? The docs state that to support execution from a packaged jar "a program must use the environment obtained by StreamExecutionEnvironment.getExecutionEnvironment()". 文档state 支持从打包的 jar 执行“程序必须使用通过 StreamExecutionEnvironment.getExecutionEnvironment() 获得的环境”。 Is there no other way?难道没有别的办法了吗?

My only guess right now is to wrap the entry point of the jar.我现在唯一的猜测是包装 jar 的入口点。 To place it inside flink operators but unfortunately I don't know that this jar does将它放在 flink 运算符中,但不幸的是我不知道这个 jar 确实

You could write a map only program and package it in jar.您可以在 jar 中编写仅 map 程序和 package 程序。 In the map, you execute the main through reflection of the provided jar.在 map 中,您通过反射提供的 jar 执行 main。

Your small wrapper could be put into Flink lib to be reusable for other jars or you add the other jar in the distributed cache .您的小型包装器可以放入 Flink 库中,以便其他 jars 可重用,或者您将其他 jar 添加到分布式缓存中。

Btw, I haven't fully understood the use case or I find weird, since it's unclear to me how the parallelism is supposed to work.顺便说一句,我还没有完全理解用例,或者我觉得很奇怪,因为我不清楚并行性应该如何工作。 So sorry if the answer does not help.很抱歉,如果答案没有帮助。

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

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