2
package org.myorg.quickstart;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;
import org.apache.flink.runtime.minicluster.LocalFlinkMiniCluster;
import org.apache.flink.configuration.Configuration;
public class WordCount {
public static void main(String[] args) throws Exception {
final LocalFlinkMiniCluster cluster = new LocalFlinkMiniCluster(new Configuration(), false); //line 16
cluster.start(); //line 17
final StreamExecutionEnvironment env = StreamExecutionEnvironment.createRemoteEnvironment("localhost", 6123);
final long N = 10;
DataStream<Long> stream = env.generateSequence(1, N);
stream.map(new MapFunction<Long, Long>() {
@Override
public Long map(Long value) throws Exception {
return 2 * value;
}
}).print();
env.execute("WC Test");
}
public static final class LineSplitter implements FlatMapFunction<String, Tuple2<String, Integer>> {
@Override
public void flatMap(String value, Collector<Tuple2<String, Integer>> out) {
// normalize and split the line
String[] tokens = value.toLowerCase().split("\\W+");
// emit the pairs
for (String token : tokens) {
if (token.length() > 0) {
out.collect(new Tuple2<String, Integer>(token, 1));
}
}
}
}
}
上面的代碼可以在本地小型集羣上本地運行(Windows + IDEA)。將flink作業提交到遠程virtualbox不起作用
然後,我註釋掉第16行和第17行。我在virtualbox中啓動Flink
,或者通過start-local.sh
或start-cluster.sh
。但是,這次我的程序在IDEA
中失敗。它抱怨與職位經理無關如下。
任何人都可以幫我找出失敗的原因嗎?我需要在virtualbox中爲Flink
進行特殊設置。我已經在virtualbox設置中將JobManager
端口6123
轉發給了我。我甚至編譯了jar
,並在virtualbox內運行jar
,出現同樣的錯誤。
09:16:00,631 INFO org.apache.flink.streaming.api.environment.RemoteStreamEnvironment - Running remotely at localhost:6123
09:16:01,220 INFO org.apache.flink.client.program.StandaloneClusterClient - Submitting job with JobID: 2e53f2e2f66f023c2f4748f7fe6d4545. Waiting for job completion.
Submitting job with JobID: 2e53f2e2f66f023c2f4748f7fe6d4545. Waiting for job completion.
09:16:01,220 INFO org.apache.flink.client.program.StandaloneClusterClient - Starting client actor system.
09:16:02,212 INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
09:16:02,295 INFO Remoting - Starting remoting
09:16:02,530 INFO Remoting - Remoting started; listening on addresses :[akka.tcp://[email protected]:56050]
09:16:02,542 INFO org.apache.flink.runtime.client.JobClientActor - Disconnect from JobManager null.
09:16:02,550 INFO org.apache.flink.runtime.client.JobClientActor - Received job Window WordCount (2e53f2e2f66f023c2f4748f7fe6d4545).
09:16:02,550 INFO org.apache.flink.runtime.client.JobClientActor - Could not submit job Window WordCount (2e53f2e2f66f023c2f4748f7fe6d4545), because there is no connection to a JobManager.
09:16:02,624 WARN akka.remote.ReliableDeliverySupervisor - Association with remote system [akka.tcp://[email protected]:6123] has failed, address is now gated for [5000] ms. Reason is: [Association failed with [akka.tcp://[email protected]:6123]].
Process finished with exit code 1
嘗試將'jobmanager.rpc.address'設置爲'0.0.0.0',因爲默認情況下它[設置爲'localhost'](https://ci.apache.org/projects/flink/flink-docs-release -1.1 /設置/ config.html#jobmanager放大器 - 任務管理器)。所以,好像Job Manager只接受來自'localhost/127.0.0.1'的連接。 –
還有一個問題:你通過路徑Job Manager/Configuration/jobmanager.rpc.address'在Flink Web UI中看到了什麼IP? –