MyJavaSparkListener類星火:onApplicationStart永遠不會被調用
package com.streamanalytix.spark.core.pipeline;
import org.apache.commons.logging.Log;
import org.apache.spark.JavaSparkListener;
import org.apache.spark.scheduler.SparkListenerApplicationEnd;
import org.apache.spark.scheduler.SparkListenerApplicationStart;
import org.apache.spark.scheduler.SparkListenerBlockManagerAdded;
import org.apache.spark.scheduler.SparkListenerBlockManagerRemoved;
public class MyJavaSparkListener extends JavaSparkListener {
/** The Constant LOGGER. */
private static final Log LOGGER = LogUtil.getLogger(MyJavaSparkListener.class);
public MyJavaSparkListener() {
super();
LOGGER.info("---------------------------------------------- Creating new SaxJavaSparkListener");
}
@Override
public void onApplicationStart(SparkListenerApplicationStart arg0) {
LOGGER.info("---------------------------------------------- Spark pipeline is up and running...");
}
@Override
public void onApplicationEnd(SparkListenerApplicationEnd arg0) {
LOGGER.info("---------------------------------------------- Spark pipeline going to shutdown...");
}
@Override
public void onBlockManagerAdded(SparkListenerBlockManagerAdded blockManagerAdded) {
LOGGER.info("---------------------------------------------- onBlockManagerAdded");
}
@Override
public void onBlockManagerRemoved(SparkListenerBlockManagerRemoved blockManagerRemoved) {
LOGGER.info("---------------------------------------------- onBlockManagerRemoved");
}
}
我註冊這個監聽器有以下行
context.sparkContext().sc().addSparkListener(new MyJavaSparkListener());
我在客戶端模式下運行的Spark應用程序,但我沒有看到任何日誌打印爲onApplicationStart
或onApplicationEnd
。但是,調用onBlockManagerAdded
並打印日誌。 我不知道如何使用onApplicationStart
或者如何使用它,因爲文檔太有限了。
謝謝。