[英]Run a Flink job on a remote cluster without providing a .jar
I have the following problem: I want to create a Flink job in IntelliJ on a local machine and run it on a remote cluster which is located in a VM.我有以下问题:我想在本地机器上的 IntelliJ 中创建一个 Flink 作业,并在位于 VM 中的远程集群上运行它。 I used the createRemoteEnvironment function but anonymous classes as well as lambda expressions require jar files (if I didn't miss anything).
我使用了createRemoteEnvironment函数,但匿名类以及 lambda 表达式需要 jar 文件(如果我没有遗漏任何东西)。 Is there a (or another) way to run a Flink job on remote cluster without providing jar files?
是否有(或另一种)方法可以在不提供 jar 文件的情况下在远程集群上运行 Flink 作业? The following code is a simple Flink job I wanted to run on the remote cluster (without a jar).
下面的代码是我想在远程集群上运行的一个简单的 Flink 作业(没有 jar)。
public static void main(String[] args) throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.createRemoteEnvironment("192.168.56.101", 6123);
DataStream<Tuple2<String, Integer>> dataStream = env
.socketTextStream("192.168.56.102", 8080)
.flatMap((String sentence, Collector<Tuple2<String, Integer>> out) ->
{
for (String word: sentence.split(" ")) {
out.collect(new Tuple2<String, Integer>(word, 1));
}
});
// Alternative approach with an anonymous class
/*DataStream<Tuple2<String, Integer>> dataStream = env
.socketTextStream("localhost", 8080)
.flatMap(new FlatMapFunction<String, Tuple2<String, Integer>>() {
@Override
public void flatMap(String sentence, Collector<Tuple2<String, Integer>> out)
throws Exception {
for (String word: sentence.split(" ")) {
out.collect(new Tuple2<String, Integer>(word, 1));
}
}
});*/
dataStream.print();
env.execute("Window WordCount");
}
Thanks for any help!谢谢你的帮助!
Based on the description here the error may be less than intuitive, but it essentially means you need a dependency.根据这里的描述,错误可能不太直观,但它本质上意味着您需要一个依赖项。
Conceptually, that means you need to provide the dependency.从概念上讲,这意味着您需要提供依赖项。
And this is normally done by providing it in a jar.这通常是通过将它放在一个罐子里来完成的。
So, based on how dependencies work in general I think the answer is that you must indeed provide the Jar to run the code that requires the dependency.因此,基于依赖项的一般工作方式,我认为答案是您确实必须提供 Jar 来运行需要依赖项的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.