2017-05-31 36 views
0

重新啓動弗林克工作這似乎是一個相當簡單的問題,但經過研究好幾天我還想不出辦法優雅地取消弗林克工作,從代碼如何從代碼

重新啓動它

作爲參考,有一個類似的帖子:Canceling Apache Flink job from the code,但它沒有告訴如何獲取JobManager,它有cancel()方法可能有幫助。

有人可以解釋這一點嗎?

回答

0

我認爲,通過代碼取消flink作業的最簡單方法是使用rest api。 請參閱:https://ci.apache.org/projects/flink/flink-docs-release-1.2/monitoring/rest_api.html#job-cancellation

然後你就可以在主類的你弗林克代碼定義重啓策略。像

final int restartAttempts = configuration.getInteger(RESTART_ATTEMPTS, 3); 
final int delayBtwAttempts = configuration.getInteger(RESTART_DELAY_IN_MILLIS, 3000); 
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); 
env.setRestartStrategy(fixedDelayRestart(restartAttempts, delayBtwAttempts)); 

參見:https://ci.apache.org/projects/flink/flink-docs-release-1.2/dev/restart_strategies.html