java
アプリケーションからspark
バッチアプリケーションを実行するアプリケーションで作業しています。Javaアプリケーションからのスパークアプリケーションの起動と監視
spark
アプリケーションを開始するスレッドを開始するメインクラスが1つあります。これはzookeeper
を使用してspark
アプリケーションを開始するマシンの中でleader
を検索します。 leader
を選択するとコードがspark
アプリケーションを起動することで実行します以下、
public static void main(String[] args) throws IOException {
final int id = Integer.valueOf(args[0]);
final String zkURL = args[1];
final ExecutorService service = Executors.newSingleThreadExecutor();
final Future<?> status = service.submit(new ProcessNode(id, zkURL));
try {
status.get();
} catch (InterruptedException | ExecutionException e) {
LOG.fatal(e.getMessage(), e);
service.shutdown();
}
:Main
方法は次のようになります。
protected Boolean executeCommand() {
try {
final Runtime rt = Runtime.getRuntime();
final Process proc = rt.exec("sh start-sparkapp.sh");
final int exitVal = proc.waitFor();
BufferedReader buf = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line = "";
while ((line=buf.readLine())!=null) {
System.out.println(line);
}
System.out.println(" commandToExecute exited with code: " + exitVal);
proc.destroy();
} catch (final Exception e) {
System.out.println("Exception occurred while Launching process : " + e.getMessage());
return Boolean.FALSE;
}
return Boolean.TRUE;
}
しかし、これは長いランニングspark
ジョブを開始します。だから私は、spark
仕事が終了したときにのみ、コードの次の部分が実行されると思います。私の要件は、すぐにspark
アプリケーションが開始されると、コントロールは同じspark
アプリケーションのステータスを監視しているコードの次の部分に進みます。つまり、spark
アプリケーションを起動し、同じjava
アプリケーションからspark
アプリケーションのステータスを監視します。 私はどのようにこれを達成するために、アプリケーション
public String monitor(ApplicationId id)
どれ提案の状態を監視する方法montior
を持っていると仮定しますか?
タグ 'apache-spark'は正当なものですか? – suj1th